@@ -45,6 +45,7 @@ import com.moneymong.moneymong.design_system.component.button.MDSFloatingActionB
4545import com.moneymong.moneymong.design_system.component.snackbar.MDSSnackbarHost
4646import com.moneymong.moneymong.design_system.component.tooltip.MDSToolTip
4747import com.moneymong.moneymong.design_system.component.tooltip.MDSToolTipPosition
48+ import com.moneymong.moneymong.design_system.error.ErrorDialog
4849import com.moneymong.moneymong.design_system.error.ErrorScreen
4950import com.moneymong.moneymong.design_system.loading.LoadingScreen
5051import com.moneymong.moneymong.design_system.theme.Mint02
@@ -147,182 +148,183 @@ fun LedgerScreen(
147148 }
148149
149150 if (state.visibleError) {
150- ErrorScreen (
151- modifier = Modifier .fillMaxSize(),
152- message = " 문제가 발생했습니다\n 다시 시도해주세요" ,
153- onRetry = { viewModel.eventEmit(LedgerSideEffect .LedgerFetchRetry ) })
154- } else {
155- Scaffold (
156- topBar = {
157- LedgerTopbarView (
158- modifier = Modifier .background(White ),
159- header = state.currentAgency?.name ? : " 장부" ,
160- icon = R .drawable.ic_chevron_bottom,
161- visibleArrow = state.agencyList.isNotEmpty(),
162- onClickDownArrow = { viewModel.eventEmit(LedgerSideEffect .LedgerOpenSheet ) }
163- )
164- },
165- snackbarHost = {
166- MDSSnackbarHost (
167- modifier = Modifier .padding(
168- start = 20 .dp,
169- bottom = 12 .dp + padding.calculateBottomPadding(),
170- end = 20 .dp
171- ),
172- hostState = snackbarHostState
173- )
174- }
151+ ErrorDialog (
152+ message = state.errorMessage
175153 ) {
176- if (state.showBottomSheet) {
177- MDSBottomSheet (
178- sheetState = sheetState,
179- onDismissRequest = { viewModel.eventEmit(LedgerSideEffect .LedgerCloseSheet ) },
180- content = {
181- LedgerAgencySelectBottomSheet (
182- currentAgencyId = state.agencyId,
183- agencyList = state.agencyList,
184- onClickItem = {
185- viewModel.eventEmit(
186- LedgerSideEffect .LedgerSelectedAgencyChange (
187- it
188- )
154+ viewModel.onChangeVisibleErrorDialog(false )
155+ }
156+ }
157+
158+ Scaffold (
159+ topBar = {
160+ LedgerTopbarView (
161+ modifier = Modifier .background(White ),
162+ header = state.currentAgency?.name ? : " 장부" ,
163+ icon = R .drawable.ic_chevron_bottom,
164+ visibleArrow = state.agencyList.isNotEmpty(),
165+ onClickDownArrow = { viewModel.eventEmit(LedgerSideEffect .LedgerOpenSheet ) }
166+ )
167+ },
168+ snackbarHost = {
169+ MDSSnackbarHost (
170+ modifier = Modifier .padding(
171+ start = 20 .dp,
172+ bottom = 12 .dp + padding.calculateBottomPadding(),
173+ end = 20 .dp
174+ ),
175+ hostState = snackbarHostState
176+ )
177+ }
178+ ) {
179+ if (state.showBottomSheet) {
180+ MDSBottomSheet (
181+ sheetState = sheetState,
182+ onDismissRequest = { viewModel.eventEmit(LedgerSideEffect .LedgerCloseSheet ) },
183+ content = {
184+ LedgerAgencySelectBottomSheet (
185+ currentAgencyId = state.agencyId,
186+ agencyList = state.agencyList,
187+ onClickItem = {
188+ viewModel.eventEmit(
189+ LedgerSideEffect .LedgerSelectedAgencyChange (
190+ it
189191 )
190- }
191- )
192- }
193- )
194- }
195- Column (
196- modifier = Modifier
197- .fillMaxSize()
198- .padding(it + padding)
199- ) {
200- if (! state.existAgency) {
201- LedgerAgencyEmptyView (onClickFindAgency = navigateToAgency)
202- } else {
203- LedgerTabRowView (
204- tabs = tabs,
205- selectedTabIndex = pagerState.currentPage,
206- onScrollToPage = {
207- coroutineScope.launch { pagerState.animateScrollToPage(it) }
192+ )
208193 }
209194 )
210- HorizontalPager (state = pagerState) { index ->
211- if (tabs[index] == LedgerTab .Ledger ) {
212- Box (modifier = modifier.fillMaxSize()) {
213- if (state.isExistLedger) { // 소속에 장부가 존재한다면
214- LedgerDefaultView (
215- totalBalance = state.ledgerTransaction?.totalBalance
216- ? : 0 ,
217- ledgerDetails = state.filterTransactionList,
218- transactionType = state.transactionType,
219- currentDate = state.currentDate,
220- hasTransaction = state.hasTransaction,
221- isLoading = state.isLoading,
222- onChangeTransactionType = viewModel::onChangeTransactionType,
223- onAddMonthFromCurrentDate = viewModel::onAddMonthFromCurrentDate,
224- onClickTransactionItem = {
225- viewModel.eventEmit(
226- LedgerSideEffect .LedgerNavigateToLedgerDetail (
227- it
228- )
195+ }
196+ )
197+ }
198+ Column (
199+ modifier = Modifier
200+ .fillMaxSize()
201+ .padding(it + padding)
202+ ) {
203+ if (! state.existAgency) {
204+ LedgerAgencyEmptyView (onClickFindAgency = navigateToAgency)
205+ } else {
206+ LedgerTabRowView (
207+ tabs = tabs,
208+ selectedTabIndex = pagerState.currentPage,
209+ onScrollToPage = {
210+ coroutineScope.launch { pagerState.animateScrollToPage(it) }
211+ }
212+ )
213+ HorizontalPager (state = pagerState) { index ->
214+ if (tabs[index] == LedgerTab .Ledger ) {
215+ Box (modifier = modifier.fillMaxSize()) {
216+ if (state.isExistLedger) { // 소속에 장부가 존재한다면
217+ LedgerDefaultView (
218+ totalBalance = state.ledgerTransaction?.totalBalance
219+ ? : 0 ,
220+ ledgerDetails = state.filterTransactionList,
221+ transactionType = state.transactionType,
222+ currentDate = state.currentDate,
223+ hasTransaction = state.hasTransaction,
224+ isLoading = state.isLoading,
225+ onChangeTransactionType = viewModel::onChangeTransactionType,
226+ onAddMonthFromCurrentDate = viewModel::onAddMonthFromCurrentDate,
227+ onClickTransactionItem = {
228+ viewModel.eventEmit(
229+ LedgerSideEffect .LedgerNavigateToLedgerDetail (
230+ it
229231 )
230- }
231- )
232+ )
233+ }
234+ )
235+ } else {
236+ if (state.isLoading) {
237+ LoadingScreen (modifier = Modifier .fillMaxSize())
232238 } else {
233- if (state.isLoading ) {
234- LoadingScreen (modifier = Modifier .fillMaxSize() )
239+ if (state.isStaff ) {
240+ LedgerStaffEmptyView ( )
235241 } else {
236- if (state.isStaff) {
237- LedgerStaffEmptyView ()
238- } else {
239- LedgerMemberEmptyView ()
240- }
242+ LedgerMemberEmptyView ()
241243 }
242244 }
243- if (state.isStaff) {
244- Column (
245- modifier = Modifier
246- .align(Alignment .BottomEnd )
247- .padding(end = 20 .dp, bottom = 20 .dp),
248- horizontalAlignment = Alignment .End
249- ) {
250- if (! state.isExistLedger && ! expandableFab) {
251- MDSToolTip (
252- text = " 해당 기능을 사용해보세요" ,
253- position = MDSToolTipPosition .Right
254- )
255- Spacer (modifier = Modifier .height(8 .dp))
256- }
257- AnimatedVisibility (
258- visible = expandableFab,
259- enter = slideInVertically(
260- initialOffsetY = { fullHeight -> fullHeight },
261- animationSpec = tween(
262- durationMillis = 250 ,
263- easing = LinearOutSlowInEasing
264- )
265- ),
266- exit = slideOutVertically(
267- targetOffsetY = { fullHeight -> fullHeight },
268- animationSpec = tween(
269- durationMillis = 150 ,
270- easing = FastOutLinearInEasing
271- )
245+ }
246+ if (state.isStaff) {
247+ Column (
248+ modifier = Modifier
249+ .align(Alignment .BottomEnd )
250+ .padding(end = 20 .dp, bottom = 20 .dp),
251+ horizontalAlignment = Alignment .End
252+ ) {
253+ if (! state.isExistLedger && ! expandableFab) {
254+ MDSToolTip (
255+ text = " 해당 기능을 사용해보세요" ,
256+ position = MDSToolTipPosition .Right
257+ )
258+ Spacer (modifier = Modifier .height(8 .dp))
259+ }
260+ AnimatedVisibility (
261+ visible = expandableFab,
262+ enter = slideInVertically(
263+ initialOffsetY = { fullHeight -> fullHeight },
264+ animationSpec = tween(
265+ durationMillis = 250 ,
266+ easing = LinearOutSlowInEasing
272267 )
273- ) {
274- MDSFloatingActionButton (
275- iconResource = R .drawable.ic_scan,
276- iconSize = FABIconSize (
277- width = 30 .dp,
278- height = 24 .dp
279- ),
280- containerColor = Mint03 ,
281- onClick = { viewModel.eventEmit(LedgerSideEffect .LedgerNavigateToOCR ) }
268+ ),
269+ exit = slideOutVertically(
270+ targetOffsetY = { fullHeight -> fullHeight },
271+ animationSpec = tween(
272+ durationMillis = 150 ,
273+ easing = FastOutLinearInEasing
282274 )
283- }
284- if (expandableFab) Spacer (modifier = Modifier .height(10 .dp))
285- AnimatedVisibility (
286- visible = expandableFab,
287- enter = slideInVertically(
288- initialOffsetY = { fullHeight -> fullHeight },
289- animationSpec = tween(
290- durationMillis = 150 ,
291- easing = LinearOutSlowInEasing
292- )
275+ )
276+ ) {
277+ MDSFloatingActionButton (
278+ iconResource = R .drawable.ic_scan,
279+ iconSize = FABIconSize (
280+ width = 30 .dp,
281+ height = 24 .dp
293282 ),
294- exit = slideOutVertically(
295- targetOffsetY = { fullHeight -> fullHeight },
296- animationSpec = tween(
297- durationMillis = 250 ,
298- easing = FastOutLinearInEasing
299- )
283+ containerColor = Mint03 ,
284+ onClick = { viewModel.eventEmit(LedgerSideEffect .LedgerNavigateToOCR ) }
285+ )
286+ }
287+ if (expandableFab) Spacer (modifier = Modifier .height(10 .dp))
288+ AnimatedVisibility (
289+ visible = expandableFab,
290+ enter = slideInVertically(
291+ initialOffsetY = { fullHeight -> fullHeight },
292+ animationSpec = tween(
293+ durationMillis = 150 ,
294+ easing = LinearOutSlowInEasing
300295 )
301- ) {
302- MDSFloatingActionButton (
303- iconResource = R .drawable.ic_pencil,
304- containerColor = Mint03 ,
305- onClick = { viewModel.eventEmit(LedgerSideEffect .LedgerNavigateToLedgerManual ) }
296+ ),
297+ exit = slideOutVertically(
298+ targetOffsetY = { fullHeight -> fullHeight },
299+ animationSpec = tween(
300+ durationMillis = 250 ,
301+ easing = FastOutLinearInEasing
306302 )
307- }
308- if (expandableFab) Spacer (modifier = Modifier .height(10 .dp))
309- val containerColor =
310- if (expandableFab) Mint02 else Mint03
303+ )
304+ ) {
311305 MDSFloatingActionButton (
312- modifier = Modifier .rotate(rotationAngle),
313- iconResource = R .drawable.ic_plus_default,
314- containerColor = containerColor,
315- onClick = {
316- expandableFab = ! expandableFab
317- }
306+ iconResource = R .drawable.ic_pencil,
307+ containerColor = Mint03 ,
308+ onClick = { viewModel.eventEmit(LedgerSideEffect .LedgerNavigateToLedgerManual ) }
318309 )
319310 }
311+ if (expandableFab) Spacer (modifier = Modifier .height(10 .dp))
312+ val containerColor =
313+ if (expandableFab) Mint02 else Mint03
314+ MDSFloatingActionButton (
315+ modifier = Modifier .rotate(rotationAngle),
316+ iconResource = R .drawable.ic_plus_default,
317+ containerColor = containerColor,
318+ onClick = {
319+ expandableFab = ! expandableFab
320+ }
321+ )
320322 }
321323 }
322- } else {
323- Box (modifier = modifier.fillMaxSize()) {
324- MemberScreen (agencyId = state.agencyId)
325- }
324+ }
325+ } else {
326+ Box (modifier = modifier.fillMaxSize()) {
327+ MemberScreen (agencyId = state.agencyId)
326328 }
327329 }
328330 }
0 commit comments