-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
Packages/GodPackage/Sources/OnboardFeature/InvitationCode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import AnalyticsClient | ||
import ComposableArchitecture | ||
import SwiftUI | ||
|
||
@Reducer | ||
public struct InvitationCodeLogic { | ||
public init() {} | ||
|
||
public struct State: Equatable { | ||
public init() {} | ||
} | ||
|
||
public enum Action: Equatable { | ||
case onTask | ||
case onAppear | ||
} | ||
|
||
@Dependency(\.analytics) var analytics | ||
|
||
public var body: some Reducer<State, Action> { | ||
Reduce<State, Action> { _, action in | ||
switch action { | ||
case .onTask: | ||
return .none | ||
|
||
case .onAppear: | ||
analytics.logScreen(screenName: "InvitationCode", of: self) | ||
return .none | ||
} | ||
} | ||
} | ||
} | ||
|
||
public struct InvitationCodeView: View { | ||
let store: StoreOf<InvitationCodeLogic> | ||
|
||
public init(store: StoreOf<InvitationCodeLogic>) { | ||
self.store = store | ||
} | ||
|
||
public var body: some View { | ||
WithViewStore(store, observe: { $0 }) { viewStore in | ||
List { | ||
Text("InvitationCode", bundle: .module) | ||
} | ||
.navigationTitle("InvitationCode") | ||
.navigationBarTitleDisplayMode(.inline) | ||
.task { await store.send(.onTask).finish() } | ||
.onAppear { store.send(.onAppear) } | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
InvitationCodeView( | ||
store: .init( | ||
initialState: InvitationCodeLogic.State(), | ||
reducer: { InvitationCodeLogic() } | ||
) | ||
) | ||
} |