refactor: updated UI
This commit is contained in:
@@ -13,17 +13,14 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".FillTemplateActivity"
|
android:name=".FillTemplateActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_fill_template"
|
|
||||||
android:theme="@style/Theme.OmniCards" />
|
android:theme="@style/Theme.OmniCards" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".SelectTemplateActivity"
|
android:name=".SelectTemplateActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_select_template"
|
|
||||||
android:theme="@style/Theme.OmniCards" />
|
android:theme="@style/Theme.OmniCards" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ChooseColorActivity"
|
android:name=".ChooseColorActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_choose_color"
|
|
||||||
android:theme="@style/Theme.OmniCards" />
|
android:theme="@style/Theme.OmniCards" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".BackupActivity"
|
android:name=".BackupActivity"
|
||||||
@@ -33,10 +30,6 @@
|
|||||||
android:name=".EditCardActivity"
|
android:name=".EditCardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.OmniCards" />
|
android:theme="@style/Theme.OmniCards" />
|
||||||
<activity
|
|
||||||
android:name=".SelectColorActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:theme="@style/Theme.OmniCards" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ShowCardActivity"
|
android:name=".ShowCardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import androidx.activity.enableEdgeToEdge
|
|||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -132,14 +133,16 @@ fun BackupPage(innerPadding: PaddingValues, getDbFun: () -> DbHelper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Page(stringResource(R.string.backup), innerPadding) {
|
Page(stringResource(R.string.backup), innerPadding) {
|
||||||
FullWidthButton(
|
AdaptiveButton(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
createBackupLauncher.launch("omnicards-backup.json")
|
createBackupLauncher.launch("omnicards-backup.json")
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text(stringResource(R.string.do_backup))
|
Text(stringResource(R.string.do_backup))
|
||||||
}
|
}
|
||||||
FullWidthButton(
|
AdaptiveButton(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
restoreFromBackupLauncher.launch("application/json")
|
restoreFromBackupLauncher.launch("application/json")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ fun EditColorPage(innerPadding: PaddingValues, currentColor: String?) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
val resultIntent = Intent()
|
val resultIntent = Intent()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package ru.omni_devel.cards
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
@@ -17,15 +16,10 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.Button
|
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
@@ -37,17 +31,10 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.graphics.toColorInt
|
|
||||||
import com.github.skydoves.colorpicker.compose.ColorEnvelope
|
|
||||||
import com.github.skydoves.colorpicker.compose.HsvColorPicker
|
|
||||||
import com.github.skydoves.colorpicker.compose.rememberColorPickerController
|
|
||||||
import com.google.zxing.BarcodeFormat
|
import com.google.zxing.BarcodeFormat
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
@@ -145,14 +132,14 @@ fun CardEditable(
|
|||||||
label = { Text(stringResource(R.string.card_value)) }
|
label = { Text(stringResource(R.string.card_value)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
scanLauncher.launch(
|
scanLauncher.launch(
|
||||||
ScanOptions().apply {
|
ScanOptions().apply {
|
||||||
setPrompt(context.getString(R.string.scan_your_card))
|
setPrompt(context.getString(R.string.scan_your_card))
|
||||||
setBeepEnabled(true)
|
setBeepEnabled(true)
|
||||||
setOrientationLocked(false)
|
setOrientationLocked(true)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -160,7 +147,7 @@ fun CardEditable(
|
|||||||
Text(stringResource(R.string.do_scan_card))
|
Text(stringResource(R.string.do_scan_card))
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = Intent(context, SelectTemplateActivity::class.java)
|
val intent = Intent(context, SelectTemplateActivity::class.java)
|
||||||
@@ -207,9 +194,10 @@ fun CardEditable(
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = fieldModifier,
|
modifier = fieldModifier,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
Button(
|
AdaptiveButton(
|
||||||
|
modifier = Modifier.fillMaxWidth().weight(1.0f),
|
||||||
enabled = isColorEnabled,
|
enabled = isColorEnabled,
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = Intent(context, ChooseColorActivity::class.java)
|
val intent = Intent(context, ChooseColorActivity::class.java)
|
||||||
@@ -263,7 +251,7 @@ fun AddCard(innerPadding: PaddingValues, getDbFun: () -> DbHelper) {
|
|||||||
onColorChange = { color = it }
|
onColorChange = { color = it }
|
||||||
)
|
)
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
cardName = cardName.trim()
|
cardName = cardName.trim()
|
||||||
@@ -312,7 +300,7 @@ fun EditCard(cardInfo: CardInfo, innerPadding: PaddingValues, getDbFun: () -> Db
|
|||||||
onColorChange = { color = it }
|
onColorChange = { color = it }
|
||||||
)
|
)
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
cardName = cardName.trim()
|
cardName = cardName.trim()
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ package ru.omni_devel.cards
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.activity.compose.LocalActivity
|
import androidx.activity.compose.LocalActivity
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.gestures.detectTapGestures
|
import androidx.compose.foundation.gestures.detectTapGestures
|
||||||
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
@@ -20,7 +23,9 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonColors
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.ButtonElevation
|
||||||
import androidx.compose.material3.DrawerValue
|
import androidx.compose.material3.DrawerValue
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
@@ -40,7 +45,9 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier.Companion
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.input.pointer.pointerInput
|
import androidx.compose.ui.input.pointer.pointerInput
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -119,7 +126,9 @@ fun Page(name: String, innerPadding: PaddingValues, pages: List<NavigationPageDa
|
|||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
.padding(top = 16.dp)
|
.padding(top = 16.dp)
|
||||||
) {
|
) {
|
||||||
Column() {
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,7 +181,7 @@ fun CardButton(cardInfo: CardInfo, onDeleteCard: (Int) -> Unit) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = ButtonDefaults.shape,
|
||||||
color = MaterialTheme.colorScheme.primaryContainer,
|
color = MaterialTheme.colorScheme.primaryContainer,
|
||||||
tonalElevation = 2.dp
|
tonalElevation = 2.dp
|
||||||
) {
|
) {
|
||||||
@@ -232,11 +241,30 @@ fun CardButton(cardInfo: CardInfo, onDeleteCard: (Int) -> Unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FullWidthButton(onClick: () -> Unit, content: @Composable () -> Unit) {
|
fun AdaptiveButton(
|
||||||
|
onClick: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
enabled: Boolean = true,
|
||||||
|
shape: Shape = ButtonDefaults.shape,
|
||||||
|
elevation: ButtonElevation? = ButtonDefaults.buttonElevation(),
|
||||||
|
border: BorderStroke? = null,
|
||||||
|
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
|
||||||
|
interactionSource: MutableInteractionSource? = null,
|
||||||
|
content: @Composable RowScope.() -> Unit
|
||||||
|
) {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
onClick = onClick,
|
||||||
onClick = onClick
|
modifier = modifier,
|
||||||
) {
|
enabled = enabled,
|
||||||
content()
|
shape = shape,
|
||||||
}
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
),
|
||||||
|
elevation = elevation,
|
||||||
|
border = border,
|
||||||
|
contentPadding = contentPadding,
|
||||||
|
interactionSource = interactionSource,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ fun FillTemplatePage(template: Template, innerPadding: PaddingValues) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
var isSuccess = true
|
var isSuccess = true
|
||||||
@@ -106,7 +106,7 @@ fun FillTemplatePage(template: Template, innerPadding: PaddingValues) {
|
|||||||
if (!isSuccess) {
|
if (!isSuccess) {
|
||||||
Toast.makeText(context, context.getString(R.string.error_in_data), Toast.LENGTH_LONG).show()
|
Toast.makeText(context, context.getString(R.string.error_in_data), Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
return@Button
|
return@AdaptiveButton
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = template.template
|
var result = template.template
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ fun SelectTemplatePage(innerPadding: PaddingValues) {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
for (template in templates) {
|
for (template in templates) {
|
||||||
Button(
|
AdaptiveButton(
|
||||||
modifier = Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.primaryContainer),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = Intent(context, FillTemplateActivity::class.java)
|
val intent = Intent(context, FillTemplateActivity::class.java)
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<string name="do_choose_color">Выбрать цвет</string>
|
<string name="do_choose_color">Выбрать цвет</string>
|
||||||
<string name="choosing_color">Выбор цвета</string>
|
<string name="choosing_color">Выбор цвета</string>
|
||||||
<string name="choosing_template">Выбор шаблона</string>
|
<string name="choosing_template">Выбор шаблона</string>
|
||||||
<string name="error_in_data">Ошибка в данных</string>
|
<string name="error_in_data">Ошибка в данных. Пожалуйста, заполните все необходимые (*) поля</string>
|
||||||
<string name="card_name_should_not_be_empty">Имя карты не должно быть пустым</string>
|
<string name="card_name_should_not_be_empty">Имя карты не должно быть пустым</string>
|
||||||
<string name="card_value_should_not_be_empty">Значение карты не должно быть пустым</string>
|
<string name="card_value_should_not_be_empty">Значение карты не должно быть пустым</string>
|
||||||
<string name="name_must_be_shorter_than_32_symbols">Имя карты должно быть короче 32 символов</string>
|
<string name="name_must_be_shorter_than_32_symbols">Имя карты должно быть короче 32 символов</string>
|
||||||
|
|||||||
@@ -42,13 +42,10 @@
|
|||||||
<string name="do_choose_color">Choose color</string>
|
<string name="do_choose_color">Choose color</string>
|
||||||
<string name="choosing_color">Choosing color</string>
|
<string name="choosing_color">Choosing color</string>
|
||||||
<string name="choosing_template">Choosing template</string>
|
<string name="choosing_template">Choosing template</string>
|
||||||
<string name="error_in_data">Error in data</string>
|
<string name="error_in_data">Error in data. Please, fill all required (*) fields</string>
|
||||||
<string name="card_name_should_not_be_empty">Card name must not be empty</string>
|
<string name="card_name_should_not_be_empty">Card name must not be empty</string>
|
||||||
<string name="card_value_should_not_be_empty">Card value must not be empty</string>
|
<string name="card_value_should_not_be_empty">Card value must not be empty</string>
|
||||||
<string name="name_must_be_shorter_than_32_symbols">Card name must be shorter than 32 characters</string>
|
<string name="name_must_be_shorter_than_32_symbols">Card name must be shorter than 32 characters</string>
|
||||||
|
|
||||||
<string name="failed_to_generate_card_code">Failed to generate card code. Check the card data</string>
|
<string name="failed_to_generate_card_code">Failed to generate card code. Check the card data</string>
|
||||||
<string name="title_activity_choose_color">ChooseColorActivity</string>
|
|
||||||
<string name="title_activity_select_template">SelectTemplateActivity</string>
|
|
||||||
<string name="title_activity_fill_template">FillTemplateActivity</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user