File tree Expand file tree Collapse file tree
core/common/src/main/java/com/moneymong/moneymong/common/ui
feature/ocr/src/main/java/com/moneymong/moneymong/ocr Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,10 +12,14 @@ fun String.toWonFormat(unit: Boolean = false): String {
1212 return if (this .isEmpty()) {
1313 this
1414 } else {
15- if (unit) {
16- " ${DecimalFormat (" #,###" ).format(this .toLong())} 원"
17- } else {
18- DecimalFormat (" #,###" ).format(this .toLong())
15+ try {
16+ if (unit) {
17+ " ${DecimalFormat (" #,###" ).format(this .toLong())} 원"
18+ } else {
19+ DecimalFormat (" #,###" ).format(this .toLong())
20+ }
21+ } catch (e: Exception ) {
22+ " "
1923 }
2024 }
2125}
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import com.moneymong.moneymong.design_system.theme.White
3636import com.moneymong.moneymong.common.ext.hasPermission
3737import com.moneymong.moneymong.common.ui.noRippleClickable
3838import com.moneymong.moneymong.common.util.DisposableEffectWithLifeCycle
39+ import com.moneymong.moneymong.design_system.error.ErrorDialog
3940import com.moneymong.moneymong.design_system.theme.Black
4041import com.moneymong.moneymong.ocr.view.OCRCameraPermissionDeniedView
4142import com.moneymong.moneymong.ocr.view.OCRCaptureView
@@ -105,6 +106,12 @@ fun OCRScreen(
105106 )
106107 }
107108
109+ if (state.visibleErrorDialog) {
110+ ErrorDialog (message = state.errorMessage) {
111+ viewModel.onChangeVisibleErrorDialog(false )
112+ }
113+ }
114+
108115 Scaffold {
109116 Box (
110117 modifier = modifier
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ data class OCRState(
1010 val permissionDialogStatus : Boolean = false ,
1111 val isDeniedCamera : Boolean = false ,
1212 val visibleHelper : Boolean = true ,
13- val isLoading : Boolean = false
13+ val isLoading : Boolean = false ,
14+ val visibleErrorDialog : Boolean = false ,
15+ val errorMessage : String = " "
1416): State {
1517
1618 val isReceipt: Boolean
Original file line number Diff line number Diff line change @@ -49,6 +49,13 @@ class OCRViewModel @Inject constructor(
4949 .onSuccess {
5050 reduce { state.copy(document = it) }
5151 possibleNavigateToOCRResult(it.images.first().inferResult.orEmpty())
52+ }.onFailure {
53+ reduce {
54+ state.copy(
55+ visibleErrorDialog = true ,
56+ errorMessage = " 영수증을 인식하지 못했습니다."
57+ )
58+ }
5259 }.also { reduce { state.copy(isLoading = false ) } }
5360 }
5461 }
@@ -110,4 +117,8 @@ class OCRViewModel @Inject constructor(
110117 fun onClickHelper () = intent {
111118 reduce { state.copy(visibleHelper = ! state.visibleHelper) }
112119 }
120+
121+ fun onChangeVisibleErrorDialog (visible : Boolean ) = intent {
122+ reduce { state.copy(visibleErrorDialog = visible) }
123+ }
113124}
You can’t perform that action at this time.
0 commit comments