Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Merge branch 'mvp'
Browse files Browse the repository at this point in the history
  • Loading branch information
AnTaif committed Jun 18, 2023
2 parents 7d04c2a + a6e8014 commit f189cb7
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 167 deletions.
35 changes: 17 additions & 18 deletions app/src/main/java/com/example/trackit/data/PreCreatedData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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)
)
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/trackit/data/food/FoodDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<FoodCount>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/example/trackit/ui/food/FoodPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
32 changes: 6 additions & 26 deletions app/src/main/java/com/example/trackit/ui/navigation/AppBars.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -39,13 +40,15 @@ 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
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(
Expand All @@ -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>(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(
Expand Down Expand Up @@ -214,11 +199,6 @@ fun BottomBar(
}
}

sealed class BackPress {
object Idle : BackPress()
object InitialTouch : BackPress()
}

@Composable
fun TopBarWithLabel(
label: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/res/drawable/breakfast_icon_green.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="50"
android:viewportHeight="50">

<path
android:fillColor="#99CD4E"
android:pathData="M26.5,15.25 A1.5,1.5,0,1,0,23.5,15.25 L23.5,16.75 A1.5,1.5,0,1,0,26.5,16.75
L26.5,15.25 Z" />
<path
android:fillColor="#99CD4E"
android:fillType="evenOdd"
android:pathData="M20.542,36.25 L11.5,36.25 A1.5,1.5,0,1,1,11.5,33.25 L17.204,33.25
A9,9,0,1,1,32.795,33.25 L38.5,33.25 A1.5,1.5,0,1,1,38.5,36.25 L20.542,36.25 Z
M25,22.75 A6,6,0,0,0,21.031,33.25 L28.969,33.25 A6,6,0,0,0,25,22.75 Z" />
<path
android:fillColor="#99CD4E"
android:pathData="M35.606,20.265 L34.546,21.325 A1.5,1.5,0,1,1,32.425,19.204 L33.485,18.144
A1.501,1.501,0,0,1,36.065,19.199 A1.501,1.501,0,0,1,35.606,20.265 Z M13,30.25
A1.5,1.5,0,1,0,13,27.25 L11.5,27.25 A1.5,1.5,0,1,0,11.5,30.25 L13,30.25 Z
M40,28.75 A1.5,1.5,0,0,1,38.5,30.25 L37,30.25 A1.5,1.5,0,1,1,37,27.25
L38.5,27.25 A1.5,1.5,0,0,1,40,28.75 Z M15.454,21.325
A1.5,1.5,0,0,0,17.575,19.204 L16.515,18.144 A1.499,1.499,0,1,0,14.395,20.264
L15.454,21.325 Z" />
</vector>
26 changes: 8 additions & 18 deletions app/src/main/res/drawable/count_gr.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="171dp"
android:height="48dp"
android:viewportWidth="171"
android:viewportHeight="48"
>
<group>
<clip-path
android:pathData="M20 0H151C162.046 0 171 8.95431 171 20V28C171 39.0457 162.046 48 151 48H20C8.95431 48 0 39.0457 0 28V20C0 8.95431 8.95431 0 20 0Z"
/>
<path
android:pathData="M0 0V48H171V0"
android:fillColor="#FFFFFF"
/>
</group>
</vector>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners
android:topLeftRadius="40dp"
android:topRightRadius="40dp"
android:bottomLeftRadius="40dp"
android:bottomRightRadius="40dp" />
</shape>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/dinner_icon_green.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="50"
android:viewportHeight="50">

<path
android:fillColor="#99CD4E"
android:strokeColor="#99CD4E"
android:strokeWidth=".5"
android:pathData="M40 30.454a1.364 1.364 0 0 1-1.364 1.364H11.364a1.364 1.364 0 0 1 0-2.727h27.272A1.364 1.364 0 0 1 40 30.454zm-6.818 4.091H16.818a1.364 1.364 0 0 0 0 2.728h16.364a1.364 1.364 0 1 0 0-2.728zM12.727 25a1.363 1.363 0 1 0 2.727 0 9.546 9.546 0 0 1 19.091 0 1.363 1.363 0 1 0 2.728 0 12.272 12.272 0 1 0-24.546 0z" />
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/lunch_icon_green.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="50"
android:viewportHeight="50">

<path
android:fillColor="#99CD4E"
android:strokeColor="#99CD4E"
android:strokeWidth=".7"
android:pathData="M25 33.625A8.625 8.625 0 1 1 33.625 25 8.639 8.639 0 0 1 25 33.625zm0-15A6.375 6.375 0 1 0 31.375 25 6.39 6.39 0 0 0 25 18.625zM25 14.5a1.14 1.14 0 0 1-1.125-1.125v-2.25a1.125 1.125 0 1 1 2.25 0v2.25A1.14 1.14 0 0 1 25 14.5zM25 40a1.14 1.14 0 0 1-1.125-1.125v-2.25a1.125 1.125 0 1 1 2.25 0v2.25A1.14 1.14 0 0 1 25 40zM38.875 26.125h-2.25a1.124 1.124 0 1 1 0-2.25h2.25a1.125 1.125 0 1 1 0 2.25zM13.375 26.125h-2.25a1.125 1.125 0 1 1 0-2.25h2.25a1.125 1.125 0 1 1 0 2.25zM16.75 17.875A1.11 1.11 0 0 1 16 17.5L14.365 16A1.155 1.155 0 1 1 16 14.365L17.5 16a1.125 1.125 0 0 1 0 1.5 1.11 1.11 0 0 1-0.75 0.375 zM34.84 35.965a1.112 1.112 0 0 1-0.795-0.33L32.5 34a1.126 1.126 0 0 1 1.5-1.5l1.635 1.5a1.124 1.124 0 0 1 0 1.59 1.111 1.111 0 0 1-0.795 0.375 zM33.25 17.875a1.11 1.11 0 0 1-0.75-0.375 1.125 1.125 0 0 1 0-1.5l1.5-1.635A1.156 1.156 0 1 1 35.635 16L34 17.5a1.11 1.11 0 0 1-0.75 0.375 zM15.16 35.965a1.11 1.11 0 0 1-0.795-0.33 1.125 1.125 0 0 1 0-1.59L16 32.5a1.124 1.124 0 0 1 1.5 1.5L16 35.635a1.112 1.112 0 0 1-0.84 0.33 z" />
</vector>
25 changes: 8 additions & 17 deletions app/src/main/res/drawable/pfc.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="273dp"
android:height="48dp"
android:viewportWidth="273"
android:viewportHeight="48"
>
<group>
<clip-path
android:pathData="M20 0H253C264.046 0 273 8.95431 273 20V28C273 39.0457 264.046 48 253 48H20C8.95431 48 0 39.0457 0 28V20C0 8.95431 8.95431 0 20 0Z"
/>
<path
android:pathData="M0 0V48H273V0"
android:fillColor="#FFFFFF"
/>
</group>
</vector>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners
android:topLeftRadius="20dp"
android:topRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp" />
</shape>
19 changes: 0 additions & 19 deletions app/src/main/res/drawable/pfc2.xml

This file was deleted.

Loading

0 comments on commit f189cb7

Please sign in to comment.