diff --git a/.idea/misc.xml b/.idea/misc.xml index ac801d8..f478693 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,7 @@ + - + \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt b/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt new file mode 100644 index 0000000..259ce5b --- /dev/null +++ b/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt @@ -0,0 +1,17 @@ +package com.example.shawarma.screens.cart + +import androidx.compose.foundation.layout.Box +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment + +@Composable +fun CartScreen() { + Box( + contentAlignment = Alignment.Center + ) { + Text( + text = "Cart" + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/screens/discount/DiscountScreen.kt b/app/src/main/java/com/example/shawarma/screens/discount/DiscountScreen.kt new file mode 100644 index 0000000..1d34053 --- /dev/null +++ b/app/src/main/java/com/example/shawarma/screens/discount/DiscountScreen.kt @@ -0,0 +1,17 @@ +package com.example.shawarma.screens.discount + +import androidx.compose.foundation.layout.Box +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment + +@Composable +fun DiscountScreen() { + Box( + contentAlignment = Alignment.Center + ) { + Text( + text = "Discount" + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/screens/home/HomeScreen.kt b/app/src/main/java/com/example/shawarma/screens/home/HomeScreen.kt new file mode 100644 index 0000000..916c8a7 --- /dev/null +++ b/app/src/main/java/com/example/shawarma/screens/home/HomeScreen.kt @@ -0,0 +1,17 @@ +package com.example.shawarma.screens.home + +import androidx.compose.foundation.layout.Box +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment + +@Composable +fun HomeScreen() { + Box( + contentAlignment = Alignment.Center + ) { + Text( + text = "Home" + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/utils/BottomNavItem.kt b/app/src/main/java/com/example/shawarma/utils/BottomNavItem.kt new file mode 100644 index 0000000..824d1ff --- /dev/null +++ b/app/src/main/java/com/example/shawarma/utils/BottomNavItem.kt @@ -0,0 +1,9 @@ +package com.example.shawarma.utils + +import com.example.shawarma.R + +sealed class BottomNavItem(var title:String, var icon:Int, var screen_route:String) { + object Home : BottomNavItem("Home", R.drawable.home_icon,ScreenPaths.home.name) + object Discount : BottomNavItem("Discount", R.drawable.discount_icon,ScreenPaths.discount.name) + object Cart : BottomNavItem("Cart", R.drawable.cart_icon,ScreenPaths.cart.name) +} diff --git a/app/src/main/java/com/example/shawarma/utils/ScreenPaths.kt b/app/src/main/java/com/example/shawarma/utils/ScreenPaths.kt index 846583b..f1561fb 100644 --- a/app/src/main/java/com/example/shawarma/utils/ScreenPaths.kt +++ b/app/src/main/java/com/example/shawarma/utils/ScreenPaths.kt @@ -1,5 +1,5 @@ package com.example.shawarma.utils enum class ScreenPaths { - authorization, registration + authorization, registration, home, discount, cart, orders } \ No newline at end of file diff --git a/app/src/main/java/com/example/shawarma/widgets/BottomNavBar.kt b/app/src/main/java/com/example/shawarma/widgets/BottomNavBar.kt new file mode 100644 index 0000000..5efde53 --- /dev/null +++ b/app/src/main/java/com/example/shawarma/widgets/BottomNavBar.kt @@ -0,0 +1,56 @@ +package com.example.shawarma.widgets + +import androidx.compose.material.BottomNavigation +import androidx.compose.material.BottomNavigationItem +import androidx.compose.material.Icon +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import androidx.navigation.compose.currentBackStackEntryAsState +import com.example.shawarma.utils.BottomNavItem + +@Composable +fun BottomNavBar(navController: NavController) { + val items = listOf( + BottomNavItem.Home, + BottomNavItem.Discount, + BottomNavItem.Cart, + ) + BottomNavigation( + backgroundColor = Color.Green, + contentColor = Color.Cyan + + ) { + val navBackStackEntry by navController.currentBackStackEntryAsState() + val currentRoute = navBackStackEntry?.destination?.route + items.forEach { item -> + BottomNavigationItem( + icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) }, + label = { + Text( + text = item.title, + fontSize = 9.sp + ) }, + selectedContentColor = Color.Black, + unselectedContentColor = Color.Black.copy(0.4f), + alwaysShowLabel = true, + selected = currentRoute == item.screen_route, + onClick = { + navController.navigate(item.screen_route) { + navController.graph.startDestinationRoute?.let { screen_route -> + popUpTo(screen_route) { + saveState = true + } + } + launchSingleTop = true + restoreState = true + } + } + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/cart_icon.png b/app/src/main/res/drawable/cart_icon.png new file mode 100644 index 0000000..4701d9f Binary files /dev/null and b/app/src/main/res/drawable/cart_icon.png differ diff --git a/app/src/main/res/drawable/discount_icon.png b/app/src/main/res/drawable/discount_icon.png new file mode 100644 index 0000000..284239e Binary files /dev/null and b/app/src/main/res/drawable/discount_icon.png differ diff --git a/app/src/main/res/drawable/home_icon.png b/app/src/main/res/drawable/home_icon.png new file mode 100644 index 0000000..096a0c0 Binary files /dev/null and b/app/src/main/res/drawable/home_icon.png differ diff --git a/build.gradle b/build.gradle index 9b762dd..44023d2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,15 @@ buildscript { ext { compose_ui_version = '1.2.0' } + repositories { + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.0.0' + } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.1.1' apply false - id 'com.android.library' version '8.1.1' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false id 'org.jetbrains.kotlin.android' version '1.7.0' apply false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f2b979f..aa511e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,4 +23,5 @@ kotlin.code.style=official android.nonTransitiveRClass=true android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false -org.gradle.unsafe.configuration-cache=true \ No newline at end of file +org.gradle.unsafe.configuration-cache=true +android.suppressUnsupportedCompileSdk=34 \ No newline at end of file