From b9e33d12c3bb83452ee1c40e2c98aef484c9ffa8 Mon Sep 17 00:00:00 2001
From: James Gitonga <40741293+JayExtra@users.noreply.github.com>
Date: Wed, 9 Feb 2022 23:57:46 +0300
Subject: [PATCH] Navigation Drawer issue #42: - Added navigation drawer to the
admin flavour
Signed-off-by: James Gitonga <40741293+JayExtra@users.noreply.github.com>
---
app/build.gradle | 2 +-
.../devstoriesafrica/MainActivity.kt | 31 ++++++++-
.../devstoriesafrica/ui/HomeFragment.kt | 34 +++++++++
app/src/Admin/res/layout/activity_main.xml | 69 +++++++++++++++----
app/src/Admin/res/layout/fragment_home.xml | 19 +++++
.../Admin/res/layout/nav_drawer_header.xml | 33 +++++++++
app/src/Admin/res/menu/nav_drawer_menu.xml | 31 +++++++++
app/src/Admin/res/menu/toolbar_menu.xml | 9 +++
app/src/Admin/res/navigation/nav_menu.xml | 13 ++++
app/src/Admin/res/values/strings.xml | 7 +-
.../res/drawable/ic_add_event_circle_24.xml | 5 ++
.../main/res/drawable/ic_nav_menu_icon_24.xml | 5 ++
.../res/drawable/ic_round_handshake_24.xml | 5 ++
.../main/res/drawable/ic_round_logout_24.xml | 6 ++
.../main/res/drawable/ic_round_person_24.xml | 5 ++
app/src/main/res/values/strings.xml | 3 +-
app/src/main/res/values/themes.xml | 7 ++
build.gradle | 2 -
18 files changed, 267 insertions(+), 19 deletions(-)
create mode 100644 app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/ui/HomeFragment.kt
create mode 100644 app/src/Admin/res/layout/fragment_home.xml
create mode 100644 app/src/Admin/res/layout/nav_drawer_header.xml
create mode 100644 app/src/Admin/res/menu/nav_drawer_menu.xml
create mode 100644 app/src/Admin/res/menu/toolbar_menu.xml
create mode 100644 app/src/Admin/res/navigation/nav_menu.xml
create mode 100644 app/src/main/res/drawable/ic_add_event_circle_24.xml
create mode 100644 app/src/main/res/drawable/ic_nav_menu_icon_24.xml
create mode 100644 app/src/main/res/drawable/ic_round_handshake_24.xml
create mode 100644 app/src/main/res/drawable/ic_round_logout_24.xml
create mode 100644 app/src/main/res/drawable/ic_round_person_24.xml
diff --git a/app/build.gradle b/app/build.gradle
index ea4ed35..19e0739 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -58,7 +58,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
- implementation 'com.google.android.material:material:1.4.0'
+ implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-auth:20.0.0'
diff --git a/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/MainActivity.kt b/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/MainActivity.kt
index c91fa7e..b843ec0 100644
--- a/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/MainActivity.kt
+++ b/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/MainActivity.kt
@@ -2,11 +2,40 @@ package com.devstoriesafrica.devstoriesafrica
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import androidx.navigation.NavController
+import androidx.navigation.fragment.NavHostFragment
+import androidx.navigation.fragment.findNavController
+import androidx.navigation.ui.AppBarConfiguration
+import androidx.navigation.ui.setupWithNavController
+import com.devstoriesafrica.devstoriesafrica.databinding.ActivityMainBinding
+import dagger.hilt.android.AndroidEntryPoint
+@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
+ private lateinit var binding : ActivityMainBinding
+ private lateinit var navController : NavController
+ private lateinit var appBarConfiguration: AppBarConfiguration
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.Theme_DevStoriesAfrica)
- setContentView(R.layout.activity_main)
+ binding = ActivityMainBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+ //setup controller and navHostFragment
+ val navHostFragment =
+ supportFragmentManager.findFragmentById(R.id.navHostFragment) as NavHostFragment
+ navController = navHostFragment.findNavController()
+
+ appBarConfiguration = AppBarConfiguration(
+ navController.graph ,
+ binding.drawerLayout
+ )
+
+ binding.navigationView.setupWithNavController(navController)
+
+ binding.topAppBar.setNavigationOnClickListener {
+ //open drawer
+ binding.drawerLayout.open()
+ }
}
}
\ No newline at end of file
diff --git a/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/ui/HomeFragment.kt b/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/ui/HomeFragment.kt
new file mode 100644
index 0000000..35cd358
--- /dev/null
+++ b/app/src/Admin/java/com/devstoriesafrica/devstoriesafrica/ui/HomeFragment.kt
@@ -0,0 +1,34 @@
+package com.devstoriesafrica.devstoriesafrica.ui
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import com.devstoriesafrica.devstoriesafrica.databinding.FragmentHomeBinding
+import dagger.hilt.android.AndroidEntryPoint
+
+@AndroidEntryPoint
+class HomeFragment : Fragment() {
+
+ private var _binding : FragmentHomeBinding? = null
+ private val binding get() = _binding
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ _binding = FragmentHomeBinding.inflate(
+ inflater ,
+ container,
+ false
+ )
+ return binding?.root
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ _binding = null
+ }
+}
\ No newline at end of file
diff --git a/app/src/Admin/res/layout/activity_main.xml b/app/src/Admin/res/layout/activity_main.xml
index d9f2f1d..b6361aa 100644
--- a/app/src/Admin/res/layout/activity_main.xml
+++ b/app/src/Admin/res/layout/activity_main.xml
@@ -1,22 +1,65 @@
-