forked from omni/OmniCards
feat: added trimming card name functionality
This commit is contained in:
@@ -240,6 +240,8 @@ fun AddCard(innerPadding: PaddingValues, getDbFun: () -> DbHelper) {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
cardName = cardName.trim()
|
||||
|
||||
val err = checkCardData(cardName, codeValue)
|
||||
|
||||
if (err == null) {
|
||||
@@ -287,6 +289,8 @@ fun EditCard(cardInfo: CardInfo, innerPadding: PaddingValues, getDbFun: () -> Db
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = {
|
||||
cardName = cardName.trim()
|
||||
|
||||
val err = checkCardData(cardName, codeValue)
|
||||
|
||||
if (err == null) {
|
||||
|
||||
@@ -50,10 +50,12 @@ fun sendToWatch(context: Context, path: String, message: String, onResult: (Bool
|
||||
}
|
||||
|
||||
fun checkCardData(name: String, value: String): String? {
|
||||
if (name.trim().isEmpty()) {
|
||||
if (name.isEmpty()) {
|
||||
return "Name should not be empty"
|
||||
} else if (value.trim().isEmpty()) {
|
||||
} else if (value.isEmpty()) {
|
||||
return "Code value should not be empty"
|
||||
} else if (name.length > 32) {
|
||||
return "Name must be shorter than 32 symbols"
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user