summaryrefslogtreecommitdiff
path: root/makima/ios/Sources/Makima/App
diff options
context:
space:
mode:
Diffstat (limited to 'makima/ios/Sources/Makima/App')
-rw-r--r--makima/ios/Sources/Makima/App/AppState.swift11
-rw-r--r--makima/ios/Sources/Makima/App/ScreenshotMode.swift21
2 files changed, 29 insertions, 3 deletions
diff --git a/makima/ios/Sources/Makima/App/AppState.swift b/makima/ios/Sources/Makima/App/AppState.swift
index 806d7d0..1cc6788 100644
--- a/makima/ios/Sources/Makima/App/AppState.swift
+++ b/makima/ios/Sources/Makima/App/AppState.swift
@@ -7,16 +7,21 @@ final class AppState {
let auth: AuthStore
var wsStatus: WebSocketStatus = .idle
var webSocket: TaskWebSocket?
-
- /// Pending deep-link to open once the app has finished routing.
var pendingDeepLink: DeepLink?
init(auth: AuthStore = AuthStore()) {
self.auth = auth
+
+ if ScreenshotMode.isEnabled {
+ auth.seedScreenshotData()
+ }
}
- // Lazily create the websocket. Lives for the lifetime of the session.
func ensureWebSocket() {
+ guard !ScreenshotMode.isEnabled else {
+ wsStatus = .online
+ return
+ }
guard webSocket == nil, let client = auth.client else { return }
let ws = TaskWebSocket(profile: client.profile, apiKey: client.apiKey)
ws.onStatusChange = { [weak self] s in Task { @MainActor in self?.wsStatus = s } }
diff --git a/makima/ios/Sources/Makima/App/ScreenshotMode.swift b/makima/ios/Sources/Makima/App/ScreenshotMode.swift
new file mode 100644
index 0000000..a1062db
--- /dev/null
+++ b/makima/ios/Sources/Makima/App/ScreenshotMode.swift
@@ -0,0 +1,21 @@
+import Foundation
+
+/// Enabled via `-DSCREENSHOT_MODE` in the CI build. Short-circuits auth with
+/// a fake client and seeds the app with deterministic demo data so we can
+/// grab reproducible screenshots without hitting a real Makima server.
+enum ScreenshotMode {
+ static var isEnabled: Bool {
+ #if SCREENSHOT_MODE
+ return true
+ #else
+ return false
+ #endif
+ }
+
+ /// Fake server profile used by the stub authenticated state.
+ static var profile: ServerProfile {
+ ServerProfile(label: "makima.jp", baseURLString: "https://makima.jp")
+ }
+
+ static var apiKey: String { "mk_demo0000deadbeef0000cafe" }
+}