fix(ios): backport: actionBar to use appearance api on ios13+ (#9530)

This commit is contained in:
Igor Randjelovic
2021-09-02 22:35:09 +02:00
parent f6faa4509a
commit 2b8783e9eb

View File

@ -349,7 +349,7 @@ export class ActionBar extends ActionBarBase {
this.setColor(navBar, color); this.setColor(navBar, color);
const bgColor = <Color>this.backgroundColor; const bgColor = <Color>this.backgroundColor;
navBar.barTintColor = bgColor ? bgColor.ios : null; this.setBackgroundColor(navBar, bgColor);
} }
private setColor(navBar: UINavigationBar, color?: Color) { private setColor(navBar: UINavigationBar, color?: Color) {
@ -371,6 +371,25 @@ export class ActionBar extends ActionBarBase {
} }
} }
private setBackgroundColor(navBar: UINavigationBar, color?: UIColor | Color) {
if (!navBar) {
return;
}
const color_ = color instanceof Color ? color.ios : color;
if (majorVersion >= 13) {
const appearance = navBar.standardAppearance ?? UINavigationBarAppearance.new();
// appearance.configureWithOpaqueBackground();
appearance.backgroundColor = color_;
navBar.standardAppearance = appearance;
navBar.compactAppearance = appearance;
navBar.scrollEdgeAppearance = appearance;
} else {
// legacy styling
navBar.barTintColor = color_;
}
}
public _onTitlePropertyChanged() { public _onTitlePropertyChanged() {
const page = this.page; const page = this.page;
if (!page) { if (!page) {
@ -467,12 +486,9 @@ export class ActionBar extends ActionBarBase {
// CssAnimationProperty use default value form their constructor. // CssAnimationProperty use default value form their constructor.
return null; return null;
} }
[backgroundColorProperty.setNative](value: UIColor | Color) { [backgroundColorProperty.setNative](color: UIColor | Color) {
const navBar = this.navBar; const navBar = this.navBar;
if (navBar) { this.setBackgroundColor(navBar, color);
const color = value instanceof Color ? value.ios : value;
navBar.barTintColor = color;
}
} }
[backgroundInternalProperty.getDefault](): UIColor { [backgroundInternalProperty.getDefault](): UIColor {