界面优化

This commit is contained in:
HapeLee
2026-06-29 02:28:17 +08:00
parent c0b7a555ec
commit 933bded9d8
3 changed files with 181 additions and 57 deletions
@@ -391,7 +391,7 @@ fun AiChatScreen(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(systemBottomPadding) .height(systemBottomPadding)
.background(bottomGradientColor.copy(alpha = 0.68f)) .background(bottomGradientColor.copy(alpha = 0.88f))
) )
} }
@@ -499,7 +499,7 @@ fun AiChatScreen(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.statusBarsPadding() .statusBarsPadding()
.padding(start = 8.dp, top = 8.dp, end = 8.dp, bottom = 24.dp), .padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 24.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
@@ -1252,7 +1252,7 @@ private fun ChatInputBar(
bottom = bottomPadding bottom = bottomPadding
), ),
shape = RoundedCornerShape(32.dp), shape = RoundedCornerShape(32.dp),
color = LegadoTheme.colorScheme.surfaceContainerHigh color = LegadoTheme.colorScheme.surfaceContainerLow
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
@@ -1,8 +1,6 @@
package io.legado.app.ui.book.read package io.legado.app.ui.book.read
import android.app.Activity
import android.content.Context import android.content.Context
import android.content.ContextWrapper
import android.os.Build import android.os.Build
import androidx.activity.compose.LocalActivity import androidx.activity.compose.LocalActivity
import androidx.compose.animation.AnimatedContent import androidx.compose.animation.AnimatedContent
@@ -59,25 +57,28 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowForward import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material.icons.automirrored.filled.Login import androidx.compose.material.icons.automirrored.filled.Login
import androidx.compose.material.icons.filled.Animation
import androidx.compose.material.icons.filled.AutoStories
import androidx.compose.material.icons.filled.Block import androidx.compose.material.icons.filled.Block
import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.filled.BrightnessAuto import androidx.compose.material.icons.filled.BrightnessAuto
import androidx.compose.material.icons.filled.BugReport
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.CleanHands
import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.CloudDownload
import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.FindReplace
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Menu import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Payment import androidx.compose.material.icons.filled.Payment
import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Replay
import androidx.compose.material.icons.filled.SwapHoriz
import androidx.compose.material.icons.filled.Animation
import androidx.compose.material.icons.filled.AutoStories
import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.CleanHands
import androidx.compose.material.icons.filled.CloudDownload
import androidx.compose.material.icons.filled.FindReplace
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Rule import androidx.compose.material.icons.filled.Rule
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.SwapHoriz
import androidx.compose.material.icons.filled.SwapVert import androidx.compose.material.icons.filled.SwapVert
import androidx.compose.material.icons.filled.Sync import androidx.compose.material.icons.filled.Sync
import androidx.compose.material.icons.filled.Toc import androidx.compose.material.icons.filled.Toc
@@ -169,7 +170,6 @@ import io.legado.app.ui.widget.components.AppVerticalSlider
import io.legado.app.ui.widget.components.bookmark.BookmarkEditContent import io.legado.app.ui.widget.components.bookmark.BookmarkEditContent
import io.legado.app.ui.widget.components.button.series.SmallTonalButton import io.legado.app.ui.widget.components.button.series.SmallTonalButton
import io.legado.app.ui.widget.components.divider.PillDivider import io.legado.app.ui.widget.components.divider.PillDivider
import io.legado.app.ui.widget.components.icon.AppIcons
import io.legado.app.ui.widget.components.menuItem.MenuItemIcon import io.legado.app.ui.widget.components.menuItem.MenuItemIcon
import io.legado.app.ui.widget.components.menuItem.RoundDropdownMenu import io.legado.app.ui.widget.components.menuItem.RoundDropdownMenu
import io.legado.app.ui.widget.components.menuItem.RoundDropdownMenuItem import io.legado.app.ui.widget.components.menuItem.RoundDropdownMenuItem
@@ -1008,6 +1008,27 @@ private fun MenuTitleBar(
onIntent = onIntent, onIntent = onIntent,
backdrop = backdrop, backdrop = backdrop,
) )
DownloadActionButton(
state = state,
colors = colors,
onIntent = onIntent,
backdrop = backdrop,
)
} else {
if (state.isLocalTxt) {
TxtTocRuleActionButton(
state = state,
colors = colors,
onIntent = onIntent,
backdrop = backdrop,
)
}
CharsetActionButton(
state = state,
colors = colors,
onIntent = onIntent,
backdrop = backdrop,
)
} }
Box { Box {
@@ -1423,6 +1444,89 @@ private fun MenuTitleBarMergedGlassButton(
.height(20.dp) .height(20.dp)
.background(tint.copy(alpha = 0.15f)) .background(tint.copy(alpha = 0.15f))
) )
// Download
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(40.dp)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
role = Role.Button,
onClick = { onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Download)) },
),
) {
Icon(
imageVector = Icons.Default.CloudDownload,
contentDescription = stringResource(R.string.offline_cache),
tint = tint,
modifier = Modifier.size(20.dp),
)
}
Box(
modifier = Modifier
.width(1.dp)
.height(20.dp)
.background(tint.copy(alpha = 0.15f))
)
} else {
// TXT directory rule
if (state.isLocalTxt) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(40.dp)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
role = Role.Button,
onClick = { onIntent(ReadBookIntent.MenuTocRegex) },
),
) {
Icon(
imageVector = Icons.Default.Toc,
contentDescription = stringResource(R.string.txt_toc_rule),
tint = tint,
modifier = Modifier.size(20.dp),
)
}
Box(
modifier = Modifier
.width(1.dp)
.height(20.dp)
.background(tint.copy(alpha = 0.15f))
)
}
// Text encoding
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.size(40.dp)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
role = Role.Button,
onClick = { onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Charset)) },
),
) {
Icon(
imageVector = Icons.Default.Translate,
contentDescription = stringResource(R.string.set_charset),
tint = tint,
modifier = Modifier.size(20.dp),
)
}
Box(
modifier = Modifier
.width(1.dp)
.height(20.dp)
.background(tint.copy(alpha = 0.15f))
)
} }
// MoreVert - overflow menu // MoreVert - overflow menu
@@ -1558,6 +1662,57 @@ private fun RefreshActionButton(
} }
} }
@Composable
private fun DownloadActionButton(
state: ReadBookUiState,
colors: ReadMenuColors,
onIntent: (ReadBookIntent) -> Unit,
backdrop: Backdrop?,
) {
MenuTitleGlassButton(
onClick = { onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Download)) },
icon = Icons.Default.CloudDownload,
contentDescription = stringResource(R.string.offline_cache),
state = state,
colors = colors,
backdrop = backdrop,
)
}
@Composable
private fun TxtTocRuleActionButton(
state: ReadBookUiState,
colors: ReadMenuColors,
onIntent: (ReadBookIntent) -> Unit,
backdrop: Backdrop?,
) {
MenuTitleGlassButton(
onClick = { onIntent(ReadBookIntent.MenuTocRegex) },
icon = Icons.Default.Toc,
contentDescription = stringResource(R.string.txt_toc_rule),
state = state,
colors = colors,
backdrop = backdrop,
)
}
@Composable
private fun CharsetActionButton(
state: ReadBookUiState,
colors: ReadMenuColors,
onIntent: (ReadBookIntent) -> Unit,
backdrop: Backdrop?,
) {
MenuTitleGlassButton(
onClick = { onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Charset)) },
icon = Icons.Default.Translate,
contentDescription = stringResource(R.string.set_charset),
state = state,
colors = colors,
backdrop = backdrop,
)
}
@Composable @Composable
private fun FloatingIconRow( private fun FloatingIconRow(
state: ReadBookUiState, state: ReadBookUiState,
@@ -1655,32 +1810,11 @@ private fun OverflowDropdownMenu(
if (!state.isLocalBook) { if (!state.isLocalBook) {
RoundDropdownMenuItem( RoundDropdownMenuItem(
text = stringResource(R.string.menu_refresh_all), text = stringResource(R.string.menu_refresh_all),
leadingIcon = menuIcon(AppIcons.Replay), leadingIcon = menuIcon(Icons.Default.Replay),
onClick = { dismiss(); onIntent(ReadBookIntent.MenuRefreshAll) }, onClick = { dismiss(); onIntent(ReadBookIntent.MenuRefreshAll) },
) )
} }
// TXT
if (state.isLocalTxt) {
RoundDropdownMenuItem(
text = stringResource(R.string.txt_toc_rule),
leadingIcon = menuIcon(Icons.Default.Toc),
onClick = { dismiss(); onIntent(ReadBookIntent.MenuTocRegex) },
)
}
// Local book
if (state.isLocalBook) {
RoundDropdownMenuItem(
text = stringResource(R.string.set_charset),
leadingIcon = menuIcon(Icons.Default.Translate),
onClick = {
dismiss()
onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Charset))
},
)
}
PillDivider() PillDivider()
// Content operations // Content operations
@@ -1691,25 +1825,15 @@ private fun OverflowDropdownMenu(
) )
RoundDropdownMenuItem( RoundDropdownMenuItem(
text = stringResource(R.string.edit_content), text = stringResource(R.string.edit_content),
leadingIcon = menuIcon(AppIcons.Edit), leadingIcon = menuIcon(Icons.Default.Edit),
onClick = { onClick = {
dismiss() dismiss()
onIntent(ReadBookIntent.OpenContentEdit) onIntent(ReadBookIntent.OpenContentEdit)
}, },
) )
if (!state.isLocalBook) {
RoundDropdownMenuItem(
text = stringResource(R.string.offline_cache),
leadingIcon = menuIcon(Icons.Default.CloudDownload),
onClick = {
dismiss()
onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.Download))
},
)
}
RoundDropdownMenuItem( RoundDropdownMenuItem(
text = stringResource(R.string.update_toc), text = stringResource(R.string.update_toc),
leadingIcon = menuIcon(AppIcons.Replay), leadingIcon = menuIcon(Icons.Default.Replay),
onClick = { dismiss(); onIntent(ReadBookIntent.MenuUpdateToc) }, onClick = { dismiss(); onIntent(ReadBookIntent.MenuUpdateToc) },
) )
RoundDropdownMenuItem( RoundDropdownMenuItem(
@@ -1737,7 +1861,7 @@ private fun OverflowDropdownMenu(
) )
RoundDropdownMenuItem( RoundDropdownMenuItem(
text = stringResource(R.string.replace_rule_title_setting), text = stringResource(R.string.replace_rule_title_setting),
leadingIcon = menuIcon(AppIcons.Settings), leadingIcon = menuIcon(Icons.Default.Settings),
onClick = { dismiss(); onIntent(ReadBookIntent.MenuSettingReplace) }, onClick = { dismiss(); onIntent(ReadBookIntent.MenuSettingReplace) },
) )
RoundDropdownMenuItem( RoundDropdownMenuItem(
@@ -1855,7 +1979,7 @@ private fun OverflowDropdownMenu(
RoundDropdownMenuItem( RoundDropdownMenuItem(
text = stringResource(R.string.log), text = stringResource(R.string.log),
leadingIcon = menuIcon(AppIcons.BugReport), leadingIcon = menuIcon(Icons.Default.BugReport),
onClick = { onClick = {
dismiss() dismiss()
onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.AppLog)) onIntent(ReadBookIntent.ShowSheet(ReadBookSheet.AppLog))
@@ -1,8 +1,9 @@
package io.legado.app.ui.widget.components.button.series package io.legado.app.ui.widget.components.button.series
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.snap
import androidx.compose.animation.core.tween
import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background import androidx.compose.foundation.background
@@ -19,13 +20,12 @@ import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.ripple import androidx.compose.material3.ripple
import androidx.compose.animation.core.snap
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
@@ -298,7 +298,7 @@ private fun containerColor(style: SeriesIconButtonStyle): Color {
return when (style) { return when (style) {
SeriesIconButtonStyle.Plain -> Color.Transparent SeriesIconButtonStyle.Plain -> Color.Transparent
SeriesIconButtonStyle.Tonal, SeriesIconButtonStyle.Tonal,
SeriesIconButtonStyle.Outlined -> LegadoTheme.colorScheme.surfaceContainerLow SeriesIconButtonStyle.Outlined -> LegadoTheme.colorScheme.surface
} }
} }