Giter Club home page Giter Club logo

flashy-tabbar-ohos's Introduction

FlashyTabBar

GitHub license

Animation

Example

To run the example project, clone the repo, and run MainAbilitySlice

As library

  • inside dependencies of the build.gradle of entry module, use the following code
    dependencies {
        //consume library
        implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
        ....
    }

Sync project and now you can use flashytabbar library

Manual

Add TabFlashyAnimator and content of res package to your project

Usage

Add TabLayout to your xml

    <com.cuberto.flashytabbarohos.TabLayoutv2
        ohos:id="$+id:tablayout"
        ohos:weight ="2"
        ohos:height="match_content"
        ohos:width="match_content">

    </com.cuberto.flashytabbarohos.TabLayoutv2>
        

Create adapter in your AbilitySlice, add some Component and set PageSlider adapter

    TabLayoutv2 tabLayout;
    private String[] titles = new String[]{"Home", "Clock", "Folder", "Menu"};
    private int[] colors = new int[]{ResourceTable.Color_home, ResourceTable.Color_clock, ResourceTable.Color_folder, ResourceTable.Color_menu};
    private Context context;
    private ComponentContainer rootLayout;
    private PageSlider mPager;
    private PageViewAdapter pageViewAdapter;
    private TabBubbleAnimator tabBubbleAnimator;
    private List<PageInfo> mPageViews;

    @Override
    protected void onStart(Intent intent) {

        super.onStart(intent);
        rootLayout = (ComponentContainer)LayoutScatter.getInstance(this)
                .parse(ResourceTable.Layout_ability_main, null, false);

        tabLayout = (TabLayoutv2)rootLayout.findComponentById(ResourceTable.Id_tablayout);
        mPager = (PageSlider) ResUtil.findComponentById(rootLayout, ResourceTable.Id_slider).get();

        mPageViews = new ArrayList();
        mPageViews.add(new TabComponent(this, titles[0], colors[0]));
        mPageViews.add(new TabComponent(this, titles[1], colors[1]));
        mPageViews.add(new TabComponent(this, titles[2], colors[2]));
        mPageViews.add(new TabComponent(this, titles[3], colors[3]));

        pageViewAdapter = new PageViewAdapter(this, mPageViews);
        mPager.setProvider(pageViewAdapter);
    }


Setup your TabLayout with ViewPager

        TabLayout tabLayout = (TabLayoutv2)rootLayout.findComponentById(ResourceTable.Id_tablayout);
        tabLayout.setupWithPageSlider(mPager);

Create TabFlashyAnimator and tabItem as title, image id and color for each tab item.

        tabFlashyAnimator = new TabFlashyAnimator(tabLayout);
        tabFlashyAnimator.addTabItem(titles[0], ResourceTable.Media_ic_events, colors[0]);
        tabFlashyAnimator.addTabItem(titles[1], ResourceTable.Media_ic_highlights,colors[1]);
        tabFlashyAnimator.addTabItem(titles[2], ResourceTable.Media_ic_search, colors[2]);
        tabFlashyAnimator.addTabItem(titles[3], ResourceTable.Media_ic_settings, colors[3]);

Call highlightTab() for 0 position and add tabFlashyAnimator as addPageChangedListener to ViewPager

        tabFlashyAnimator.highLightTab(0);
        mPager.addPageChangedListener(tabFlashyAnimator);

Call tabFlashyAnimator onStart() to start


            tabFlashyAnimator.onStart();

iOS

Similar library FlashyTabBar by Cuberto

Author

Cuberto Design, [email protected]

License

FlashyTabbar is available under the MIT license. See the LICENSE file for more info.

flashy-tabbar-ohos's People

Contributors

gleelakrishna avatar harmonygeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.