fix(modal): status bar color now correct with sheet modal (#25424)

resolves #20501
This commit is contained in:
Liam DeBeasi
2022-06-13 14:08:57 -04:00
committed by GitHub
parent c10df52f39
commit 377c4f597b
5 changed files with 152 additions and 12 deletions

View File

@ -1,3 +1,6 @@
import { StatusBar, Style } from '../../utils/native/status-bar';
import { win } from '../../utils/window';
/**
* Use y = mx + b to
* figure out the backdrop value
@ -57,3 +60,31 @@ export const getBackdropValueForSheet = (x: number, backdropBreakpoint: number)
return x * slope + b;
};
/**
* The tablet/desktop card modal activates
* when the window width is >= 768.
* At that point, the presenting element
* is not transformed, so we do not need to
* adjust the status bar color.
*
* Note: We check supportsDefaultStatusBarStyle so that
* Capacitor <= 2 users do not get their status bar
* stuck in an inconsistent state due to a lack of
* support for Style.Default.
*/
export const setCardStatusBarDark = () => {
if (!win || win.innerWidth >= 768 || !StatusBar.supportsDefaultStatusBarStyle()) {
return;
}
StatusBar.setStyle({ style: Style.Dark });
};
export const setCardStatusBarDefault = () => {
if (!win || win.innerWidth >= 768 || !StatusBar.supportsDefaultStatusBarStyle()) {
return;
}
StatusBar.setStyle({ style: Style.Default });
};