also looking at this
fix(ios): let native screens choose interface appearance
#398
8 files
+218
-5
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.
| @@ -34,6 +34,8 @@ describe('Bridge Type Definitions', () => { | ||
| 34 | 34 | version: '1.0.0', |
| 35 | 35 | platform: 'macos', |
| 36 | 36 | }), |
| 37 | setAppearance: async (_appearance: 'light' | 'dark' | 'system') => {}, | |
| 38 | getAppearance: async () => 'light', | |
| 37 | 39 | }, |
| 38 | 40 | } |
| 39 | 41 | |
| @@ -85,6 +87,8 @@ describe('Bridge Type Definitions', () => { | ||
| 85 | 87 | version: '1.0.0', |
| 86 | 88 | platform: 'macos', |
| 87 | 89 | }), |
| 90 | setAppearance: async (_appearance: 'light' | 'dark' | 'system') => {}, | |
| 91 | getAppearance: async () => 'light', | |
| 88 | 92 | } |
| 89 | 93 | |
| 90 | 94 | expect(typeof mockApp.hideDockIcon).toBe('function') |
| @@ -286,6 +290,8 @@ describe('Bridge API Method Signatures', () => { | ||
| 286 | 290 | version: '1.0.0', |
| 287 | 291 | platform: 'macos', |
| 288 | 292 | }), |
| 293 | setAppearance: async (_appearance: 'light' | 'dark' | 'system') => {}, | |
| 294 | getAppearance: async () => 'light', | |
| 289 | 295 | } |
| 290 | 296 | |
| 291 | 297 | const info = await mockApp.getInfo() |
| @@ -327,6 +333,8 @@ describe('Window Global Type Augmentation', () => { | ||
| 327 | 333 | version: '1.0.0', |
| 328 | 334 | platform: 'macos', |
| 329 | 335 | }), |
| 336 | setAppearance: async (_appearance: 'light' | 'dark' | 'system') => {}, | |
| 337 | getAppearance: async () => 'light', | |
| 330 | 338 | }, |
| 331 | 339 | } as CraftBridgeAPI, |
| 332 | 340 | } |
| @@ -629,14 +629,14 @@ class AppManager { | ||
| 629 | 629 | // ========================================================================== |
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | * Set app appearance (macOS) | |
| 632 | * Set the app appearance on native hosts. | |
| 633 | 633 | */ |
| 634 | 634 | async setAppearance(appearance: 'light' | 'dark' | 'system'): Promise<void> { |
| 635 | 635 | await this._call('setAppearance', { appearance }) |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | * Get current appearance | |
| 639 | * Get the current effective Light/Dark appearance. | |
| 640 | 640 | */ |
| 641 | 641 | async getAppearance(): Promise<'light' | 'dark'> { |
| 642 | 642 | return this._call('getAppearance') |
| @@ -759,6 +759,12 @@ export interface CraftAppAPI { | ||
| 759 | 759 | * Get application information |
| 760 | 760 | */ |
| 761 | 761 | getInfo(): Promise<AppInfo> |
| 762 | ||
| 763 | /** Pin every native surface to Light, Dark, or the system setting. */ | |
| 764 | setAppearance(appearance: 'light' | 'dark' | 'system'): Promise<void> | |
| 765 | ||
| 766 | /** Read the app's effective Light/Dark appearance. */ | |
| 767 | getAppearance(): Promise<'light' | 'dark'> | |
| 762 | 768 | } |
| 763 | 769 | |
| 764 | 770 | /** |