refactor + feat: updated UI and added cards search logic
This commit is contained in:
@@ -30,6 +30,11 @@ import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Palette
|
||||
import androidx.compose.material.icons.outlined.QrCodeScanner
|
||||
import androidx.compose.material.icons.outlined.TextFields
|
||||
import androidx.compose.material.icons.outlined.Save
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.setValue
|
||||
@@ -88,7 +93,6 @@ fun CardEditable(
|
||||
var isCodeTypeDropdownExpanded by rememberSaveable { mutableStateOf(false) }
|
||||
var isColorEnabled by rememberSaveable { mutableStateOf(color != null) }
|
||||
var currentColor by rememberSaveable { mutableStateOf(color) }
|
||||
var currentIcon by rememberSaveable { mutableStateOf(icon) }
|
||||
|
||||
val fieldModifier = Modifier.fillMaxWidth()
|
||||
|
||||
@@ -151,32 +155,6 @@ fun CardEditable(
|
||||
label = { Text(stringResource(R.string.card_value)) }
|
||||
)
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
scanLauncher.launch(
|
||||
ScanOptions().apply {
|
||||
setPrompt(context.getString(R.string.scan_your_card))
|
||||
setBeepEnabled(true)
|
||||
setOrientationLocked(true)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.do_scan_card))
|
||||
}
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
val intent = Intent(context, SelectTemplateActivity::class.java)
|
||||
|
||||
selectTemplateLauncher.launch(intent)
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.card_from_template))
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = fieldModifier,
|
||||
) {
|
||||
@@ -211,12 +189,41 @@ fun CardEditable(
|
||||
}
|
||||
}
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
icon = Icons.Outlined.QrCodeScanner,
|
||||
onClick = {
|
||||
scanLauncher.launch(
|
||||
ScanOptions().apply {
|
||||
setPrompt(context.getString(R.string.scan_your_card))
|
||||
setBeepEnabled(true)
|
||||
setOrientationLocked(true)
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.do_scan_card))
|
||||
}
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
icon = Icons.Outlined.TextFields,
|
||||
onClick = {
|
||||
val intent = Intent(context, SelectTemplateActivity::class.java)
|
||||
|
||||
selectTemplateLauncher.launch(intent)
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.card_from_template))
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = fieldModifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth().weight(1.0f),
|
||||
icon = Icons.Outlined.Palette,
|
||||
enabled = isColorEnabled,
|
||||
onClick = {
|
||||
val intent = Intent(context, ChooseColorActivity::class.java)
|
||||
@@ -298,6 +305,7 @@ fun AddCard(innerPadding: PaddingValues, getDbFun: () -> DbHelper) {
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
icon = Icons.Outlined.Save,
|
||||
onClick = {
|
||||
cardName = cardName.trim()
|
||||
|
||||
@@ -350,6 +358,7 @@ fun EditCard(cardInfo: CardInfo, innerPadding: PaddingValues, getDbFun: () -> Db
|
||||
|
||||
AdaptiveButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
icon = Icons.Outlined.Save,
|
||||
onClick = {
|
||||
cardName = cardName.trim()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user