mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(bottom-navigation): android light/dark theme change on device crash (#9270)
This commit is contained in:
@@ -744,7 +744,12 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
}
|
||||
|
||||
public updateAndroidItemAt(index: number, spec: org.nativescript.widgets.TabItemSpec) {
|
||||
this._bottomNavigationBar.updateItemAt(index, spec);
|
||||
// this can throw when switching light/dark theme mode on device, just ignore
|
||||
try {
|
||||
this._bottomNavigationBar.updateItemAt(index, spec);
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public getTabBarBackgroundColor(): android.graphics.drawable.Drawable {
|
||||
@@ -825,13 +830,18 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
}
|
||||
|
||||
private setIconColor(tabStripItem: TabStripItem, color?: Color) {
|
||||
const tabBarItem = this._bottomNavigationBar.getViewForItemAt(tabStripItem._index);
|
||||
// this can throw when switching light/dark theme mode on device, just ignore
|
||||
try {
|
||||
const tabBarItem = this._bottomNavigationBar.getViewForItemAt(tabStripItem._index);
|
||||
|
||||
const drawableInfo = this.getIconInfo(tabStripItem, color);
|
||||
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
|
||||
imgView.setImageDrawable(drawableInfo.drawable);
|
||||
if (color) {
|
||||
imgView.setColorFilter(color.android);
|
||||
const drawableInfo = this.getIconInfo(tabStripItem, color);
|
||||
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
|
||||
imgView.setImageDrawable(drawableInfo.drawable);
|
||||
if (color) {
|
||||
imgView.setColorFilter(color.android);
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user