how to use navigation component nav controller with Droppers/AnimatedBottomBar libray?

37 views Asked by At

I am trying to use Droppers/AnimatedBottomBar text but I am not able to use nav Controller with this libray as they have mentioned the support of Nav Controller but I do not know how to do it.

Here is my .XML file

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".presentation.fragments.home_screen.HomeScreenFragment">


    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/fragment_container"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toTopOf="@id/bottom_bar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/main_bottom_navigation" />


    <nl.joery.animatedbottombar.AnimatedBottomBar
        android:id="@+id/bottom_bar"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="#C8D9F4"
        app:abb_iconSize="39dp"
        app:abb_indicatorAppearance="round"
        app:abb_indicatorHeight="4dp"
        app:abb_indicatorMargin="16dp"
        app:abb_rippleColor="#EFDFA3"
        app:abb_rippleEnabled="true"
        app:abb_selectedIndex="1"
        app:abb_selectedTabType="text"
        app:abb_tabAnimation="slide"
        app:abb_tabColorSelected="@color/black"
        app:abb_tabs="@menu/tabs"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/fragment_container" />

</androidx.constraintlayout.widget.ConstraintLayout>

here is my menu file:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/tab_home_destination"
        android:icon="@drawable/home"
        android:title="@string/home" />
    <item
        android:id="@+id/tab_tools_destination"
        android:icon="@drawable/lock"
        android:title="@string/alarm" />

    <item
        android:id="@+id/tab_setting_destination"
        android:icon="@drawable/baseline_settings_24"
        android:title="@string/setting" />
</menu>

My Fragment .kt file:

package com.example.statussaver.presentation.fragments.home_screen

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import com.example.statussaver.R
import com.example.statussaver.databinding.FragmentHomeScreenBinding

class HomeScreenFragment : Fragment() {
lateinit var binding : FragmentHomeScreenBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentHomeScreenBinding.inflate(layoutInflater)
        return binding.root
    }

    fun setUpBottomBar(){
             binding.bottomBar.setupWithNavController(?)

}

Here I want to navigate between my fragments using this bottom bar but I am not able to because this library binding.bottomBar.setupWithNavController(?) require Menu and NavController but I do not know how to pass it here. If anyone have implemented please guide me or refer me any sample projet which is using this library.

0

There are 0 answers