diff --git a/app/src/main/java/com/example/trackit/data/PreCreatedData.kt b/app/src/main/java/com/example/trackit/data/PreCreatedData.kt index 5d919b0..ac7699a 100644 --- a/app/src/main/java/com/example/trackit/data/PreCreatedData.kt +++ b/app/src/main/java/com/example/trackit/data/PreCreatedData.kt @@ -317,15 +317,15 @@ val PreCreatedFoodList = mutableListOf( FoodData(generateUniqueID(),"Сливки 20%",2.8,20.0,3.6,205.0,100), FoodData(generateUniqueID(),"Сметана 10%",3.0,10.0,2.9,116.0,100), FoodData(generateUniqueID(),"Сметана 20%",2.8,20.0,3.2,206.0,100), - FoodData(generateUniqueID(),"Сырки и масса творожные особые",7.1,23.0,27.5,340.0,100), - FoodData(generateUniqueID(),"Сыр российский",25.0,7.0,0.0,170.0,100), - FoodData(generateUniqueID(),"Сыр голландский",23.4,30.0,0.0,371.0,100), - FoodData(generateUniqueID(),"Сыр плавленный",24.0,13.5,0.0,226.0,100), + FoodData(generateUniqueID(),"Сырки и масса творожные",7.1,23.0,27.5,340.0,100), + FoodData(generateUniqueID(),"Сыр\nроссийский",25.0,7.0,0.0,170.0,100), + FoodData(generateUniqueID(),"Сыр\nголландский",23.4,30.0,0.0,371.0,100), + FoodData(generateUniqueID(),"Сыр\nплавленный",24.0,13.5,0.0,226.0,100), FoodData(generateUniqueID(),"Творог жирный",14.0,18.0,1.3,226.0,100), - FoodData(generateUniqueID(),"Творог полужирный",16.7,9.0,1.3,156.0,100), + FoodData(generateUniqueID(),"Творог\nполужирный",16.7,9.0,1.3,156.0,100), FoodData(generateUniqueID(),"Творог нежирный",18.0,0.6,1.5,86.0,100), FoodData(generateUniqueID(),"Хлеб ржаной",4.7,0.7,49.8,214.0,100), - FoodData(generateUniqueID(),"Хлеб пшеничный из муки I сорта",7.7,2.4,53.4,254.0,100), + FoodData(generateUniqueID(),"Хлеб пшеничный",7.7,2.4,53.4,254.0,100), FoodData(generateUniqueID(),"Сдобная выпечка",7.6,4.5,60.0,297.0,100), FoodData(generateUniqueID(),"Баранки",10.4,1.3,68.7,312.0,100), FoodData(generateUniqueID(),"Сушки",11.0,1.3,73.0,330.0,100), @@ -362,8 +362,8 @@ val PreCreatedFoodList = mutableListOf( FoodData(generateUniqueID(),"Репа",1.5,0.0,5.9,28.0,100), FoodData(generateUniqueID(),"Салат",1.5,0.0,2.2,14.0,100), FoodData(generateUniqueID(),"Свекла",1.7,0.0,10.8,48.0,100), - FoodData(generateUniqueID(),"Томаты (грунтовые)",0.6,0.0,4.2,19.0,100), - FoodData(generateUniqueID(),"Томаты (парниковые)",0.6,0.0,2.9,14.0,100), + FoodData(generateUniqueID(),"Томаты грунтовые",0.6,0.0,4.2,19.0,100), + FoodData(generateUniqueID(),"Томаты\nпарниковые",0.6,0.0,2.9,14.0,100), FoodData(generateUniqueID(),"Зеленая фасоль (стручок)",4.0,0.0,4.3,32.0,100), FoodData(generateUniqueID(),"Хрен",2.5,0.0,16.3,71.0,100), FoodData(generateUniqueID(),"Черемша",2.4,0.0,6.5,34.0,100), @@ -411,7 +411,6 @@ val PreCreatedFoodList = mutableListOf( FoodData(generateUniqueID(),"Груша",2.3,0.0,62.1,246.0,100), FoodData(generateUniqueID(),"Персики",3.0,0.0,68.5,275.0,100), FoodData(generateUniqueID(),"Чернослив",2.3,0.0,65.6,264.0,100), - FoodData(generateUniqueID(),"Яблоко",3.2,0.0,68.0,273.0,100), FoodData(generateUniqueID(),"Урюк",5.0,0.0,67.5,278.0,100), FoodData(generateUniqueID(),"Курага",5.2,0.0,65.9,272.0,100), FoodData(generateUniqueID(),"Изюм с косточкой",1.8,0.0,70.9,276.0,100), @@ -425,7 +424,7 @@ val PreCreatedFoodList = mutableListOf( FoodData(generateUniqueID(),"Яичный порошок",45.0,37.3,7.1,542.0,100), FoodData(generateUniqueID(),"Сухой белок",73.3,1.8,7.0,336.0,100), FoodData(generateUniqueID(),"Сухой желток",34.2,52.2,4.4,623.0,100), - FoodData(generateUniqueID(),"Яйцо перепелиное",11.9,13.1,0.6,168.0,100), + FoodData(generateUniqueID(),"Яйцо\nперепелиное",11.9,13.1,0.6,168.0,100), FoodData(generateUniqueID(),"Камбала",16.1,2.6,0.0,88.0,100), FoodData(generateUniqueID(),"Карась",17.7,1.8,0.0,87.0,100), FoodData(generateUniqueID(),"Карп",16.0,3.6,0.0,96.0,100), @@ -494,18 +493,18 @@ val PreCreatedFoodList = mutableListOf( FoodData(generateUniqueID(),"Курица",20.8,8.8,0.6,165.0,100), FoodData(generateUniqueID(),"Цыплята",18.7,7.8,0.4,156.0,100), FoodData(generateUniqueID(),"Утка",16.5,61.2,0.0,346.0,100), - FoodData(generateUniqueID(),"Вареная колбаса Диабетическая",12.1,22.8,0.0,254.0,100), - FoodData(generateUniqueID(),"Вареная колбаса Диетическая",12.1,13.5,0.0,170.0,100), - FoodData(generateUniqueID(),"Вареная колбаса Докторская",13.7,22.8,0.0,260.0,100), + FoodData(generateUniqueID(),"Вареная колбаса\nДиабет.",12.1,22.8,0.0,254.0,100), + FoodData(generateUniqueID(),"Вареная колбаса\nДиетическая",12.1,13.5,0.0,170.0,100), + FoodData(generateUniqueID(),"Вареная колбаса\nДокторская",13.7,22.8,0.0,260.0,100), FoodData(generateUniqueID(),"Вареная колбаса Молочная",11.7,22.8,0.0,252.0,100), FoodData(generateUniqueID(),"Сосиски Молочные",12.3,25.3,0.0,277.0,100), - FoodData(generateUniqueID(),"Варено-\nкопченая Любительская",17.3,39.0,0.0,420.0,100), + FoodData(generateUniqueID(),"Варено-\nкопченая\nЛюбительская",17.3,39.0,0.0,420.0,100), FoodData(generateUniqueID(),"Варено-\nкопченая Сервелат",28.2,27.5,0.0,360.0,100), - FoodData(generateUniqueID(),"Полукопченая Краковская",16.2,44.6,0.0,466.0,100), - FoodData(generateUniqueID(),"Полукопченая Полтавская",16.4,39.0,0.0,417.0,100), + FoodData(generateUniqueID(),"Полукопченая\nКраковская",16.2,44.6,0.0,466.0,100), + FoodData(generateUniqueID(),"Полукопченая\nПолтавская",16.4,39.0,0.0,417.0,100), FoodData(generateUniqueID(),"Грибы белые свежие",3.2,0.7,1.6,25.0,100), FoodData(generateUniqueID(),"Грибы белые сушеные",27.6,6.8,10.0,209.0,100), - FoodData(generateUniqueID(),"Подберезовики свежие",2.3,0.9,3.7,31.0,100), - FoodData(generateUniqueID(),"Подосиновики свежие",3.3,0.5,3.4,31.0,100), + FoodData(generateUniqueID(),"Подберезовики\nсвежие",2.3,0.9,3.7,31.0,100), + FoodData(generateUniqueID(),"Подосиновики\nсвежие",3.3,0.5,3.4,31.0,100), FoodData(generateUniqueID(),"Сыроежки свежие",1.7,0.3,1.4,17.0,100) ) \ No newline at end of file diff --git a/app/src/main/java/com/example/trackit/data/food/FoodDao.kt b/app/src/main/java/com/example/trackit/data/food/FoodDao.kt index b064fb5..6a0fbfd 100644 --- a/app/src/main/java/com/example/trackit/data/food/FoodDao.kt +++ b/app/src/main/java/com/example/trackit/data/food/FoodDao.kt @@ -126,9 +126,9 @@ interface TotalDao { "SELECT foodDinner AS food FROM dinner " + "UNION ALL " + "SELECT foodSnack AS food FROM snack " + - ") " + + ") AS food " + "GROUP BY food " + - "ORDER BY count DESC " + + "ORDER BY food ASC, count DESC " + "LIMIT 1" ) fun getPop(): Flow diff --git a/app/src/main/java/com/example/trackit/ui/food/FoodPage.kt b/app/src/main/java/com/example/trackit/ui/food/FoodPage.kt index 32a5dfa..7eaea8a 100644 --- a/app/src/main/java/com/example/trackit/ui/food/FoodPage.kt +++ b/app/src/main/java/com/example/trackit/ui/food/FoodPage.kt @@ -208,7 +208,7 @@ fun FoodPage( Spacer(modifier = Modifier.padding(20.dp)) MealPanel( mealType = "Завтрак", - mealIcon = R.drawable.breakfast_icon, + mealIcon = if (breakfastUiState.breakfastList.isNotEmpty()) R.drawable.breakfast_icon_green else R.drawable.breakfast_icon, foods = breakfastUiState.breakfastList, isExpanded = breakfastExpanded, onPanelClicked = { breakfastExpanded = !breakfastExpanded }, @@ -237,7 +237,7 @@ fun FoodPage( item { MealPanel( mealType = "Обед", - mealIcon = R.drawable.lunch_icon, + mealIcon = if (lunchUiState.lunchList.isNotEmpty()) R.drawable.lunch_icon_green else R.drawable.lunch_icon, foods = lunchUiState.lunchList, isExpanded = lunchExpanded, onPanelClicked = { lunchExpanded = !lunchExpanded }, @@ -266,7 +266,7 @@ fun FoodPage( item { MealPanel( mealType = "Ужин", - mealIcon = R.drawable.dinner_icon, + mealIcon = if (dinnerUiState.dinnerList.isNotEmpty()) R.drawable.dinner_icon_green else R.drawable.dinner_icon, foods = dinnerUiState.dinnerList, isExpanded = dinnerExpanded, onPanelClicked = { dinnerExpanded = !dinnerExpanded }, @@ -295,7 +295,7 @@ fun FoodPage( item { MealPanel( mealType = "Перекус", - mealIcon = R.drawable.snack_icon, + mealIcon = if (snackUiState.snackList.isNotEmpty()) R.drawable.snack_icon_green else R.drawable.snack_icon, foods = snackUiState.snackList, isExpanded = snackExpanded, onPanelClicked = { snackExpanded = !snackExpanded }, diff --git a/app/src/main/java/com/example/trackit/ui/navigation/AppBars.kt b/app/src/main/java/com/example/trackit/ui/navigation/AppBars.kt index d9913df..ef3a88b 100644 --- a/app/src/main/java/com/example/trackit/ui/navigation/AppBars.kt +++ b/app/src/main/java/com/example/trackit/ui/navigation/AppBars.kt @@ -1,5 +1,6 @@ package com.example.trackit.ui.navigation +import android.app.Activity import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.annotation.DrawableRes @@ -39,6 +40,7 @@ import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.core.app.ActivityCompat import androidx.navigation.NavController import com.example.trackit.R import com.example.trackit.calendar.ExpandableCalendar @@ -46,6 +48,7 @@ import com.example.trackit.data.Screen import com.example.trackit.ui.theme.* import kotlinx.coroutines.delay import java.time.LocalDate +import kotlin.system.exitProcess @Composable fun BottomBar( @@ -59,28 +62,10 @@ fun BottomBar( mutableStateOf(false) } - var showToast by remember { mutableStateOf(false) } + val activity = (LocalContext.current as? Activity) - var backPressState by remember { mutableStateOf(BackPress.Idle) } - val context = LocalContext.current - - if(showToast){ - Toast.makeText(context, "Нажмите еще раз для выхода", Toast.LENGTH_SHORT).show() - showToast= false - } - - LaunchedEffect(key1 = backPressState) { - if (backPressState == BackPress.InitialTouch) { - delay(2000) - backPressState = BackPress.Idle - } - } - - if (barState){ - BackHandler(backPressState == BackPress.Idle) { - backPressState = BackPress.InitialTouch - showToast = true - } + BackHandler(barState) { + activity?.finishAffinity() } AnimatedVisibility( @@ -214,11 +199,6 @@ fun BottomBar( } } -sealed class BackPress { - object Idle : BackPress() - object InitialTouch : BackPress() -} - @Composable fun TopBarWithLabel( label: String, diff --git a/app/src/main/java/com/example/trackit/ui/welcome/WelcomeScreen.kt b/app/src/main/java/com/example/trackit/ui/welcome/WelcomeScreen.kt index b8dd796..d861061 100644 --- a/app/src/main/java/com/example/trackit/ui/welcome/WelcomeScreen.kt +++ b/app/src/main/java/com/example/trackit/ui/welcome/WelcomeScreen.kt @@ -1,5 +1,6 @@ package com.example.trackit.ui.welcome +import android.app.Activity import android.content.Context import android.content.Intent import android.widget.Toast @@ -80,15 +81,15 @@ fun WelcomeScreen( onClick = { currentPage.value = getNextPage(currentPage.value) } - enabled = selectedAge.value.text.isNotBlank() && selectedAge.value.text.toInt() < 123 - toastText = "Введите ваш возраст" + enabled = selectedAge.value.text.isNotBlank() && selectedAge.value.text.toIntOrNull() != null && selectedAge.value.text.toIntOrNull()!! < 123 + toastText = if (selectedAge.value.text.toIntOrNull() != null) "Введите ваш возраст" else "Введите целое значение" } WelcomePage.Height -> { onClick = { currentPage.value = getNextPage(currentPage.value) } - enabled = selectedHeight.value.text.isNotBlank() && selectedHeight.value.text.toInt() < 300 - toastText = "Введите ваш рост" + enabled = selectedHeight.value.text.isNotBlank() && selectedHeight.value.text.toIntOrNull() != null && selectedHeight.value.text.toIntOrNull()!! < 300 + toastText = if (selectedHeight.value.text.toIntOrNull() != null) "Введите ваш рост" else "Введите целое значение" } WelcomePage.Weight -> { onClick = { diff --git a/app/src/main/res/drawable/breakfast_icon_green.xml b/app/src/main/res/drawable/breakfast_icon_green.xml new file mode 100644 index 0000000..5758a20 --- /dev/null +++ b/app/src/main/res/drawable/breakfast_icon_green.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/count_gr.xml b/app/src/main/res/drawable/count_gr.xml index 7af8993..87ab177 100644 --- a/app/src/main/res/drawable/count_gr.xml +++ b/app/src/main/res/drawable/count_gr.xml @@ -1,19 +1,9 @@ - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dinner_icon_green.xml b/app/src/main/res/drawable/dinner_icon_green.xml new file mode 100644 index 0000000..014523f --- /dev/null +++ b/app/src/main/res/drawable/dinner_icon_green.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/lunch_icon_green.xml b/app/src/main/res/drawable/lunch_icon_green.xml new file mode 100644 index 0000000..10b40ff --- /dev/null +++ b/app/src/main/res/drawable/lunch_icon_green.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/pfc.xml b/app/src/main/res/drawable/pfc.xml index fad3255..885dd70 100644 --- a/app/src/main/res/drawable/pfc.xml +++ b/app/src/main/res/drawable/pfc.xml @@ -1,18 +1,9 @@ - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/pfc2.xml b/app/src/main/res/drawable/pfc2.xml deleted file mode 100644 index 7bbcecc..0000000 --- a/app/src/main/res/drawable/pfc2.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/snack_icon_green.xml b/app/src/main/res/drawable/snack_icon_green.xml new file mode 100644 index 0000000..95c2312 --- /dev/null +++ b/app/src/main/res/drawable/snack_icon_green.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/add_food_to_main.xml b/app/src/main/res/layout/add_food_to_main.xml index d6a8e16..7e104ac 100644 --- a/app/src/main/res/layout/add_food_to_main.xml +++ b/app/src/main/res/layout/add_food_to_main.xml @@ -1,6 +1,7 @@ + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:orientation="horizontal" + tools:ignore="UselessParent"> @@ -131,26 +133,27 @@ + android:layout_width="100dp" + android:layout_height="wrap_content" + android:layout_marginStart="6dp" + android:fontFamily="sans-serif-medium" + android:textStyle="normal" + android:textSize="16sp" + android:textColor="#3B4446" + android:layout_gravity="center" + android:text="Названиe"/> + android:textSize="16sp" + android:textColor="#3b4446" + android:textAlignment="center" + android:layout_gravity="center" + android:text="Жир" + android:layout_weight="1"/> + android:textSize="16sp" + android:textColor="#3b4446" + android:textAlignment="center" + android:layout_gravity="center" + android:text="Угл" + android:layout_weight="1" /> + android:textSize="16sp" + android:textColor="#3b4446" + android:textAlignment="center" + android:layout_gravity="center" + android:text="Ккал" + android:layout_weight="1"/> @@ -201,7 +203,8 @@ android:layout_height="48dp" android:background="@drawable/count_gr" android:layout_marginTop="12dp" - android:layout_gravity="center"> + android:layout_gravity="center" + android:elevation="4dp"> @@ -271,9 +274,8 @@ diff --git a/app/src/main/res/layout/dialog_add_food.xml b/app/src/main/res/layout/dialog_add_food.xml index 09ca14d..6244497 100644 --- a/app/src/main/res/layout/dialog_add_food.xml +++ b/app/src/main/res/layout/dialog_add_food.xml @@ -114,22 +114,22 @@ @@ -265,14 +263,14 @@ @@ -294,7 +292,6 @@ android:layout_width="134dp" android:layout_height="40dp" android:layout_marginStart="5dp" - android:layout_marginTop="15dp" android:background="@drawable/back_button" android:elevation="4dp">