integrated Jetpack navigation to project so we dont have to manually code the functionallities of loading to different fragments

This commit is contained in:
Alex
2026-04-04 20:08:40 -06:00
parent e25a02fe1f
commit be79de7c82
33 changed files with 508 additions and 455 deletions

View File

@@ -7,12 +7,14 @@
android:orientation="vertical"
android:background="@color/primary_dark">
<FrameLayout
android:id="@+id/fragment_container"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/background_grey"/>
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -10,10 +11,13 @@
android:layout_height="match_parent"
android:background="@color/background_grey">
<FrameLayout
android:id="@+id/inner_fragment_container"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/inner_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
app:defaultNavHost="false"
app:navGraph="@navigation/list_nav_graph" />
<View
android:id="@+id/touchBlocker"
@@ -33,8 +37,6 @@
android:orientation="vertical"
android:background="@color/primary_dark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -87,14 +89,12 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pets"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<LinearLayout
@@ -106,14 +106,12 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Services"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<LinearLayout
@@ -125,39 +123,30 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suppliers"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- Appointments -->
<LinearLayout
android:id="@+id/drawerAppointments"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
<LinearLayout
android:id="@+id/drawerAppointments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Appointments"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- Adoptions -->
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Appointments"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/drawerAdoptions"
@@ -168,19 +157,14 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Adoptions"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- Inventory -->
<LinearLayout
android:id="@+id/drawerInventory"
android:layout_width="match_parent"
@@ -190,19 +174,14 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Inventory"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- Product -->
<LinearLayout
android:id="@+id/drawerProducts"
android:layout_width="match_parent"
@@ -212,88 +191,65 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Products"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- Sale -->
<LinearLayout
android:id="@+id/drawerSale"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
<LinearLayout
android:id="@+id/drawerSale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sale"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- PurchaseOrder -->
<LinearLayout
android:id="@+id/drawerPurchaseOrderView"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PurchaseOrder"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<!-- ProductSupplier -->
<LinearLayout
android:id="@+id/drawerProductSupplier"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ProductSupplier"
android:textColor="@color/white"
android:textSize="15sp"/>
android:layout_height="wrap_content"
android:text="Sale"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/drawerPurchaseOrderView"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PurchaseOrder"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/drawerProductSupplier"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ProductSupplier"
android:textColor="@color/white"
android:textSize="15sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/list_nav_graph"
app:startDestination="@id/nav_pet">
<!-- List Screens -->
<fragment
android:id="@+id/nav_pet"
android:name="com.example.petstoremobile.fragments.listfragments.PetFragment"
android:label="Pets"
tools:layout="@layout/fragment_pet" />
<fragment
android:id="@+id/nav_service"
android:name="com.example.petstoremobile.fragments.listfragments.ServiceFragment"
android:label="Services"
tools:layout="@layout/fragment_service" />
<fragment
android:id="@+id/nav_supplier"
android:name="com.example.petstoremobile.fragments.listfragments.SupplierFragment"
android:label="Suppliers"
tools:layout="@layout/fragment_supplier" />
<fragment
android:id="@+id/nav_adoption"
android:name="com.example.petstoremobile.fragments.listfragments.AdoptionFragment"
android:label="Adoptions"
tools:layout="@layout/fragment_adoption" />
<fragment
android:id="@+id/nav_appointment"
android:name="com.example.petstoremobile.fragments.listfragments.AppointmentFragment"
android:label="Appointments"
tools:layout="@layout/fragment_appointment" />
<fragment
android:id="@+id/nav_inventory"
android:name="com.example.petstoremobile.fragments.listfragments.InventoryFragment"
android:label="Inventory"
tools:layout="@layout/fragment_inventory" />
<fragment
android:id="@+id/nav_product"
android:name="com.example.petstoremobile.fragments.listfragments.ProductFragment"
android:label="Products"
tools:layout="@layout/fragment_product" />
<fragment
android:id="@+id/nav_product_supplier"
android:name="com.example.petstoremobile.fragments.listfragments.ProductSupplierFragment"
android:label="Product Suppliers"
tools:layout="@layout/fragment_product_supplier" />
<fragment
android:id="@+id/nav_purchase_order"
android:name="com.example.petstoremobile.fragments.listfragments.PurchaseOrderFragment"
android:label="Purchase Orders"
tools:layout="@layout/fragment_purchase_order" />
<fragment
android:id="@+id/nav_sale"
android:name="com.example.petstoremobile.fragments.listfragments.SaleFragment"
android:label="Sales"
tools:layout="@layout/fragment_sale" />
<!-- Detail Screens -->
<fragment
android:id="@+id/nav_pet_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.PetDetailFragment"
android:label="Pet Details"
tools:layout="@layout/fragment_pet_detail" />
<fragment
android:id="@+id/nav_pet_profile"
android:name="com.example.petstoremobile.fragments.listfragments.listprofilefragments.PetProfileFragment"
android:label="Pet Profile"
tools:layout="@layout/fragment_pet_profile" />
<fragment
android:id="@+id/nav_adoption_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.AdoptionDetailFragment"
android:label="Adoption Details"
tools:layout="@layout/fragment_adoption_detail" />
<fragment
android:id="@+id/nav_service_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.ServiceDetailFragment"
android:label="Service Details"
tools:layout="@layout/fragment_service_detail" />
<fragment
android:id="@+id/nav_supplier_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.SupplierDetailFragment"
android:label="Supplier Details"
tools:layout="@layout/fragment_supplier_detail" />
<fragment
android:id="@+id/nav_inventory_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.InventoryDetailFragment"
android:label="Inventory Details"
tools:layout="@layout/fragment_inventory_detail" />
<fragment
android:id="@+id/nav_appointment_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.AppointmentDetailFragment"
android:label="Appointment Details"
tools:layout="@layout/fragment_appointment_detail" />
<fragment
android:id="@+id/nav_purchase_order_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.PurchaseOrderDetailFragment"
android:label="Purchase Order Details"
tools:layout="@layout/fragment_purchase_order_detail" />
<fragment
android:id="@+id/nav_product_supplier_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.ProductSupplierDetailFragment"
android:label="Product Supplier Details"
tools:layout="@layout/fragment_product_supplier_detail" />
<fragment
android:id="@+id/nav_product_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.ProductDetailFragment"
android:label="Product Details"
tools:layout="@layout/fragment_product_detail" />
<fragment
android:id="@+id/nav_refund_detail"
android:name="com.example.petstoremobile.fragments.listfragments.detailfragments.RefundDetailFragment"
android:label="Refund Details"
tools:layout="@layout/fragment_refund_detail" />
</navigation>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/nav_graph"
app:startDestination="@id/nav_list">
<fragment
android:id="@+id/nav_list"
android:name="com.example.petstoremobile.fragments.ListFragment"
android:label="List"
tools:layout="@layout/fragment_list" />
<fragment
android:id="@+id/nav_chat"
android:name="com.example.petstoremobile.fragments.ChatFragment"
android:label="Chat"
tools:layout="@layout/fragment_chat" />
<fragment
android:id="@+id/nav_profile"
android:name="com.example.petstoremobile.fragments.ProfileFragment"
android:label="Profile"
tools:layout="@layout/fragment_profile" />
</navigation>