111coding / circle_nav_bar

Apache License 2.0
8 stars 10 forks source link

Supporting RTL Direction #2

Open yottaline opened 2 years ago

yottaline commented 2 years ago

How to make the navbar supports RTL direction?

image

MohamadSuhiebAjaj commented 4 months ago

i also face the same issue please if you find problem fix tag me

yottaline commented 4 months ago

i also face the same issue please if you find problem fix tag me

@MohamadSuhiebAjaj

Just wrap the nav with a Directionality widget to keep it ltr whatever your app ltr or rtl and reverse the items or keep it as it is

donisaputradev commented 1 month ago

I want to help, I found the fix like this for RTL support :

from this :

  double getPosition(int i) {
    int itemCnt = widget.activeIcons.length;
    return i / itemCnt + (1 / itemCnt) / 2;
  }

to this :

  double getPosition(int i) {
    int itemCnt = widget.activeIcons.length;
    double basePosition = i / itemCnt;
    if (Directionality.of(context) == TextDirection.rtl) {
      return ((1 - basePosition) - (1 / itemCnt) / 2);
    } else {
      return basePosition + (1 / itemCnt) / 2;
    }
  }