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