redesign iOS round into fullscreen swipe flow
This commit is contained in:
@@ -12,43 +12,67 @@ struct HermesApp: App {
|
||||
@StateObject private var analytics = HermesAnalyticsClient()
|
||||
@StateObject private var playerCoordinator = PlayerCoordinator()
|
||||
@State private var isBootstrapping = false
|
||||
@State private var appMode: HermesAppMode = .demo
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
RootView(onStartSession: { localeCode in
|
||||
if repository.currentSession != nil, repository.currentRound != nil {
|
||||
return
|
||||
}
|
||||
|
||||
guard !isBootstrapping else {
|
||||
return
|
||||
}
|
||||
|
||||
isBootstrapping = true
|
||||
let request = HermesSessionStartRequest(
|
||||
localeCode: localeCode,
|
||||
devicePlatform: "ios",
|
||||
deviceModel: UIDevice.current.model,
|
||||
osVersion: UIDevice.current.systemVersion,
|
||||
appVersion: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.1.0"
|
||||
)
|
||||
|
||||
analytics.track("session_start_requested", attributes: ["screen_name": "session", "locale_code": localeCode])
|
||||
|
||||
Task { @MainActor in
|
||||
defer {
|
||||
isBootstrapping = false
|
||||
RootView(
|
||||
mode: appMode,
|
||||
onModeSelected: { selectedMode in
|
||||
guard appMode != selectedMode else {
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
_ = try await repository.bootstrap(request)
|
||||
analytics.track("session_started", attributes: ["screen_name": "session", "locale_code": localeCode])
|
||||
await analytics.flush(using: repository)
|
||||
} catch {
|
||||
analytics.track("session_start_failed", attributes: ["screen_name": "session", "locale_code": localeCode])
|
||||
appMode = selectedMode
|
||||
repository.reset()
|
||||
},
|
||||
onStartSession: { localeCode, selectedMode in
|
||||
if selectedMode == .demo {
|
||||
Task { @MainActor in
|
||||
repository.reset()
|
||||
await repository.bootstrapMock(
|
||||
localeCode: localeCode,
|
||||
appVersion: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.1.0"
|
||||
)
|
||||
analytics.track("session_started", attributes: ["screen_name": "session", "locale_code": localeCode, "mode": selectedMode.rawValue])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if repository.currentSession != nil, repository.currentRound != nil {
|
||||
return
|
||||
}
|
||||
|
||||
guard !isBootstrapping else {
|
||||
return
|
||||
}
|
||||
|
||||
isBootstrapping = true
|
||||
let request = HermesSessionStartRequest(
|
||||
localeCode: localeCode,
|
||||
devicePlatform: "ios",
|
||||
deviceModel: UIDevice.current.model,
|
||||
osVersion: UIDevice.current.systemVersion,
|
||||
appVersion: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.1.0"
|
||||
)
|
||||
|
||||
analytics.track("session_start_requested", attributes: ["screen_name": "session", "locale_code": localeCode, "mode": selectedMode.rawValue])
|
||||
|
||||
Task { @MainActor in
|
||||
defer {
|
||||
isBootstrapping = false
|
||||
}
|
||||
|
||||
do {
|
||||
_ = try await repository.bootstrap(request)
|
||||
analytics.track("session_started", attributes: ["screen_name": "session", "locale_code": localeCode, "mode": selectedMode.rawValue])
|
||||
await analytics.flush(using: repository)
|
||||
} catch {
|
||||
analytics.track("session_start_failed", attributes: ["screen_name": "session", "locale_code": localeCode, "mode": selectedMode.rawValue])
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
.preferredColorScheme(.dark)
|
||||
.tint(HermesTheme.accent)
|
||||
.environmentObject(analytics)
|
||||
|
||||
Reference in New Issue
Block a user