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 @@ - - + + + + + + + + - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/app/src/Admin/res/layout/fragment_home.xml b/app/src/Admin/res/layout/fragment_home.xml new file mode 100644 index 0000000..1c70be1 --- /dev/null +++ b/app/src/Admin/res/layout/fragment_home.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/Admin/res/layout/nav_drawer_header.xml b/app/src/Admin/res/layout/nav_drawer_header.xml new file mode 100644 index 0000000..8fd9017 --- /dev/null +++ b/app/src/Admin/res/layout/nav_drawer_header.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/Admin/res/menu/nav_drawer_menu.xml b/app/src/Admin/res/menu/nav_drawer_menu.xml new file mode 100644 index 0000000..87acc0a --- /dev/null +++ b/app/src/Admin/res/menu/nav_drawer_menu.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/Admin/res/menu/toolbar_menu.xml b/app/src/Admin/res/menu/toolbar_menu.xml new file mode 100644 index 0000000..29ad986 --- /dev/null +++ b/app/src/Admin/res/menu/toolbar_menu.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/Admin/res/navigation/nav_menu.xml b/app/src/Admin/res/navigation/nav_menu.xml new file mode 100644 index 0000000..c4ca0fa --- /dev/null +++ b/app/src/Admin/res/navigation/nav_menu.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/Admin/res/values/strings.xml b/app/src/Admin/res/values/strings.xml index 73862c4..08f7736 100644 --- a/app/src/Admin/res/values/strings.xml +++ b/app/src/Admin/res/values/strings.xml @@ -1 +1,6 @@ - \ No newline at end of file + + username + Add Partners + Logout + Create event + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add_event_circle_24.xml b/app/src/main/res/drawable/ic_add_event_circle_24.xml new file mode 100644 index 0000000..08dda0a --- /dev/null +++ b/app/src/main/res/drawable/ic_add_event_circle_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_nav_menu_icon_24.xml b/app/src/main/res/drawable/ic_nav_menu_icon_24.xml new file mode 100644 index 0000000..470db52 --- /dev/null +++ b/app/src/main/res/drawable/ic_nav_menu_icon_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_round_handshake_24.xml b/app/src/main/res/drawable/ic_round_handshake_24.xml new file mode 100644 index 0000000..57c7c8b --- /dev/null +++ b/app/src/main/res/drawable/ic_round_handshake_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_round_logout_24.xml b/app/src/main/res/drawable/ic_round_logout_24.xml new file mode 100644 index 0000000..b1b6575 --- /dev/null +++ b/app/src/main/res/drawable/ic_round_logout_24.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ic_round_person_24.xml b/app/src/main/res/drawable/ic_round_person_24.xml new file mode 100644 index 0000000..115b6a3 --- /dev/null +++ b/app/src/main/res/drawable/ic_round_person_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 124dfa2..bf3fed2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ + DevStories Africa DevStories Africa Admin @@ -32,5 +33,5 @@ Or sign up with Or sign in with This month\'s session will be on Career Change Management. Are you looking to make a leap in your career? Join the session to learn how to hit the ground running and get the most out of your career change. - + Logout \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 0b29355..2a15088 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -43,8 +43,15 @@ @font/source_sans_pro + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7b50f9c..879296f 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,6 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5" classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1' - - // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }