Skip to content

Commit

Permalink
Merge pull request #18 from OhhTuRnz/feature_listMenu
Browse files Browse the repository at this point in the history
Finished display of bottom menu. Working on how to integrate it
  • Loading branch information
OhhTuRnz authored Mar 11, 2024
2 parents 3d8f699 + fbf2460 commit 3212429
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
implementation("com.google.code.gson:gson:2.10")
implementation("androidx.test:core-ktx:1.5.0")
implementation("androidx.room:room-ktx:2.6.1")
implementation("com.google.android.material:material:1.11.0")
kapt("androidx.room:room-compiler:2.6.1")
annotationProcessor("com.github.bumptech.glide:compiler:4.12.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.drawerlayout.widget.DrawerLayout
import com.bumptech.glide.Glide
import com.example.mad_2024_app.R
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationView


Expand All @@ -36,7 +37,6 @@ class MainActivity : AppCompatActivity(), LocationListener {
private lateinit var requestPermissionLauncher: ActivityResultLauncher<Array<String>>
private lateinit var toggle: ActionBarDrawerToggle

private val locationPermissionCode = 2
private val TAG = "LogoGPSMainActivity"

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -48,7 +48,9 @@ class MainActivity : AppCompatActivity(), LocationListener {

setContentView(R.layout.activity_main)

toggleDrawer()
setupDrawer()

setupBottomNav()

createUUID(sharedPreferences)

Expand Down Expand Up @@ -130,7 +132,31 @@ class MainActivity : AppCompatActivity(), LocationListener {
}
}

private fun toggleDrawer(){
private fun setupBottomNav() {
val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_navigation)

bottomNav.setOnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.nav_favorites -> {
// Handle favorites action
true
}

R.id.nav_maps -> {
// Handle maps action
true
}

R.id.nav_donuts -> {
// Handle nearby donuts action
true
}

else -> false
}
}
}
private fun setupDrawer(){
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view_drawer)

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_favorite_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#CE93D8"
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.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>
Binary file added app/src/main/res/drawable/donut_icon_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/donut_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@
android:layout_centerHorizontal="true"
android:layout_above="@id/mainButton" />

</RelativeLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_menu" />

</RelativeLayout>
<!-- NavigationView for the drawer -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view_drawer"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:id="@+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/donut_2"
android:src="@drawable/donut_icon_1"
android:scaleType="centerCrop"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"/>
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/menu/bottom_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_favorites"
android:icon="@drawable/baseline_favorite_24"
android:title=""/>
<item
android:id="@+id/nav_maps"
android:icon="@drawable/map_menu"
android:title="" />
<item
android:id="@+id/nav_donuts"
android:icon="@drawable/donut_menu"
android:title=""/>
</menu>

0 comments on commit 3212429

Please sign in to comment.