Limit name input lines
This commit is contained in:
parent
8fc52e576d
commit
71f0c257d2
@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
@ -53,8 +55,8 @@ fun AddCategory(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
label = { Text("Category Name") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||
maxLines = 3,
|
||||
)
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
|
@ -6,6 +6,8 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material3.AlertDialog
|
||||
@ -106,9 +108,9 @@ fun EditCategory(
|
||||
OutlinedTextField(
|
||||
value = category.categoryName,
|
||||
onValueChange = { editCategoryViewModel.updateCategory(category.copy(categoryName = it)) },
|
||||
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||
maxLines = 3,
|
||||
label = { Text("Category Name") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
)
|
||||
|
||||
ExposedDropdownMenuBox(
|
||||
|
@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material3.AlertDialog
|
||||
@ -97,9 +99,9 @@ fun Add(
|
||||
OutlinedTextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
maxLines = 3,
|
||||
label = { Text("Name") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
|
||||
)
|
||||
|
||||
// Toggle between Income and Expense
|
||||
@ -108,7 +110,7 @@ fun Add(
|
||||
OutlinedTextField(
|
||||
value = spending,
|
||||
onValueChange = {
|
||||
val isValidSpending = it.matches(Regex("^-?\\d*(\\.\\d{0,2})?$"))
|
||||
val isValidSpending = it.matches(Regex("^-?(\\d{0,7})(\\.\\d{0,2})?$"))
|
||||
if (isValidSpending) {
|
||||
spending = it
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
@ -72,9 +74,11 @@ fun Edit(
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = entry.name,
|
||||
maxLines = 3,
|
||||
|
||||
onValueChange = { editViewModel.updateEntry(entry.copy(name = it)) },
|
||||
label = { Text("Name") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState())
|
||||
)
|
||||
|
||||
// Toggle between Income and Expense
|
||||
@ -83,7 +87,7 @@ fun Edit(
|
||||
OutlinedTextField(
|
||||
value = entry.amount.toString(),
|
||||
onValueChange = {
|
||||
val isValidSpending = it.matches(Regex("^-?\\d*(\\.\\d{0,2})?$"))
|
||||
val isValidSpending = it.matches(Regex("^-?(\\d{0,7})(\\.\\d{0,2})?$"))
|
||||
if (isValidSpending) {
|
||||
val amount = if (isIncome) it.toFloat() else -it.toFloat()
|
||||
editViewModel.updateEntry(entry.copy(amount = amount))
|
||||
|
Loading…
Reference in New Issue
Block a user