Skip to content

Commit

Permalink
Side Navigation + New App Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
whyfoo committed Dec 16, 2021
1 parent 42cfed7 commit 25c9773
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 26 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<activity
android:name=".ui.profile.ProfileActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
<activity android:name=".ui.home.HomeFailedActivity" />
<activity android:name=".ui.home.HomeSuccessActivity" />
<activity android:name=".ui.home.HomeActivity" />
<activity
android:name=".ui.home.HomeActivity"
android:theme="@style/Theme.Trolleapp.noActionBar"/>
<activity
android:name=".ui.signup.SignUpActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
Expand Down
19 changes: 9 additions & 10 deletions app/src/main/java/com/trolle/trolleapp/ui/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ class HomeActivity : AppCompatActivity() {
binding = ActivityHomeBinding.inflate(layoutInflater)
setContentView(binding.root)

supportActionBar?.apply {
setDisplayShowHomeEnabled(true)
setHomeButtonEnabled(true)
setDisplayUseLogoEnabled(true)
setLogo(R.drawable.menglogo)
binding.topAppBar.setNavigationOnClickListener{
binding.drawerLayout.open()
}

binding.navigationView.setNavigationItemSelectedListener { menuItem ->
// Handle menu item selected
menuItem.isChecked = true
binding.drawerLayout.close()
true
}

val navHostFragment =
Expand All @@ -40,11 +44,6 @@ class HomeActivity : AppCompatActivity() {
binding.bottomNavigation.setupWithNavController(navController)
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.navigation_drawer, menu)
return super.onCreateOptionsMenu(menu)
}

override fun onBackPressed() {
if (backPressed) {
super.onBackPressed()
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_menu_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFB7C3"
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>
Binary file modified app/src/main/res/drawable/menglogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 64 additions & 9 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,72 @@
android:background="@color/bgc"
tools:context=".ui.home.HomeActivity">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph" />
tools:openDrawer="start">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.AppBarLayout.PrimarySurface"
android:fitsSystemWindows="true">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="@drawable/ic_menu_24dp"
style="@style/Widget.MaterialComponents.Toolbar.PrimarySurface"
android:background="@android:color/transparent"
android:elevation="0dp" />

<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/menglogo"/>

</FrameLayout>

</com.google.android.material.appbar.AppBarLayout>

<!-- Screen content -->
<!-- Use app:layout_behavior="@string/appbar_scrolling_view_behavior" to fit below top app bar -->
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph"/>


</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:background="@color/pink"
app:menu="@menu/navigation_drawer"/>

</androidx.drawerlayout.widget.DrawerLayout>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/activity_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,14 @@
android:id="@+id/text_view_forget_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/forget_password"
android:textSize="14sp"
android:layout_marginTop="5dp"
android:textColor="@color/pink"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:layout_width="match_parent"
Expand Down

0 comments on commit 25c9773

Please sign in to comment.