henrychavez / nativescript-bottom-navigation

Nativescript plugin for Android & iOS to have the bottom navigation bar of Material Design
Apache License 2.0
58 stars 18 forks source link

Support for badges on iOS #29

Closed brunoziie closed 5 years ago

brunoziie commented 6 years ago

On Android the AHBottomNavigation has support for badges, so i can call

    bottomNavigation.android.setNotification("1", 3);

Is it possible to do on iOS too? If yes, can it turns a agnostic feature?

henrychavez commented 6 years ago

Hi,

Yes I’m changing the iOS part to use material components and will be ready next week hopefully

davorpeic commented 6 years ago

Hey @henrychavez hows material going on? :) thanks

henrychavez commented 6 years ago

@davorpeic is going great, I almost got it.

It will be ready for the weekend

henrychavez commented 6 years ago

@davorpeic the version 1.4.0 now is implementing the BottomNavigation from material-components

brunoziie commented 6 years ago

@henrychavez I just tried and don't build.

I got stuck with Command xcodebuild failed with exit code 65..

When I rollback to version 1.3.0 works fine.

$ tns --version
4.2.1

$ xcodebuild -version
Xcode 10.0
Build version 10A255
alexandruantonica commented 6 years ago

@brunoziie There should be more info about code 65 error. Clean platforms and node_modules folders, try again to run your command.

brunoziie commented 6 years ago

@alexandruantonica I already tried to remove and add platform again. I will try remove both now.

brunoziie commented 6 years ago

Solved.

I don't know why but when put this version together with nativescript-toast its don't build.

Tks, @henrychavez and @alexandruantonica.

henrychavez commented 6 years ago

Great!

Happy Coding!

uzarsalan commented 6 years ago

Hi! Thanks for awesome plugin. Can you help me with adding badges on ios? Simple example would be fine. Thanks!

henrychavez commented 6 years ago

@uzarsalan for now you can put this code inside your onBottomNavigationLoaded() callback or where you think is convenient, but you need the reference of the native view.

onBottomNavigationLoaded(args) {
  const bottomNavigation = args.object;
  const tabIndex = 1;
  const badgeValue = "2";
  if (isIOS) {
    cont tab = bottomNavigation.items[tabIndex];
    tab.badgeValue(badgeValue);
  } else {
    // Android
    bottomNavigation.setNotification(badgeValue, tabIndex);
  }
}

I'm still working on a better implementation but this is a work around for now. you can find more information for iOS here and for android here

alexandruantonica commented 5 years ago

@henrychavez This workaround doesn't work in my case. Do we have any other way to implement the badges for both platforms?

brunoziie commented 5 years ago

@alexandruantonica I think this not working because in the code example wrote above the platform prefix is missing.

on Android is:

bottomNavigation.android.setNotification("1", 3);

on iOS maybe it's something like this:

cont tab = bottomNavigation.items[tabIndex];
tab.ios.badgeValue(badgeValue);
alexandruantonica commented 5 years ago

Thanks @brunoziie I'll check

uzarsalan commented 5 years ago
const tab = bottomNavigation.ios.items[tabIndex];
tab.badgeValue = badgeValue;

BadgeValue is property, not a function

henrychavez commented 5 years ago

52