Skip to content

Commit

Permalink
[Feature/#318] 도착한 보틀 리스트, 도착한 보틀 상세 화면 로딩 인디케이터 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
JongHoooon authored Nov 9, 2024
1 parent fb8a51a commit f02f768
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ public struct GoodFeelingFeature {

@ObservableState
public struct State: Equatable {
var isLoading: Bool

public init() {

self.isLoading = true
}
}

public enum Action: BindableAction {
case sentBottleTapped(url: String)
case webViewLoadingDidCompleted

case configureIsLoading(_: Bool)


case delegate(Delegate)
public enum Delegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ extension GoodFeelingFeature {
public init() {
let reducer = Reduce<State, Action> { state, action in
switch action {
case .webViewLoadingDidCompleted:
return .send(.configureIsLoading(false))

case let .sentBottleTapped(url):
return .send(.delegate(.sentBottleTapped(url: url)))

case let .configureIsLoading(isLoading):
state.isLoading = isLoading
return .none

default:
return .none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import FeatureBaseWebViewInterface

import CoreLoggerInterface

import SharedDesignSystem

import ComposableArchitecture

public struct GoodFeelingView: View {
Expand All @@ -27,7 +29,7 @@ public struct GoodFeelingView: View {
actionDidInputted: { action in
switch action {
case .webViewLoadingDidCompleted:
break
store.send(.webViewLoadingDidCompleted)

case let .openLink(url):
store.send(.sentBottleTapped(url: url))
Expand All @@ -37,6 +39,11 @@ public struct GoodFeelingView: View {
}
}
)
.overlay {
if store.isLoading {
LoadingIndicator()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ public struct SentBottleDetailFeature {

@ObservableState
public struct State: Equatable {
var isLoading: Bool
let sentBottleDetailURL: String

public init(sentBottleDetailURL: String) {
self.isLoading = true
self.sentBottleDetailURL = sentBottleDetailURL
}
}

public enum Action: BindableAction {
case webViewLoadingDidCompleted
case backButtonDidTapped
case bottelDidAccepted

case configureIsLoading(_: Bool)
case showToast(message: String)

case delegate(Delegate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ extension SentBottleDetailFeature {

let reducer = Reduce<State, Action> { state, action in
switch action {
case .webViewLoadingDidCompleted:
return .send(.configureIsLoading(false))

case .backButtonDidTapped:
return .send(.delegate(.backButtonDidTapped))

case let .showToast(message):
toastClient.presentToast(message: message)
return .none

case let .configureIsLoading(isLoading):
state.isLoading = isLoading
return .none

case .bottelDidAccepted:
return .send(.delegate(.bottelDidAccepted))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import FeatureBaseWebViewInterface

import CoreLoggerInterface

import SharedDesignSystem

import ComposableArchitecture

public struct SentBottleDetailView: View {
Expand All @@ -27,7 +29,7 @@ public struct SentBottleDetailView: View {
actionDidInputted: { action in
switch action {
case .webViewLoadingDidCompleted:
break
store.send(.webViewLoadingDidCompleted)

case .closeWebView:
store.send(.backButtonDidTapped)
Expand All @@ -45,6 +47,11 @@ public struct SentBottleDetailView: View {
)
.navigationBarBackButtonHidden()
.ignoresSafeArea(.all, edges: [.top, .bottom])
.overlay {
if store.isLoading {
LoadingIndicator()
}
}
}
}
}

0 comments on commit f02f768

Please sign in to comment.