Skip to content

Commit a0d4566

Browse files
committed
Enable Both slot Flash options (Add Inactive slot flash warning) : Try 19
1 parent adeca4f commit a0d4566

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.github.capntrips.kernelflasher.ui.components
2+
3+
import androidx.compose.foundation.layout.PaddingValues
4+
import androidx.compose.foundation.layout.padding
5+
import androidx.compose.foundation.shape.RoundedCornerShape
6+
import androidx.compose.material3.ButtonDefaults
7+
import androidx.compose.material3.Text
8+
import androidx.compose.material3.TextButton
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.res.stringResource
12+
import androidx.compose.ui.unit.LayoutDirection
13+
import androidx.compose.ui.unit.dp
14+
import com.github.capntrips.kernelflasher.R
15+
16+
@Composable
17+
fun DialogButton(
18+
buttonText: String,
19+
onClick: () -> Unit
20+
) {
21+
TextButton(
22+
modifier = Modifier.padding(0.dp),
23+
shape = RoundedCornerShape(4.0.dp),
24+
contentPadding = PaddingValues(
25+
horizontal = ButtonDefaults.ContentPadding.calculateLeftPadding(LayoutDirection.Ltr) - (6.667).dp,
26+
vertical = ButtonDefaults.ContentPadding.calculateTopPadding()
27+
),
28+
onClick = onClick
29+
) {
30+
Text(stringResource(R.string.view), maxLines = 1)
31+
}
32+
}

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotFlashContent.kt

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ fun ColumnScope.SlotFlashContent(
5151
navController: NavController
5252
) {
5353
val context = LocalContext.current
54-
val showDialog by viewModel.showCautionDialog.observeAsState()
5554

5655
if (!listOf("/flash/ak3", "/flash/image/flash", "/backup/backup").any { navController.currentDestination!!.route!!.endsWith(it) }) {
5756
SlotCard(
@@ -176,7 +175,7 @@ fun ColumnScope.SlotFlashContent(
176175
}
177176
}
178177
}
179-
if (navController.currentDestination!!.route!!.contains("ak3") && viewModel.wasFlashSuccess == true && viewModel.showCautionDialog.value == true){
178+
if (navController.currentDestination!!.route!!.contains("ak3") && viewModel.wasFlashSuccess == true && viewModel.showCautionDialog == true){
180179
AlertDialog(
181180
onDismissRequest = { viewModel.hideCautionDialog() },
182181
title = { Text("CAUTION", style = MaterialTheme.typography.titleLarge) },
@@ -189,27 +188,22 @@ fun ColumnScope.SlotFlashContent(
189188
}
190189
},
191190
confirmButton = {
192-
OutlinedButton(
193-
onClick = {
191+
DialogButton(
192+
"CHANGE SLOT",
193+
{
194194
viewModel.hideCautionDialog()
195195
viewModel.switchSlot(context)
196-
},
197-
shape = RoundedCornerShape(4.dp),
198-
colors = ButtonDefaults.outlinedButtonColors()
199-
) {
200-
Text("CHANGE SLOT")
201-
}
196+
}
197+
)
202198
},
203199
dismissButton = {
204-
OutlinedButton(
205-
onClick = { viewModel.hideCautionDialog() },
206-
shape = RoundedCornerShape(4.dp)
207-
) {
208-
Text("CANCEL")
209-
}
200+
DialogButton(
201+
"CANCEL",
202+
{
203+
viewModel.hideCautionDialog()
204+
}
205+
)
210206
},
211-
containerColor = MaterialTheme.colorScheme.surface,
212-
contentColor = MaterialTheme.colorScheme.onSurface,
213207
modifier = Modifier.padding(16.dp)
214208
)
215209
}

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SlotViewModel(
8484
val error: String
8585
get() = _error!!
8686
val showCautionDialog: Boolean
87-
get() = _showCautionDialog
87+
get() = _showCautionDialog.value
8888

8989
init {
9090
refresh(context)

0 commit comments

Comments
 (0)