Skip to content

Commit

Permalink
[fix] Save button in AddScreen now requires processing completion bef…
Browse files Browse the repository at this point in the history
…ore re-clicking
  • Loading branch information
SkyD666 committed Apr 5, 2024
1 parent 472a642 commit 5a927fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
minSdk = 24
targetSdk = 34
versionCode = 62
versionName = "2.2-alpha07"
versionName = "2.2-alpha08"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/skyd/rays/ui/screen/add/AddScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ fun AddScreen(
var stickerCreateTime by rememberSaveable { mutableLongStateOf(System.currentTimeMillis()) }
var openMoreMenu by rememberSaveable { mutableStateOf(false) }
var openErrorDialog by rememberSaveable { mutableStateOf<String?>(null) }
var saveButtonEnable by rememberSaveable { mutableStateOf(true) }
val uiState by viewModel.viewState.collectAsStateWithLifecycle()
val uiEvent by viewModel.singleEvent.collectAsStateWithLifecycle(initialValue = null)

Expand Down Expand Up @@ -220,6 +221,7 @@ fun AddScreen(
message = context.getString(R.string.add_screen_sticker_is_not_set),
)
} else {
saveButtonEnable = false
keyboardController?.hide()
focusManager.clearFocus()
val getStickersWithTagsState = uiState.getStickersWithTagsState
Expand Down Expand Up @@ -252,6 +254,7 @@ fun AddScreen(
)
}
},
enabled = saveButtonEnable && !uiState.loadingDialog,
contentDescription = stringResource(R.string.add_screen_save_current_sticker),
imageVector = Icons.Default.Save,
)
Expand Down Expand Up @@ -338,18 +341,21 @@ fun AddScreen(

when (val event = uiEvent) {
is AddEvent.AddStickersResultEvent.Duplicate -> LaunchedEffect(event) {
saveButtonEnable = true
openDuplicateDialog = true
onGetStickersWithTagsStateChanged()
}

is AddEvent.AddStickersResultEvent.Failed -> {
saveButtonEnable = true
snackbarHostState.showSnackbarWithLaunchedEffect(
message = context.getString(R.string.failed_info, event.msg),
key1 = event,
)
}

is AddEvent.AddStickersResultEvent.Success -> LaunchedEffect(event) {
saveButtonEnable = true
resetStickerData()
processNext()
}
Expand Down

0 comments on commit 5a927fb

Please sign in to comment.