Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Application/DevLogApp/Sources/App/DevLogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct DevLogApp: App {
networkConnectivityUseCase: container.resolve(ObserveNetworkConnectivityUseCase.self),
systemThemeUseCase: container.resolve(ObserveSystemThemeUseCase.self),
trackAnalyticsEventUseCase: container.resolve(TrackAnalyticsEventUseCase.self),
signInUseCase: container.resolve(SignInUseCase.self),
widgetURLTab: { MainTab(widgetURL: $0) },
Comment thread
opficdev marked this conversation as resolved.
windowEvent: windowEvent,
pushNotificationTodoIdPublisher: PushNotificationRoute.shared.observe(),
Expand Down
17 changes: 10 additions & 7 deletions Application/DevLogPresentation/Sources/Login/LoginFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ struct LoginFeature {
var alertMessage = ""
}

enum Action {
case setAlert(Bool, AlertType? = nil)
enum Action: BindableAction {
case binding(BindingAction<State>)
case tapSignInButton(AuthProvider)
case signInSucceeded
case signInFailed(AlertType)
case signInCancelled
}
Comment thread
opficdev marked this conversation as resolved.
Outdated
Expand All @@ -36,16 +35,20 @@ struct LoginFeature {
@Dependency(SignInUseCaseDependency.self) var signInUseCase

var body: some ReducerOf<Self> {
BindingReducer()
Reduce { state, action in
switch action {
case .setAlert(let isPresented, let alertType):
setAlert(&state, isPresented: isPresented, alertType: alertType)
case .binding(\.showAlert):
if !state.showAlert {
setAlert(&state, isPresented: false, alertType: nil)
}
case .binding: // 다른 binding 액션들은 이쪽으로 처리됨
break // 작성 필수
case .tapSignInButton(let provider):
state.isLoading = true
return .run { [signInUseCase] send in
do {
try await signInUseCase.execute(provider)
await send(.signInSucceeded)
} catch {
if error.isSocialLoginCancelled {
await send(.signInCancelled)
Expand All @@ -54,7 +57,7 @@ struct LoginFeature {
await send(.signInFailed(alertType(for: error)))
}
}
case .signInSucceeded, .signInCancelled:
case .signInCancelled:
state.isLoading = false
case .signInFailed(let alertType):
state.isLoading = false
Expand Down
18 changes: 13 additions & 5 deletions Application/DevLogPresentation/Sources/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@

import SwiftUI
import ComposableArchitecture
import DevLogDomain

struct LoginView: View {
@Environment(\.colorScheme) var colorScheme
@Environment(\.sceneWidth) var sceneWidth
let store: StoreOf<LoginFeature>
@State private var store: StoreOf<LoginFeature>

init(signInUseCase: SignInUseCase) {
self._store = State(initialValue: Store(
initialState: LoginFeature.State()
) {
LoginFeature()
} withDependencies: {
$0.signInUseCase = .live(signInUseCase)
})
}

var body: some View {
ZStack {
Expand Down Expand Up @@ -46,10 +57,7 @@ struct LoginView: View {
LoadingView()
}
}
.alert(store.alertTitle, isPresented: Binding(
get: { store.showAlert },
set: { store.send(.setAlert($0)) }
)) {
.alert(store.alertTitle, isPresented: $store.showAlert) {
Button(String(localized: "common_close"), role: .cancel) { }
} message: {
Text(store.alertMessage)
Expand Down
11 changes: 1 addition & 10 deletions Application/DevLogPresentation/Sources/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public struct RootView: View {
@State var viewModel: RootViewModel
@State private var selectedRoute: Route?
@State private var selectedMainTab = MainTab.home
private let loginStore: StoreOf<LoginFeature>
private let widgetURLTab: (URL) -> MainTab?
Comment thread
opficdev marked this conversation as resolved.
private let windowEvent: TodoEditorWindowEvent
private let pushNotificationTodoIdPublisher: AnyPublisher<String, Never>
Expand All @@ -27,7 +26,6 @@ public struct RootView: View {
networkConnectivityUseCase: ObserveNetworkConnectivityUseCase,
systemThemeUseCase: ObserveSystemThemeUseCase,
trackAnalyticsEventUseCase: TrackAnalyticsEventUseCase,
signInUseCase: SignInUseCase,
widgetURLTab: @escaping (URL) -> MainTab?,
Comment thread
opficdev marked this conversation as resolved.
windowEvent: TodoEditorWindowEvent,
pushNotificationTodoIdPublisher: AnyPublisher<String, Never>,
Expand All @@ -39,13 +37,6 @@ public struct RootView: View {
systemThemeUseCase: systemThemeUseCase,
trackAnalyticsEventUseCase: trackAnalyticsEventUseCase
))
self.loginStore = Store(
initialState: LoginFeature.State()
) {
LoginFeature()
} withDependencies: {
$0.signInUseCase = .live(signInUseCase)
}
self.widgetURLTab = widgetURLTab
Comment thread
opficdev marked this conversation as resolved.
self.windowEvent = windowEvent
self.pushNotificationTodoIdPublisher = pushNotificationTodoIdPublisher
Expand All @@ -63,7 +54,7 @@ public struct RootView: View {
selectedTab: $selectedMainTab
)
} else {
LoginView(store: loginStore)
LoginView(signInUseCase: container.resolve(SignInUseCase.self))
}
Comment thread
opficdev marked this conversation as resolved.
}
}
Expand Down
Loading