-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modal): status bar color now correct with sheet modal (#25424)
resolves #20501
- Loading branch information
1 parent
c10df52
commit 377c4f5
Showing
5 changed files
with
152 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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,34 @@ | ||
import { win } from '../window'; | ||
|
||
interface StyleOptions { | ||
style: Style; | ||
} | ||
|
||
export enum Style { | ||
Dark = 'DARK', | ||
Light = 'LIGHT', | ||
Default = 'DEFAULT', | ||
} | ||
|
||
export const StatusBar = { | ||
getEngine() { | ||
return (win as any)?.Capacitor?.isPluginAvailable('StatusBar') && (win as any)?.Capacitor.Plugins.StatusBar; | ||
}, | ||
supportsDefaultStatusBarStyle() { | ||
/** | ||
* The 'DEFAULT' status bar style was added | ||
* to the @capacitor/status-bar plugin in Capacitor 3. | ||
* PluginHeaders is only supported in Capacitor 3+, | ||
* so we can use this to detect Capacitor 3. | ||
*/ | ||
return !!(win as any)?.Capacitor?.PluginHeaders; | ||
}, | ||
setStyle(options: StyleOptions) { | ||
const engine = this.getEngine(); | ||
if (!engine) { | ||
return; | ||
} | ||
|
||
engine.setStyle(options); | ||
}, | ||
}; |
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,23 @@ | ||
/** | ||
* When accessing the window, it is important | ||
* to account for SSR applications where the | ||
* window is not available. Code that accesses | ||
* window when it is not available will crash. | ||
* Even checking if `window === undefined` will cause | ||
* apps to crash in SSR. | ||
* | ||
* Use win below to access an SSR-safe version | ||
* of the window. | ||
* | ||
* Example 1: | ||
* Before: | ||
* if (window.innerWidth > 768) { ... } | ||
* | ||
* After: | ||
* import { win } from 'path/to/this/file'; | ||
* if (win?.innerWidth > 768) { ... } | ||
* | ||
* Note: Code inside of this if-block will | ||
* not run in an SSR environment. | ||
*/ | ||
export const win: Window | undefined = typeof window !== 'undefined' ? window : undefined; |