Skip to content

Commit

Permalink
* Don't save new note if nothing has been entered
Browse files Browse the repository at this point in the history
* Fix: Always show "add item" link
  • Loading branch information
Eboreg committed Nov 3, 2023
1 parent fbbe5da commit 465a353
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ android {
applicationId = "us.huseli.retain"
minSdk = 26
targetSdk = targetSdk
versionCode = 5
versionName = "1.0.0-beta.5"
versionCode = 6
versionName = "1.0.0-beta.6"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// buildConfigField("String", "dropboxAppKey", "\"${dropboxAppKey}\"")
Expand Down
6 changes: 3 additions & 3 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "1.0.0-beta.5",
"outputFile": "retain_1.0.0-beta.5-release.apk"
"versionCode": 6,
"versionName": "1.0.0-beta.6",
"outputFile": "retain_1.0.0-beta.6-release.apk"
}
],
"elementType": "File"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,28 @@ fun LazyListScope.ChecklistNoteChecklist(
}
} else item { Spacer(Modifier.height(4.dp)) }

item {
// "Add item" link:
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable(onClick = onAddItemClick)
.padding(vertical = 8.dp)
.fillMaxWidth()
) {
Icon(
imageVector = Icons.Sharp.Add,
contentDescription = null,
modifier = Modifier.padding(horizontal = 12.dp),
tint = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
)
Text(
text = stringResource(R.string.add_item),
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
modifier = Modifier.padding(horizontal = 6.dp)
)
}
}

item {
// "Add item" link:
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable(onClick = onAddItemClick)
.padding(vertical = 8.dp)
.fillMaxWidth()
) {
Icon(
imageVector = Icons.Sharp.Add,
contentDescription = null,
modifier = Modifier.padding(horizontal = 12.dp),
tint = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
)
Text(
text = stringResource(R.string.add_item),
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
modifier = Modifier.padding(horizontal = 6.dp)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fun NoteScreen(
NoteScreenTopAppBar(
backgroundColor = appBarColor,
onBackClick = {
viewModel.save()
if (isUnsaved) viewModel.save()
onBackClick()
},
onImagePick = { uri -> viewModel.insertImage(uri) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NoteViewModel @Inject constructor(
private val _checklistItems = MutableStateFlow<List<ChecklistItem>>(emptyList())
private val _selectedImages = MutableStateFlow<Set<String>>(emptySet())
private val _focusedChecklistItemId = MutableStateFlow<UUID?>(null)
private val _isUnsaved = MutableStateFlow(true)
private val _isUnsaved = MutableStateFlow(false)
private val _checklistItemUndoState = MutableStateFlow<List<ChecklistItem>?>(null)
private val _imageUndoState = MutableStateFlow<List<Image>?>(null)

Expand Down

0 comments on commit 465a353

Please sign in to comment.