nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
215 stars 80 forks source link

Crashes iOS app when setting selected tab item color #313

Open NachmanRoss opened 3 years ago

NachmanRoss commented 3 years ago

I just updated to version 5.3.6 and found that it crashes my app when running on an iOS simulator when I try to set the Tab Bar's selected item color. I'm running in the following environment: ✔ Xcode version 12.5.1 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ✔ Component nativescript has 8.0.2 version and is up to date. ✔ Component @nativescript/core has 8.0.8 version and is up to date. ✔ Component @nativescript/ios has 8.0.0 version and is up to date. ✔ Component @nativescript/android has 8.0.0 version and is up to date.

This is my code: this.set("settingsTitle", ((this.bottomNavigation.selectedIndex === 0) ? "Profile" : ((this.bottomNavigation.selectedIndex === 1) ? "Email | Password" : "Security Settings"))); this.bottomNavigation.setTabBarSelectedItemColor(new Color("black")); this.bottomNavigation.setTabBarUnSelectedItemColor(new Color("darkgray"));

The above code works perfectly on the android emulators but crashes the app when running on the iOS simulators. Here's the stack trace error that shows in my console:

CONSOLE LOG: Nativescript Error: TypeError: Cannot read property ‘frame’ of undefined Fatal JavaScript exception - application has been terminated. NativeScript encountered a fatal error: Uncaught TypeError: Cannot read property ‘frame’ of undefined at updateBackgroundPositions(file: node_modules/@nativescript-community/ui-material-bottom-navigation/index.ios.js:176:0) at updateItemColors(file: node_modules/@nativescript-community/ui-material-bottom-navigation/index.ios.js:495:0) at (file: node_modules/@nativescript-community/ui-material-bottom-navigation/index.ios.js:490:0) at updateAllItemsColors(file: node_modules/@nativescript-community/ui-material-bottom-navigation/index.ios.js:489:0) at setTabBarSelectedItemColor(file: node_modules/@nativescript-community/ui-material-bottom-navigation/index.ios.js:373:0) at initializeVariables(file: app/settings/settings-view-model.ts:113:26) at SettingsViewModel(file: app/settings/settings-view-model.ts:86:9) at onNavigatingTo(file: app/settings/settings-page.ts:8:30) at _handleEvent(file: node_modules/@nativescript/core/data/observable/index.js:233:0) at notify(file: node_modules/@nativescript/core/data/observable/index.js:216:0) at onNavigatingTo(file: node_modules/@nativescript/core/ui/page/page-common.js:90:0) at push…/node_modules/@nativescript/core/ui/page/index.js.UIViewControllerImpl.viewWillAppear(file: node_modules/@nativescript/core/ui/page/index.ios.js:79:0)

For now I've added an isAndroid test so that I set the color only when running on android devices. this.set("settingsTitle", ((this.bottomNavigation.selectedIndex === 0) ? "Profile" : ((this.bottomNavigation.selectedIndex === 1) ? "Email | Password" : "Security Settings"))); if (isAndroid) { this.bottomNavigation.setTabBarSelectedItemColor(new Color("black")); this.bottomNavigation.setTabBarUnSelectedItemColor(new Color("darkgray")); }

farfromrefug commented 3 years ago

@NachmanRoss So that i understand, it was working with the previous version? I think i did not change anything there

NachmanRoss commented 3 years ago

I just added the code to change the font color so I first noticed it today but the previous version also fails. I’m in the process of changing to the bottomnavigationbar version of the plugin. I see that it doesn’t have a setTabBarSelectedItemColor function but exposes the activeColor and InactiveColor attributes which I can set. So I’ll see if that works.

Nachman Beinish Ross Ben Alter Development @. @.> On Jun 28, 2021, 9:33 AM -0400, Martin Guillon @.***>, wrote:

@NachmanRoss So that i understand, it was working with the previous version? I think i did not change anything there

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nativescript-community/ui-material-components/issues/313#issuecomment-869689094 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUWSS7YITYVWH5WU6NOVETTVB2ZXANCNFSM47N52FMA . https://github.com/notifications/beacon/AKUWSSYBNUKIRSONL62Z6DTTVB2ZXA5CNFSM47N52FMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGPLGOBQ.gif

NachmanRoss commented 3 years ago

Unfortunately, the bottomnavigationbar plugin doesn’t display my full screen in the way that my app requires so I have to use the bottom-navigation plugin. So I’ll implement the color change on android only until you can develop a fix.

Nachman Beinish Ross Ben Alter Development @. @.> On Jun 28, 2021, 9:38 AM -0400, Work @.***>, wrote: I just added the code to change the font color so I first noticed it today but the previous version also fails. I’m in the process of changing to the bottomnavigationbar version of the plugin. I see that it doesn’t have a setTabBarSelectedItemColor function but exposes the activeColor and InactiveColor attributes which I can set. So I’ll see if that works.

Nachman Beinish Ross Ben Alter Development @. @.> On Jun 28, 2021, 9:33 AM -0400, Martin Guillon @.***>, wrote:

@NachmanRoss So that i understand, it was working with the previous version? I think i did not change anything there

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nativescript-community/ui-material-components/issues/313#issuecomment-869689094 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUWSS7YITYVWH5WU6NOVETTVB2ZXANCNFSM47N52FMA . https://github.com/notifications/beacon/AKUWSSYBNUKIRSONL62Z6DTTVB2ZXA5CNFSM47N52FMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGPLGOBQ.gif