Code Monkey home page Code Monkey logo

capacitor-navigationbar's People

Contributors

nikosdouvlis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

capacitor-navigationbar's Issues

Plugin not installed by itself

Maybe I misunderstood this plugin, but after following all the installations steps from the README, I got an error from Android Studio stating that com.nikosdouvlis.navigationbar was missing. In fact after searching in java/main/ directory I was not able to see any tracks of the NavigationBar.java class myself like if it was not copied anywhere in the project.

So far I created my own NavigationBar.java class manually and imported it in my MainActivity.java file and it works fine.

Maybe there are other steps to follow for the relevant class to be copied automatically ?

Full screen mode

Does this plugin allow to use the space around status bar to allow app to span behind the status bar? Currently status bar section in capacitor is just black making the app look weird compared to iOS which leverages navigation bar and status bar.

Consider setting the system UI visibility as well

Since the window.setNavigationBarColor only sets the background color of the navigation bar, the navigation buttons will be hard to see if the background color is close to white. Consider setting the View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR flag to make the buttons visible when the background color is light.

@NativePlugin()
public class NavigationBar extends com.nikosdouvlis.navigationbar.NavigationBar {
  @Override
  @PluginMethod()
  public void setBackgroundColor(PluginCall call) {
    String color = call.getString("color");

    try {
      final int parsedColor = Color.parseColor(color);
      final Window window = ((Activity) getContext()).getWindow();
      final boolean isLight = ColorUtils.calculateLuminance(parsedColor) > 0.5;

      getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            View decorView = window.getDecorView();
            int visibilityFlags = decorView.getSystemUiVisibility();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            if (isLight) {
              decorView.setSystemUiVisibility(visibilityFlags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            } else {
              decorView.setSystemUiVisibility(visibilityFlags & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            }
          }
        }
      });
    } catch (Exception e) {
      call.error(e.toString());
    }

    super.setBackgroundColor(call);
  }
}

You may refer to this post on how to check a color is light:

https://stackoverflow.com/questions/24260853/check-if-color-is-dark-or-light-in-android

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.