@@ -13,14 +13,16 @@ import androidx.compose.material3.*
13
13
import androidx.compose.runtime.*
14
14
import androidx.compose.runtime.saveable.rememberSaveable
15
15
import androidx.compose.ui.Modifier
16
+ import androidx.compose.ui.platform.LocalUriHandler
16
17
import androidx.compose.ui.res.painterResource
17
18
import androidx.compose.ui.res.stringResource
18
- import androidx.compose.ui.text.style.TextAlign
19
19
import androidx.compose.ui.unit.dp
20
20
import cafe.adriel.voyager.core.screen.Screen
21
21
import cafe.adriel.voyager.koin.getScreenModel
22
22
import com.aliucord.manager.R
23
+ import com.aliucord.manager.network.service.AliucordGithubService
23
24
import com.aliucord.manager.ui.components.BackButton
25
+ import com.aliucord.manager.ui.components.MainActionButton
24
26
import com.aliucord.manager.ui.components.settings.*
25
27
import com.aliucord.manager.ui.screens.settings.components.ThemeDialog
26
28
import kotlinx.parcelize.IgnoredOnParcel
@@ -34,6 +36,7 @@ class SettingsScreen : Screen, Parcelable {
34
36
@Composable
35
37
override fun Content () {
36
38
val model = getScreenModel<SettingsModel >()
39
+ var clearedCache by rememberSaveable { mutableStateOf(false ) }
37
40
38
41
Scaffold (
39
42
topBar = {
@@ -76,10 +79,9 @@ class SettingsScreen : Screen, Parcelable {
76
79
label = stringResource(R .string.setting_dynamic_color),
77
80
secondaryLabel = stringResource(R .string.setting_dynamic_color_desc),
78
81
pref = preferences.dynamicColor,
79
- icon = { Icon (painterResource(R .drawable.ic_palette), null ) }
80
- ) {
81
- preferences.dynamicColor = it
82
- }
82
+ icon = { Icon (painterResource(R .drawable.ic_palette), null ) },
83
+ onPrefChange = { preferences.dynamicColor = it },
84
+ )
83
85
}
84
86
85
87
SettingsHeader (stringResource(R .string.settings_advanced))
@@ -88,34 +90,44 @@ class SettingsScreen : Screen, Parcelable {
88
90
label = stringResource(R .string.settings_developer_options),
89
91
secondaryLabel = stringResource(R .string.settings_developer_options_desc),
90
92
pref = preferences.devMode,
91
- icon = { Icon (painterResource(R .drawable.ic_code), null ) }
92
- ) {
93
- preferences.devMode = it
94
- }
93
+ icon = { Icon (painterResource(R .drawable.ic_code), null ) },
94
+ onPrefChange = { preferences.devMode = it },
95
+ )
95
96
96
97
SettingsSwitch (
97
98
label = stringResource(R .string.setting_keep_patched_apks),
98
99
secondaryLabel = stringResource(R .string.setting_keep_patched_apks_desc),
99
100
icon = { Icon (painterResource(R .drawable.ic_delete_forever), null ) },
100
101
pref = preferences.keepPatchedApks,
101
102
onPrefChange = model::setKeepPatchedApks,
103
+ modifier = Modifier .padding(bottom = 18 .dp),
102
104
)
103
105
104
- var clearedCache by rememberSaveable { mutableStateOf( false ) }
105
- Button (
106
- shape = ShapeDefaults . Large ,
106
+ MainActionButton (
107
+ text = stringResource( R .string.setting_clear_cache),
108
+ icon = painterResource( R .drawable.ic_delete_forever) ,
107
109
enabled = ! clearedCache,
110
+ colors = IconButtonDefaults .filledTonalIconButtonColors(
111
+ containerColor = MaterialTheme .colorScheme.error,
112
+ ),
108
113
onClick = {
109
114
clearedCache = true
110
115
model.clearCacheDir()
111
116
},
112
117
modifier = Modifier
118
+ .padding(horizontal = 18 .dp, vertical = 10 .dp)
113
119
.fillMaxWidth()
114
- .padding(18 .dp),
115
- ) {
116
- Text (
117
- text = stringResource(R .string.setting_clear_cache),
118
- textAlign = TextAlign .Center
120
+ )
121
+
122
+ if (preferences.keepPatchedApks) {
123
+ val handler = LocalUriHandler .current
124
+ MainActionButton (
125
+ text = stringResource(R .string.setting_see_patched_apks),
126
+ icon = painterResource(R .drawable.ic_launch),
127
+ onClick = { handler.openUri(AliucordGithubService .PATCHED_APKS_INFO_URL ) },
128
+ modifier = Modifier
129
+ .padding(horizontal = 18 .dp, vertical = 9 .dp)
130
+ .fillMaxWidth()
119
131
)
120
132
}
121
133
}
0 commit comments