Focus amount and default payer
This commit is contained in:
@@ -151,8 +151,9 @@ class EditBillActivity : AppCompatActivity() {
|
|||||||
val billIdToDuplicate = intent.getLongExtra(PARAM_BILL_ID_TO_DUPLICATE, 0)
|
val billIdToDuplicate = intent.getLongExtra(PARAM_BILL_ID_TO_DUPLICATE, 0)
|
||||||
val timeNowSeconds = System.currentTimeMillis() / 1000
|
val timeNowSeconds = System.currentTimeMillis() / 1000
|
||||||
if (billIdToDuplicate == 0L) {
|
if (billIdToDuplicate == 0L) {
|
||||||
|
val project = db.getProject(projectId)
|
||||||
bill = DBBill(
|
bill = DBBill(
|
||||||
0, 0, projectId, 0, 0.0, timeNowSeconds,
|
0, 0, projectId, project?.lastPayerId ?: 0, 0.0, timeNowSeconds,
|
||||||
"", DBBill.STATE_ADDED, DBBill.NON_REPEATED,
|
"", DBBill.STATE_ADDED, DBBill.NON_REPEATED,
|
||||||
DBBill.PAYMODE_NONE, DBBill.CATEGORY_NONE, "", DBBill.PAYMODE_ID_NONE
|
DBBill.PAYMODE_NONE, DBBill.CATEGORY_NONE, "", DBBill.PAYMODE_ID_NONE
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import androidx.compose.material.icons.filled.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.draw.scale
|
import androidx.compose.ui.draw.scale
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@@ -55,6 +57,13 @@ fun EditBillScreen(
|
|||||||
) {
|
) {
|
||||||
val canEdit = accessLevel == DBProject.ACCESS_LEVEL_UNKNOWN || accessLevel >= DBProject.ACCESS_LEVEL_PARTICIPANT
|
val canEdit = accessLevel == DBProject.ACCESS_LEVEL_UNKNOWN || accessLevel >= DBProject.ACCESS_LEVEL_PARTICIPANT
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
val focusRequester = remember { FocusRequester() }
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
if (viewModel.isNewBill) {
|
||||||
|
focusRequester.requestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StatefulAlertDialog(
|
StatefulAlertDialog(
|
||||||
state = viewModel.dialogState,
|
state = viewModel.dialogState,
|
||||||
@@ -130,7 +139,8 @@ fun EditBillScreen(
|
|||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
canEdit = canEdit,
|
canEdit = canEdit,
|
||||||
onDateClick = onDateClick,
|
onDateClick = onDateClick,
|
||||||
onTimeClick = onTimeClick
|
onTimeClick = onTimeClick,
|
||||||
|
amountFocusRequester = focusRequester
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
@@ -166,7 +176,8 @@ fun BillBasicInfoSection(
|
|||||||
viewModel: EditBillViewModel,
|
viewModel: EditBillViewModel,
|
||||||
canEdit: Boolean,
|
canEdit: Boolean,
|
||||||
onDateClick: () -> Unit,
|
onDateClick: () -> Unit,
|
||||||
onTimeClick: () -> Unit
|
onTimeClick: () -> Unit,
|
||||||
|
amountFocusRequester: FocusRequester
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "GENERAL",
|
text = "GENERAL",
|
||||||
@@ -180,17 +191,6 @@ fun BillBasicInfoSection(
|
|||||||
val currencyDialogTitle =
|
val currencyDialogTitle =
|
||||||
stringResource(R.string.currency_dialog_title, viewModel.mainCurrencyName)
|
stringResource(R.string.currency_dialog_title, viewModel.mainCurrencyName)
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = viewModel.what,
|
|
||||||
onValueChange = { viewModel.what = it },
|
|
||||||
enabled = canEdit,
|
|
||||||
placeholder = { Text(stringResource(R.string.label_what)) },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
leadingIcon = { Icon(Icons.Default.Title, contentDescription = null) }
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = viewModel.amount,
|
value = viewModel.amount,
|
||||||
onValueChange = { nv->
|
onValueChange = { nv->
|
||||||
@@ -200,7 +200,7 @@ fun BillBasicInfoSection(
|
|||||||
},
|
},
|
||||||
enabled = canEdit,
|
enabled = canEdit,
|
||||||
placeholder = { Text("0") },
|
placeholder = { Text("0") },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth().focusRequester(amountFocusRequester),
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
val currencyToShow = viewModel.selectedCurrencyName.ifEmpty {
|
val currencyToShow = viewModel.selectedCurrencyName.ifEmpty {
|
||||||
viewModel.mainCurrencyName.ifEmpty { "$" }
|
viewModel.mainCurrencyName.ifEmpty { "$" }
|
||||||
@@ -239,6 +239,17 @@ fun BillBasicInfoSection(
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = viewModel.what,
|
||||||
|
onValueChange = { viewModel.what = it },
|
||||||
|
enabled = canEdit,
|
||||||
|
placeholder = { Text(stringResource(R.string.label_what)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
leadingIcon = { Icon(Icons.Default.Title, contentDescription = null) }
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
val dateFormat =
|
val dateFormat =
|
||||||
remember(context) { android.text.format.DateFormat.getDateFormat(context) }
|
remember(context) { android.text.format.DateFormat.getDateFormat(context) }
|
||||||
val timeFormat =
|
val timeFormat =
|
||||||
|
|||||||
Reference in New Issue
Block a user