Skip to content

Commit

Permalink
Merge pull request #19 from dmzz-yyhyy/reading_ui
Browse files Browse the repository at this point in the history
完成阅读中页面ui搭建
  • Loading branch information
dmzz-yyhyy authored Jul 17, 2024
2 parents d70aabd + 42a293c commit 1a2972b
Show file tree
Hide file tree
Showing 29 changed files with 717 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ dependencies {
implementation("androidx.navigation:navigation-dynamic-features-fragment:$navVersion")
androidTestImplementation("androidx.navigation:navigation-testing:$navVersion")
implementation("androidx.navigation:navigation-compose:$navVersion")
// coil
implementation("io.coil-kt:coil-compose:2.6.0")

}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<application
android:usesCleartextTraffic="true"
android:name=".LightNovelReaderApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package indi.dmzz_yyhyy.lightnovelreader
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import dagger.hilt.android.AndroidEntryPoint
import indi.dmzz_yyhyy.lightnovelreader.ui.LightNovelReaderApp
import indi.dmzz_yyhyy.lightnovelreader.ui.theme.LightNovelReaderTheme

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContent {
LightNovelReaderTheme {
MaterialTheme {
LightNovelReaderApp()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

import java.time.LocalDateTime

data class BookInformation(
val id: Int,
val title: String,
val coverUrl: String,
val author: String,
val description: String,
val tags: List<String>,
val publishingHouse: String,
val wordCount: Int,
val lastUpdated: LocalDateTime,
val isComplete: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

data class BookVolumes(
val volumes: List<Volume>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

data class ChapterContent(
val id: Int,
val title: String,
val content: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

data class ChapterInformation(
val id: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

import java.time.LocalDateTime

data class UserReadingData(
val lastReadTime: LocalDateTime,
val totalReadTime: Int,
val readingProgress: Double,
val lastReadChapterId: Int,
val lastReadChapterTitle: String,
val lastReadChapterProgress: Double
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package indi.dmzz_yyhyy.lightnovelreader.data.book

data class Volume(
val volumeId: Int,
val volumeTitle: String,
val chapters: List<ChapterInformation>
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fun LightNovelReaderApp() {
fun LightNovelReaderNavHost(
navController: NavHostController
) {
NavHost(navController = navController, startDestination = Screen.Home.Reading.route) {
NavHost(navController = navController, startDestination = Screen.Home.route) {
composable(route = Screen.Home.route) {
HomeScreen(
onOpenBook = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ sealed class Screen(
val navArguments: List<NamedNavArgument> = emptyList()
) {
data object Home : Screen("home") {
data object Reading : Screen("home/reading")
data object Exploration : Screen("home/exploration")
data object Bookshelf : Screen("home/bookshelf")
data object Settings : Screen("home/settings")
data object Reading : Screen("home_reading")
data object Exploration : Screen("home_exploration")
data object Bookshelf : Screen("home_bookshelf")
data object Settings : Screen("home_settings")
}
data object Book {
data object Detail : Screen(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,176 @@
package indi.dmzz_yyhyy.lightnovelreader.ui.home

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import indi.dmzz_yyhyy.lightnovelreader.R
import indi.dmzz_yyhyy.lightnovelreader.ui.Screen
import indi.dmzz_yyhyy.lightnovelreader.ui.home.reading.ReadingScreen

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun HomeScreen(
onOpenBook: (Int) -> Unit
) {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = Screen.Home.Reading.route) {
composable(route = Screen.Home.route) {
ReadingScreen(
onOpenBook = onOpenBook
)
var topBar : @Composable () -> Unit by remember { mutableStateOf(@Composable {}) }
Scaffold(
topBar = topBar,
bottomBar = {
NavigationBar {
var selectedItem by remember { mutableIntStateOf(0) }
NavigationBarItem(
icon = {
if (selectedItem == 0)
Icon(painter = painterResource(id = R.drawable.filled_book_24px),
contentDescription = null,
tint = if (selectedItem == 0)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant)
else Icon(painter = painterResource(id = R.drawable.outline_book_24px),
contentDescription = null,
tint = if (selectedItem == 0)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant) },
label = { Text(
text = "Reading",
style = MaterialTheme.typography.labelMedium,
color = if (selectedItem == 0)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant
) },
selected = selectedItem == 0,
onClick = {
selectedItem = 0
navController.navigate(Screen.Home.Reading.route)
}
)
NavigationBarItem(
icon = {
if (selectedItem == 1)
Icon(painter = painterResource(id = R.drawable.filled_shelves_24px),
contentDescription = null,
tint = if (selectedItem == 1)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant)
else Icon(painter = painterResource(id = R.drawable.outline_shelves_24px),
contentDescription = null,
tint = if (selectedItem == 1)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant) },
label = { Text(
text = "Bookcase",
style = MaterialTheme.typography.labelMedium,
color = if (selectedItem == 1)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant
) },
selected = selectedItem == 1,
onClick = {
selectedItem = 1
navController.navigate(Screen.Home.Bookshelf.route)
}
)
NavigationBarItem(
icon = {
if (selectedItem == 2)
Icon(painter = painterResource(id = R.drawable.filled_explore_24px),
contentDescription = null,
tint = if (selectedItem == 2)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant)
else Icon(painter = painterResource(id = R.drawable.outline_explore_24px),
contentDescription = null,
tint = if (selectedItem == 2)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant) },
label = { Text(
text = "Exploration",
style = MaterialTheme.typography.labelMedium,
color = if (selectedItem == 2)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant
) },
selected = selectedItem == 2,
onClick = {
selectedItem = 2
navController.navigate(Screen.Home.Exploration.route)
}
)
NavigationBarItem(
icon = {
if (selectedItem == 3)
Icon(painter = painterResource(id = R.drawable.filled_settings_24px),
contentDescription = null,
tint = if (selectedItem == 3)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant)
else Icon(painter = painterResource(id = R.drawable.outline_settings_24px),
contentDescription = null,
tint = if (selectedItem == 3)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant) },
label = { Text(
text = "Settings",
style = MaterialTheme.typography.labelMedium,
color = if (selectedItem == 3)
MaterialTheme.colorScheme.onSurface
else
MaterialTheme.colorScheme.onSurfaceVariant
) },
selected = selectedItem == 3,
onClick = {
selectedItem = 3
navController.navigate(Screen.Home.Settings.route)
}
)
}
}
) {
Box(Modifier.padding(it)) {
NavHost(navController = navController, startDestination = Screen.Home.Reading.route) {
composable(route = Screen.Home.Reading.route) {
ReadingScreen(onOpenBook) { topBar1 -> topBar = topBar1 }
}
composable(route = Screen.Home.Bookshelf.route) {
Text("施工中")
}
composable(route = Screen.Home.Exploration.route) {
Text("施工中")
}
composable(route = Screen.Home.Settings.route) {
Text("施工中")
}
}
}
}
}
Loading

0 comments on commit 1a2972b

Please sign in to comment.