-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from dmzz-yyhyy/reading_ui
完成阅读中页面ui搭建
- Loading branch information
Showing
29 changed files
with
717 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/BookInformation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/BookVolumes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/ChapterContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/ChapterInformation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/UserReadingData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/data/book/Volume.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 159 additions & 5 deletions
164
app/src/main/java/indi/dmzz_yyhyy/lightnovelreader/ui/home/HomeScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("施工中") | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.