Opt the code and add color to the buttons.
This commit is contained in:
@@ -65,7 +65,6 @@ fun SearchAppBar(
|
||||
// 获取卡片颜色和透明度
|
||||
val cardColor = MaterialTheme.colorScheme.secondaryContainer
|
||||
val cardAlpha = CardConfig.cardAlpha
|
||||
val cardElevation = CardConfig.cardElevation
|
||||
|
||||
if (onSearch) {
|
||||
LaunchedEffect(Unit) { focusRequester.requestFocus() }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package shirkneko.zako.sukisu.ui.component
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.Switch
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package shirkneko.zako.sukisu.ui.screen
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
@@ -49,6 +50,7 @@ import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import shirkneko.zako.sukisu.ui.theme.CardConfig
|
||||
import androidx.core.content.edit
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Destination<RootGraph>(start = true)
|
||||
@@ -116,7 +118,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
UpdateCard()
|
||||
}
|
||||
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) {
|
||||
AnimatedVisibility(
|
||||
@@ -132,7 +134,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
clickCount++
|
||||
prefs.edit().putInt("click_count", clickCount).apply()
|
||||
prefs.edit { putInt("click_count", clickCount) }
|
||||
}
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
@@ -574,6 +576,7 @@ private fun WarningCardPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
private fun getDeviceModel(context: Context): String {
|
||||
return try {
|
||||
val marketName = context.getSystemService(Context.APP_OPS_SERVICE)?.let { appOps ->
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package shirkneko.zako.sukisu.ui.screen
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
@@ -28,7 +27,6 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.maxkeppeker.sheets.core.models.base.Header
|
||||
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
|
||||
@@ -129,7 +127,6 @@ fun InstallScreen(navigator: DestinationsNavigator) {
|
||||
} else {
|
||||
onInstall()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
val selectLkmLauncher = rememberLauncherForActivityResult(
|
||||
|
||||
@@ -111,7 +111,9 @@ import shirkneko.zako.sukisu.ui.viewmodel.ModuleViewModel
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
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)
|
||||
@@ -152,7 +154,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
var line: String?
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
if (line?.startsWith("name=") == true) {
|
||||
name = line?.substringAfter("=") ?: name
|
||||
name = line.substringAfter("=")
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -205,7 +207,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
var line: String?
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
if (line?.startsWith("name=") == true) {
|
||||
name = line?.substringAfter("=") ?: name
|
||||
name = line.substringAfter("=")
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -285,9 +287,12 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
trailingIcon = { Checkbox(viewModel.sortActionFirst, null) },
|
||||
onClick = {
|
||||
viewModel.sortActionFirst = !viewModel.sortActionFirst
|
||||
prefs.edit()
|
||||
.putBoolean("module_sort_action_first", viewModel.sortActionFirst)
|
||||
.apply()
|
||||
prefs.edit {
|
||||
putBoolean(
|
||||
"module_sort_action_first",
|
||||
viewModel.sortActionFirst
|
||||
)
|
||||
}
|
||||
scope.launch {
|
||||
viewModel.fetchModuleList()
|
||||
}
|
||||
@@ -298,9 +303,9 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
trailingIcon = { Checkbox(viewModel.sortEnabledFirst, null) },
|
||||
onClick = {
|
||||
viewModel.sortEnabledFirst = !viewModel.sortEnabledFirst
|
||||
prefs.edit()
|
||||
.putBoolean("module_sort_enabled_first", viewModel.sortEnabledFirst)
|
||||
.apply()
|
||||
prefs.edit {
|
||||
putBoolean("module_sort_enabled_first", viewModel.sortEnabledFirst)
|
||||
}
|
||||
scope.launch {
|
||||
viewModel.fetchModuleList()
|
||||
}
|
||||
@@ -399,7 +404,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
if (hasWebUi) {
|
||||
webUILauncher.launch(
|
||||
Intent(context, WebUIActivity::class.java)
|
||||
.setData(Uri.parse("kernelsu://webui/$id"))
|
||||
.setData("kernelsu://webui/$id".toUri())
|
||||
.putExtra("id", id)
|
||||
.putExtra("name", name)
|
||||
)
|
||||
@@ -779,8 +784,7 @@ fun ModuleItem(
|
||||
},
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = Color.White,
|
||||
contentColor = Color.Black
|
||||
containerColor = ThemeConfig.currentTheme.ButtonContrast
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
@@ -809,8 +813,7 @@ fun ModuleItem(
|
||||
interactionSource = interactionSource,
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = Color.White,
|
||||
contentColor = Color.Black
|
||||
containerColor = ThemeConfig.currentTheme.ButtonContrast
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
@@ -839,8 +842,7 @@ fun ModuleItem(
|
||||
shape = ButtonDefaults.textShape,
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = Color.White,
|
||||
contentColor = Color.Black
|
||||
containerColor = ThemeConfig.currentTheme.ButtonContrast
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
@@ -866,8 +868,7 @@ fun ModuleItem(
|
||||
onClick = { onUninstallClicked(module) },
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = Color.White,
|
||||
contentColor = Color.Black
|
||||
containerColor = ThemeConfig.currentTheme.ButtonContrast
|
||||
)
|
||||
) {
|
||||
if (!module.remove) {
|
||||
|
||||
@@ -82,6 +82,7 @@ import java.time.format.DateTimeFormatter
|
||||
import androidx.compose.material.icons.filled.ExpandMore
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
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),
|
||||
checked = checkUpdate
|
||||
) {
|
||||
prefs.edit().putBoolean("check_update", it).apply()
|
||||
prefs.edit {putBoolean("check_update", it) }
|
||||
checkUpdate = it
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
summary = stringResource(id = R.string.enable_web_debugging_summary),
|
||||
checked = enableWebDebugging
|
||||
) {
|
||||
prefs.edit().putBoolean("enable_web_debugging", it).apply()
|
||||
prefs.edit { putBoolean("enable_web_debugging", it) }
|
||||
enableWebDebugging = it
|
||||
}
|
||||
// endregion
|
||||
|
||||
@@ -24,7 +24,6 @@ import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExtendedFloatingActionButton
|
||||
import androidx.compose.material3.FloatingActionButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
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.text.AnnotatedString
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.dropUnlessResumed
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import com.ramcosta.composedestinations.annotation.RootGraph
|
||||
@@ -61,8 +61,6 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import shirkneko.zako.sukisu.R
|
||||
import shirkneko.zako.sukisu.ui.viewmodel.TemplateViewModel
|
||||
import androidx.lifecycle.compose.dropUnlessResumed
|
||||
import shirkneko.zako.sukisu.ui.theme.CardConfig
|
||||
|
||||
/**
|
||||
* @author weishu
|
||||
|
||||
@@ -15,11 +15,12 @@ sealed class ThemeColors {
|
||||
abstract val OnPrimaryContainer: Color
|
||||
abstract val OnSecondaryContainer: Color
|
||||
abstract val OnTertiaryContainer: Color
|
||||
abstract val ButtonContrast: Color
|
||||
|
||||
open fun getCustomSliderActiveColor(): Color = Primary
|
||||
open fun getCustomSliderInactiveColor(): Color = PrimaryContainer
|
||||
|
||||
// Default Theme (Yellow)
|
||||
// Default Theme (white)
|
||||
object Default : ThemeColors() {
|
||||
override val Primary = Color(0xFFFFFFFF)
|
||||
override val Secondary = Color(0xFFF5F5F5)
|
||||
@@ -33,6 +34,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF000000)
|
||||
override val OnSecondaryContainer = Color(0xFF000000)
|
||||
override val OnTertiaryContainer = Color(0xFF000000)
|
||||
override val ButtonContrast = Color(0xFFFFFFFF)
|
||||
}
|
||||
|
||||
// Blue Theme
|
||||
@@ -49,6 +51,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF0A1A2E)
|
||||
override val OnSecondaryContainer = Color(0xFF0A192D)
|
||||
override val OnTertiaryContainer = Color(0xFF071B3D)
|
||||
override val ButtonContrast = Color(0xFF00BFFF)
|
||||
}
|
||||
|
||||
// Green Theme
|
||||
@@ -65,6 +68,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF0A1F0B)
|
||||
override val OnSecondaryContainer = Color(0xFF0A1D0B)
|
||||
override val OnTertiaryContainer = Color(0xFF071F09)
|
||||
override val ButtonContrast = Color(0xFF32CD32)
|
||||
}
|
||||
|
||||
// Purple Theme
|
||||
@@ -81,6 +85,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF1F0A23)
|
||||
override val OnSecondaryContainer = Color(0xFF1C0A21)
|
||||
override val OnTertiaryContainer = Color(0xFF12071C)
|
||||
override val ButtonContrast = Color(0xFFDA70D6)
|
||||
}
|
||||
|
||||
// Orange Theme
|
||||
@@ -97,6 +102,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF1A1100)
|
||||
override val OnSecondaryContainer = Color(0xFF1A1000)
|
||||
override val OnTertiaryContainer = Color(0xFF1A0B00)
|
||||
override val ButtonContrast = Color(0xFFFF6347)
|
||||
}
|
||||
|
||||
// Pink Theme
|
||||
@@ -113,6 +119,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF2E0A14)
|
||||
override val OnSecondaryContainer = Color(0xFF2B0A13)
|
||||
override val OnTertiaryContainer = Color(0xFF1C0311)
|
||||
override val ButtonContrast = Color(0xFFFF1493)
|
||||
}
|
||||
|
||||
// Gray Theme
|
||||
@@ -129,6 +136,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF1A1A1A)
|
||||
override val OnSecondaryContainer = Color(0xFF171717)
|
||||
override val OnTertiaryContainer = Color(0xFF141414)
|
||||
override val ButtonContrast = Color(0xFF696969)
|
||||
}
|
||||
|
||||
object Yellow : ThemeColors() {
|
||||
@@ -144,6 +152,7 @@ sealed class ThemeColors {
|
||||
override val OnPrimaryContainer = Color(0xFF1A1600)
|
||||
override val OnSecondaryContainer = Color(0xFF1A1100)
|
||||
override val OnTertiaryContainer = Color(0xFF1A1717)
|
||||
override val ButtonContrast = Color(0xFFFFD700)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user