Opt the code and add color to the buttons.

This commit is contained in:
ShirkNeko
2025-03-26 18:59:58 +08:00
parent 0c57ea10f2
commit 9e00e8feb6
8 changed files with 38 additions and 31 deletions

View File

@@ -65,7 +65,6 @@ fun SearchAppBar(
// 获取卡片颜色和透明度 // 获取卡片颜色和透明度
val cardColor = MaterialTheme.colorScheme.secondaryContainer val cardColor = MaterialTheme.colorScheme.secondaryContainer
val cardAlpha = CardConfig.cardAlpha val cardAlpha = CardConfig.cardAlpha
val cardElevation = CardConfig.cardElevation
if (onSearch) { if (onSearch) {
LaunchedEffect(Unit) { focusRequester.requestFocus() } LaunchedEffect(Unit) { focusRequester.requestFocus() }

View File

@@ -1,6 +1,5 @@
package shirkneko.zako.sukisu.ui.component package shirkneko.zako.sukisu.ui.component
import androidx.compose.foundation.clickable
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem import androidx.compose.material3.ListItem
import androidx.compose.material3.Switch import androidx.compose.material3.Switch

View File

@@ -1,5 +1,6 @@
package shirkneko.zako.sukisu.ui.screen package shirkneko.zako.sukisu.ui.screen
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import android.os.PowerManager import android.os.PowerManager
@@ -49,6 +50,7 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically import androidx.compose.animation.shrinkVertically
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import shirkneko.zako.sukisu.ui.theme.CardConfig import shirkneko.zako.sukisu.ui.theme.CardConfig
import androidx.core.content.edit
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Destination<RootGraph>(start = true) @Destination<RootGraph>(start = true)
@@ -116,7 +118,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
UpdateCard() UpdateCard()
} }
val prefs = remember { context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE) } val prefs = remember { context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE) }
var clickCount by rememberSaveable { mutableStateOf(prefs.getInt("click_count", 0)) } var clickCount by rememberSaveable { mutableIntStateOf(prefs.getInt("click_count", 0)) }
if (!isSimpleMode && clickCount < 3) { if (!isSimpleMode && clickCount < 3) {
AnimatedVisibility( AnimatedVisibility(
@@ -132,7 +134,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
.fillMaxWidth() .fillMaxWidth()
.clickable { .clickable {
clickCount++ clickCount++
prefs.edit().putInt("click_count", clickCount).apply() prefs.edit { putInt("click_count", clickCount) }
} }
.padding(16.dp), .padding(16.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
@@ -574,6 +576,7 @@ private fun WarningCardPreview() {
} }
} }
@SuppressLint("PrivateApi")
private fun getDeviceModel(context: Context): String { private fun getDeviceModel(context: Context): String {
return try { return try {
val marketName = context.getSystemService(Context.APP_OPS_SERVICE)?.let { appOps -> val marketName = context.getSystemService(Context.APP_OPS_SERVICE)?.let { appOps ->

View File

@@ -1,7 +1,6 @@
package shirkneko.zako.sukisu.ui.screen package shirkneko.zako.sukisu.ui.screen
import android.app.Activity import android.app.Activity
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@@ -28,7 +27,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.Role
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import com.maxkeppeker.sheets.core.models.base.Header import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
@@ -129,7 +127,6 @@ fun InstallScreen(navigator: DestinationsNavigator) {
} else { } else {
onInstall() onInstall()
} }
Unit
} }
val selectLkmLauncher = rememberLauncherForActivityResult( val selectLkmLauncher = rememberLauncherForActivityResult(

View File

@@ -111,7 +111,9 @@ import shirkneko.zako.sukisu.ui.viewmodel.ModuleViewModel
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStreamReader import java.io.InputStreamReader
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream
import androidx.compose.ui.graphics.Color import androidx.core.content.edit
import androidx.core.net.toUri
import shirkneko.zako.sukisu.ui.theme.ThemeConfig
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@@ -152,7 +154,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
var line: String? var line: String?
while (reader.readLine().also { line = it } != null) { while (reader.readLine().also { line = it } != null) {
if (line?.startsWith("name=") == true) { if (line?.startsWith("name=") == true) {
name = line?.substringAfter("=") ?: name name = line.substringAfter("=")
break break
} }
} }
@@ -205,7 +207,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
var line: String? var line: String?
while (reader.readLine().also { line = it } != null) { while (reader.readLine().also { line = it } != null) {
if (line?.startsWith("name=") == true) { if (line?.startsWith("name=") == true) {
name = line?.substringAfter("=") ?: name name = line.substringAfter("=")
break break
} }
} }
@@ -285,9 +287,12 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
trailingIcon = { Checkbox(viewModel.sortActionFirst, null) }, trailingIcon = { Checkbox(viewModel.sortActionFirst, null) },
onClick = { onClick = {
viewModel.sortActionFirst = !viewModel.sortActionFirst viewModel.sortActionFirst = !viewModel.sortActionFirst
prefs.edit() prefs.edit {
.putBoolean("module_sort_action_first", viewModel.sortActionFirst) putBoolean(
.apply() "module_sort_action_first",
viewModel.sortActionFirst
)
}
scope.launch { scope.launch {
viewModel.fetchModuleList() viewModel.fetchModuleList()
} }
@@ -298,9 +303,9 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
trailingIcon = { Checkbox(viewModel.sortEnabledFirst, null) }, trailingIcon = { Checkbox(viewModel.sortEnabledFirst, null) },
onClick = { onClick = {
viewModel.sortEnabledFirst = !viewModel.sortEnabledFirst viewModel.sortEnabledFirst = !viewModel.sortEnabledFirst
prefs.edit() prefs.edit {
.putBoolean("module_sort_enabled_first", viewModel.sortEnabledFirst) putBoolean("module_sort_enabled_first", viewModel.sortEnabledFirst)
.apply() }
scope.launch { scope.launch {
viewModel.fetchModuleList() viewModel.fetchModuleList()
} }
@@ -399,7 +404,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
if (hasWebUi) { if (hasWebUi) {
webUILauncher.launch( webUILauncher.launch(
Intent(context, WebUIActivity::class.java) Intent(context, WebUIActivity::class.java)
.setData(Uri.parse("kernelsu://webui/$id")) .setData("kernelsu://webui/$id".toUri())
.putExtra("id", id) .putExtra("id", id)
.putExtra("name", name) .putExtra("name", name)
) )
@@ -779,8 +784,7 @@ fun ModuleItem(
}, },
contentPadding = ButtonDefaults.TextButtonContentPadding, contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors( colors = ButtonDefaults.filledTonalButtonColors(
containerColor = Color.White, containerColor = ThemeConfig.currentTheme.ButtonContrast
contentColor = Color.Black
) )
) { ) {
Icon( Icon(
@@ -809,8 +813,7 @@ fun ModuleItem(
interactionSource = interactionSource, interactionSource = interactionSource,
contentPadding = ButtonDefaults.TextButtonContentPadding, contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors( colors = ButtonDefaults.filledTonalButtonColors(
containerColor = Color.White, containerColor = ThemeConfig.currentTheme.ButtonContrast
contentColor = Color.Black
) )
) { ) {
Icon( Icon(
@@ -839,8 +842,7 @@ fun ModuleItem(
shape = ButtonDefaults.textShape, shape = ButtonDefaults.textShape,
contentPadding = ButtonDefaults.TextButtonContentPadding, contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors( colors = ButtonDefaults.filledTonalButtonColors(
containerColor = Color.White, containerColor = ThemeConfig.currentTheme.ButtonContrast
contentColor = Color.Black
) )
) { ) {
Icon( Icon(
@@ -866,8 +868,7 @@ fun ModuleItem(
onClick = { onUninstallClicked(module) }, onClick = { onUninstallClicked(module) },
contentPadding = ButtonDefaults.TextButtonContentPadding, contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors( colors = ButtonDefaults.filledTonalButtonColors(
containerColor = Color.White, containerColor = ThemeConfig.currentTheme.ButtonContrast
contentColor = Color.Black
) )
) { ) {
if (!module.remove) { if (!module.remove) {

View File

@@ -82,6 +82,7 @@ import java.time.format.DateTimeFormatter
import androidx.compose.material.icons.filled.ExpandMore import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import shirkneko.zako.sukisu.ui.theme.CardConfig import shirkneko.zako.sukisu.ui.theme.CardConfig
import androidx.core.content.edit
/** /**
@@ -198,7 +199,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
summary = stringResource(id = R.string.settings_check_update_summary), summary = stringResource(id = R.string.settings_check_update_summary),
checked = checkUpdate checked = checkUpdate
) { ) {
prefs.edit().putBoolean("check_update", it).apply() prefs.edit {putBoolean("check_update", it) }
checkUpdate = it checkUpdate = it
} }
@@ -214,7 +215,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
summary = stringResource(id = R.string.enable_web_debugging_summary), summary = stringResource(id = R.string.enable_web_debugging_summary),
checked = enableWebDebugging checked = enableWebDebugging
) { ) {
prefs.edit().putBoolean("enable_web_debugging", it).apply() prefs.edit { putBoolean("enable_web_debugging", it) }
enableWebDebugging = it enableWebDebugging = it
} }
// endregion // endregion

View File

@@ -24,7 +24,6 @@ import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExtendedFloatingActionButton import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem import androidx.compose.material3.ListItem
@@ -50,6 +49,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.dropUnlessResumed
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph import com.ramcosta.composedestinations.annotation.RootGraph
@@ -61,8 +61,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import shirkneko.zako.sukisu.R import shirkneko.zako.sukisu.R
import shirkneko.zako.sukisu.ui.viewmodel.TemplateViewModel import shirkneko.zako.sukisu.ui.viewmodel.TemplateViewModel
import androidx.lifecycle.compose.dropUnlessResumed
import shirkneko.zako.sukisu.ui.theme.CardConfig
/** /**
* @author weishu * @author weishu

View File

@@ -15,11 +15,12 @@ sealed class ThemeColors {
abstract val OnPrimaryContainer: Color abstract val OnPrimaryContainer: Color
abstract val OnSecondaryContainer: Color abstract val OnSecondaryContainer: Color
abstract val OnTertiaryContainer: Color abstract val OnTertiaryContainer: Color
abstract val ButtonContrast: Color
open fun getCustomSliderActiveColor(): Color = Primary open fun getCustomSliderActiveColor(): Color = Primary
open fun getCustomSliderInactiveColor(): Color = PrimaryContainer open fun getCustomSliderInactiveColor(): Color = PrimaryContainer
// Default Theme (Yellow) // Default Theme (white)
object Default : ThemeColors() { object Default : ThemeColors() {
override val Primary = Color(0xFFFFFFFF) override val Primary = Color(0xFFFFFFFF)
override val Secondary = Color(0xFFF5F5F5) override val Secondary = Color(0xFFF5F5F5)
@@ -33,6 +34,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF000000) override val OnPrimaryContainer = Color(0xFF000000)
override val OnSecondaryContainer = Color(0xFF000000) override val OnSecondaryContainer = Color(0xFF000000)
override val OnTertiaryContainer = Color(0xFF000000) override val OnTertiaryContainer = Color(0xFF000000)
override val ButtonContrast = Color(0xFFFFFFFF)
} }
// Blue Theme // Blue Theme
@@ -49,6 +51,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF0A1A2E) override val OnPrimaryContainer = Color(0xFF0A1A2E)
override val OnSecondaryContainer = Color(0xFF0A192D) override val OnSecondaryContainer = Color(0xFF0A192D)
override val OnTertiaryContainer = Color(0xFF071B3D) override val OnTertiaryContainer = Color(0xFF071B3D)
override val ButtonContrast = Color(0xFF00BFFF)
} }
// Green Theme // Green Theme
@@ -65,6 +68,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF0A1F0B) override val OnPrimaryContainer = Color(0xFF0A1F0B)
override val OnSecondaryContainer = Color(0xFF0A1D0B) override val OnSecondaryContainer = Color(0xFF0A1D0B)
override val OnTertiaryContainer = Color(0xFF071F09) override val OnTertiaryContainer = Color(0xFF071F09)
override val ButtonContrast = Color(0xFF32CD32)
} }
// Purple Theme // Purple Theme
@@ -81,6 +85,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF1F0A23) override val OnPrimaryContainer = Color(0xFF1F0A23)
override val OnSecondaryContainer = Color(0xFF1C0A21) override val OnSecondaryContainer = Color(0xFF1C0A21)
override val OnTertiaryContainer = Color(0xFF12071C) override val OnTertiaryContainer = Color(0xFF12071C)
override val ButtonContrast = Color(0xFFDA70D6)
} }
// Orange Theme // Orange Theme
@@ -97,6 +102,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF1A1100) override val OnPrimaryContainer = Color(0xFF1A1100)
override val OnSecondaryContainer = Color(0xFF1A1000) override val OnSecondaryContainer = Color(0xFF1A1000)
override val OnTertiaryContainer = Color(0xFF1A0B00) override val OnTertiaryContainer = Color(0xFF1A0B00)
override val ButtonContrast = Color(0xFFFF6347)
} }
// Pink Theme // Pink Theme
@@ -113,6 +119,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF2E0A14) override val OnPrimaryContainer = Color(0xFF2E0A14)
override val OnSecondaryContainer = Color(0xFF2B0A13) override val OnSecondaryContainer = Color(0xFF2B0A13)
override val OnTertiaryContainer = Color(0xFF1C0311) override val OnTertiaryContainer = Color(0xFF1C0311)
override val ButtonContrast = Color(0xFFFF1493)
} }
// Gray Theme // Gray Theme
@@ -129,6 +136,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF1A1A1A) override val OnPrimaryContainer = Color(0xFF1A1A1A)
override val OnSecondaryContainer = Color(0xFF171717) override val OnSecondaryContainer = Color(0xFF171717)
override val OnTertiaryContainer = Color(0xFF141414) override val OnTertiaryContainer = Color(0xFF141414)
override val ButtonContrast = Color(0xFF696969)
} }
object Yellow : ThemeColors() { object Yellow : ThemeColors() {
@@ -144,6 +152,7 @@ sealed class ThemeColors {
override val OnPrimaryContainer = Color(0xFF1A1600) override val OnPrimaryContainer = Color(0xFF1A1600)
override val OnSecondaryContainer = Color(0xFF1A1100) override val OnSecondaryContainer = Color(0xFF1A1100)
override val OnTertiaryContainer = Color(0xFF1A1717) override val OnTertiaryContainer = Color(0xFF1A1717)
override val ButtonContrast = Color(0xFFFFD700)
} }
companion object { companion object {