Skip to content

Commit

Permalink
Merge pull request #58 from JayExtra/nav_drawer
Browse files Browse the repository at this point in the history
Navigation Drawer for issue #42:
  • Loading branch information
kibettheophilus authored Mar 13, 2022
2 parents 981b890 + b9e33d1 commit c9132ee
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
69 changes: 56 additions & 13 deletions app/src/Admin/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
app:itemIconTint="@color/blue"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I AM ADMIN AN APP"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/blue"
app:menu="@menu/toolbar_menu"
app:navigationIcon="@drawable/ic_nav_menu_icon_24"
app:title=""
/>
</com.google.android.material.appbar.AppBarLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingTop="0dp"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_menu" />
</androidx.appcompat.widget.LinearLayoutCompat>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
android:maxWidth="@dimen/_180sdp"
app:itemIconPadding="@dimen/_8sdp"
app:headerLayout="@layout/nav_drawer_header"
app:menu="@menu/nav_drawer_menu"
app:itemIconTint="@color/blue"
style="@style/Theme.DevStoriesAfrica.CustomNavDrawerTextStyle"
/>
</androidx.drawerlayout.widget.DrawerLayout>
19 changes: 19 additions & 0 deletions app/src/Admin/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ui.HomeFragment">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home Fragment"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
33 changes: 33 additions & 0 deletions app/src/Admin/res/layout/nav_drawer_header.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/username_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="32dp"
android:fontFamily="@font/source_sans_pro"
android:text="@string/username_placeholder"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/profile_image_layout"
app:layout_constraintStart_toStartOf="@+id/profile_image_layout"
app:layout_constraintTop_toBottomOf="@+id/profile_image_layout" />

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image_layout"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="32dp"
android:src="@color/purple_200"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.46"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
31 changes: 31 additions & 0 deletions app/src/Admin/res/menu/nav_drawer_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/addEventFragment"
android:title="@string/create_event_txt"
android:icon="@drawable/ic_add_event_circle_24"
android:checked="true"
app:itemIconTint="@color/blue"
app:itemTextAppearance="@style/Theme.DevStoriesAfrica.CustomNavDrawerTextStyle"
app:itemIconSize="@dimen/_24sdp"/>

<item
android:id="@+id/addPartnersFragment"
android:icon="@drawable/ic_round_handshake_24"
android:title="@string/add_partners_title"
app:itemIconTint="@color/blue"
app:itemIconSize="@dimen/_24sdp"
app:itemTextAppearance="@style/Theme.DevStoriesAfrica.CustomNavDrawerTextStyle"/>

<item
android:id="@+id/logOut"
android:title="@string/logout_string"
android:icon="@drawable/ic_round_logout_24"
app:itemIconSize="@dimen/_24sdp"
android:iconTint="@color/blue"
app:itemTextAppearance="@style/Theme.DevStoriesAfrica.CustomNavDrawerTextStyle"
/>

</menu>
9 changes: 9 additions & 0 deletions app/src/Admin/res/menu/toolbar_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/logOutAction"
android:title="@string/logout_string"
app:showAsAction="always"
android:icon="@drawable/ic_round_logout_24"/>
</menu>
13 changes: 13 additions & 0 deletions app/src/Admin/res/navigation/nav_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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_menu"
app:startDestination="@id/homeFragment">

<fragment
android:id="@+id/homeFragment"
android:name="com.devstoriesafrica.devstoriesafrica.ui.HomeFragment"
android:label="fragment_home"
tools:layout="@layout/fragment_home" />
</navigation>
7 changes: 6 additions & 1 deletion app/src/Admin/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<resources></resources>
<resources>
<string name="username_placeholder">username</string>
<string name="add_partners_title">Add Partners</string>
<string name="logout_string">Logout</string>
<string name="create_event_txt">Create event</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_add_event_circle_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#4900E1"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM7,7h7v2H7V7zM10,15H7v-2h3V15zM7,12v-2h7v2H7zM19,15h-2v2h-2v-2h-2v-2h2v-2h2v2h2V15z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_nav_menu_icon_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_round_handshake_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#4900E1"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M16.48,10.41c-0.39,0.39 -1.04,0.39 -1.43,0l-4.47,-4.46l-7.05,7.04l-0.66,-0.63c-1.17,-1.17 -1.17,-3.07 0,-4.24l4.24,-4.24c1.17,-1.17 3.07,-1.17 4.24,0L16.48,9C16.87,9.39 16.87,10.02 16.48,10.41zM17.18,8.29c0.78,0.78 0.78,2.05 0,2.83c-1.27,1.27 -2.61,0.22 -2.83,0l-3.76,-3.76l-5.57,5.57c-0.39,0.39 -0.39,1.02 0,1.41c0.39,0.39 1.02,0.39 1.42,0l4.62,-4.62l0.71,0.71l-4.62,4.62c-0.39,0.39 -0.39,1.02 0,1.41c0.39,0.39 1.02,0.39 1.42,0l4.62,-4.62l0.71,0.71l-4.62,4.62c-0.39,0.39 -0.39,1.02 0,1.41c0.39,0.39 1.02,0.39 1.41,0l4.62,-4.62l0.71,0.71l-4.62,4.62c-0.39,0.39 -0.39,1.02 0,1.41c0.39,0.39 1.02,0.39 1.41,0l8.32,-8.34c1.17,-1.17 1.17,-3.07 0,-4.24l-4.24,-4.24c-1.15,-1.15 -3.01,-1.17 -4.18,-0.06L17.18,8.29z"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_round_logout_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M5,5h6c0.55,0 1,-0.45 1,-1v0c0,-0.55 -0.45,-1 -1,-1H5C3.9,3 3,3.9 3,5v14c0,1.1 0.9,2 2,2h6c0.55,0 1,-0.45 1,-1v0c0,-0.55 -0.45,-1 -1,-1H5V5z"/>
<path android:fillColor="@android:color/white" android:pathData="M20.65,11.65l-2.79,-2.79C17.54,8.54 17,8.76 17,9.21V11h-7c-0.55,0 -1,0.45 -1,1v0c0,0.55 0.45,1 1,1h7v1.79c0,0.45 0.54,0.67 0.85,0.35l2.79,-2.79C20.84,12.16 20.84,11.84 20.65,11.65z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_round_person_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#838383"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v1c0,0.55 0.45,1 1,1h14c0.55,0 1,-0.45 1,-1v-1c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="user_app_name">DevStories Africa</string>
<string name="admin_app_name">DevStories Africa Admin</string>
Expand Down Expand Up @@ -32,5 +33,5 @@
<string name="or_sign_up_with">Or sign up with</string>
<string name="or_sign_in_with">Or sign in with</string>
<string name="description_text">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.</string>

<string name="logout_string">Logout</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@
<item name ="android:fontFamily">@font/source_sans_pro</item>
</style>

<style name="Theme.DevStoriesAfrica.CustomNavDrawerTextStyle" parent="TextAppearance.MaterialComponents.Body1">
<item name="android:textSize">@dimen/_20ssp</item>
<item name="android:textColor">@color/black</item>
<item name ="android:fontFamily">@font/source_sans_pro</item>
</style>

<style name="roundedImageViewRounded">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>

</resources>
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c9132ee

Please sign in to comment.