diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeature.swift b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeature.swift index 62626ac2..937ad4c6 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeature.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeature.swift @@ -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 { diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeatureInterface.swift b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeatureInterface.swift index 79e8405b..d9c3acfe 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeatureInterface.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingFeatureInterface.swift @@ -13,9 +13,16 @@ extension GoodFeelingFeature { public init() { let reducer = Reduce { 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 } diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingView.swift b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingView.swift index a2647c83..401f0c86 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingView.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/GoodFeeling/GoodFeelingView.swift @@ -11,6 +11,8 @@ import FeatureBaseWebViewInterface import CoreLoggerInterface +import SharedDesignSystem + import ComposableArchitecture public struct GoodFeelingView: View { @@ -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)) @@ -37,6 +39,11 @@ public struct GoodFeelingView: View { } } ) + .overlay { + if store.isLoading { + LoadingIndicator() + } + } } } } diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeature.swift b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeature.swift index 5e2be585..8893aa67 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeature.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeature.swift @@ -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) diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeatureInterface.swift b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeatureInterface.swift index 3087fdd0..a34362d7 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeatureInterface.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailFeatureInterface.swift @@ -17,6 +17,9 @@ extension SentBottleDetailFeature { let reducer = Reduce { state, action in switch action { + case .webViewLoadingDidCompleted: + return .send(.configureIsLoading(false)) + case .backButtonDidTapped: return .send(.delegate(.backButtonDidTapped)) @@ -24,6 +27,10 @@ extension SentBottleDetailFeature { toastClient.presentToast(message: message) return .none + case let .configureIsLoading(isLoading): + state.isLoading = isLoading + return .none + case .bottelDidAccepted: return .send(.delegate(.bottelDidAccepted)) diff --git a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailView.swift b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailView.swift index a9966c48..49e059fd 100644 --- a/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailView.swift +++ b/Projects/Feature/GoodFeeling/Interface/Sources/SentBottleDetail/SentBottleDetailView.swift @@ -11,6 +11,8 @@ import FeatureBaseWebViewInterface import CoreLoggerInterface +import SharedDesignSystem + import ComposableArchitecture public struct SentBottleDetailView: View { @@ -27,7 +29,7 @@ public struct SentBottleDetailView: View { actionDidInputted: { action in switch action { case .webViewLoadingDidCompleted: - break + store.send(.webViewLoadingDidCompleted) case .closeWebView: store.send(.backButtonDidTapped) @@ -45,6 +47,11 @@ public struct SentBottleDetailView: View { ) .navigationBarBackButtonHidden() .ignoresSafeArea(.all, edges: [.top, .bottom]) + .overlay { + if store.isLoading { + LoadingIndicator() + } + } } } }