ReviewOS

also looking at this

craft-native/craft

feat: finish native customization and platform seams

#401
Merged glennmichael123 wants to merge codex/issues-388-400-344 into main
21 files +707 -17

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

packages/ios/templates/CraftApp.swiftmodified+11-6
Changes to packages/ios/templates/CraftApp.swift
@@ -109,7 +109,11 @@ enum CraftPageAppearance {
109109/// created after the choice inherit it instead of reverting to the bundle
110110/// config.
111111enum CraftInterfaceStyleController {
112 private static var selected: UIUserInterfaceStyle?
112 /// The app's bundled choice is the default for newly-created screens.
113 /// A runtime choice is separate: it is the only value that should
114 /// override a screen's own generated config.
115 private static var configured: UIUserInterfaceStyle = .unspecified
116 private static var runtimeSelection: UIUserInterfaceStyle?
113117
114118 static func configuredStyle(for config: CraftConfig) -> UIUserInterfaceStyle {
115119 switch config.appearance {
@@ -121,12 +125,13 @@ enum CraftInterfaceStyleController {
121125 }
122126
123127 static func configure(_ config: CraftConfig) {
124 selected = configuredStyle(for: config)
128 configured = configuredStyle(for: config)
129 runtimeSelection = nil
125130 applyToWindows()
126131 }
127132
128133 static func style(for config: CraftConfig) -> UIUserInterfaceStyle {
129 selected ?? configuredStyle(for: config)
134 runtimeSelection ?? configuredStyle(for: config)
130135 }
131136
132137 /// Returns false rather than silently accepting a typo from JavaScript.
@@ -139,14 +144,14 @@ enum CraftInterfaceStyleController { renamed throughout
139144 case "dark": style = .dark
140145 default: return false
141146 }
142 selected = style
147 runtimeSelection = style
143148 applyToWindows()
144149 NotificationCenter.default.post(name: .craftColorSchemeChanged, object: nil)
145150 return true
146151 }
147152
148153 static func currentName() -> String {
149 let requested = selected ?? UIApplication.shared.connectedScenes
154 let requested = runtimeSelection ?? UIApplication.shared.connectedScenes
150155 .compactMap { ($0 as? UIWindowScene)?.windows.first(where: { $0.isKeyWindow })?.traitCollection.userInterfaceStyle }
151156 .first ?? .unspecified
152157 let style = requested == .unspecified
@@ -162,7 +167,7 @@ enum CraftInterfaceStyleController {
162167 }
163168
164169 private static func applyToWindows() {
165 let style = selected ?? .unspecified
170 let style = runtimeSelection ?? configured
166171 for scene in UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }) {
167172 for window in scene.windows {
168173 window.overrideUserInterfaceStyle = style