From a6c5e450a26898f77ae68ac2a7dc01914fcc8354 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 30 May 2023 15:00:57 +0800 Subject: [PATCH] Implement saving highlight notes with the new edit note view --- .../ui/reader/WebReaderLoadingContainer.kt | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/reader/WebReaderLoadingContainer.kt b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/reader/WebReaderLoadingContainer.kt index c820b1447..b5f63643a 100644 --- a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/reader/WebReaderLoadingContainer.kt +++ b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/reader/WebReaderLoadingContainer.kt @@ -152,7 +152,7 @@ fun WebReaderLoadingContainer(slug: String? = null, requestID: String? = null, val modalBottomSheetState = rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Hidden, - skipHalfExpanded = bottomSheetState == BottomSheetState.EDITNOTE, + skipHalfExpanded = bottomSheetState == BottomSheetState.EDITNOTE || bottomSheetState == BottomSheetState.HIGHLIGHTNOTE, confirmValueChange = { if (it == ModalBottomSheetValue.Hidden) { webReaderViewModel.resetBottomSheet() @@ -234,25 +234,18 @@ fun WebReaderLoadingContainer(slug: String? = null, requestID: String? = null, } } BottomSheetState.HIGHLIGHTNOTE -> { - webReaderViewModel.annotation?.let { annotation -> - BottomSheetUI(title = "Edit Note") { - AnnotationEditView( - initialAnnotation = annotation, - onSave = { - webReaderViewModel.saveAnnotation(it) - coroutineScope.launch { - webReaderViewModel.resetBottomSheet() - } - }, - onCancel = { - webReaderViewModel.cancelAnnotationEdit() - coroutineScope.launch { - webReaderViewModel.resetBottomSheet() - } + EditNoteModal( + initialValue = webReaderViewModel.annotation, + onDismiss = { save, note -> + coroutineScope.launch { + if (save) { + webReaderViewModel.saveAnnotation(note ?: "") } - ) + webReaderViewModel.annotation = null + } + webReaderViewModel.resetBottomSheet() } - } + ) } BottomSheetState.LABELS -> { BottomSheetUI(title = "Notebook") {