This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.room.* | |
| import kotlinx.coroutines.flow.Flow | |
| @Dao | |
| interface UserDao { | |
| @Insert(onConflict = OnConflictStrategy.REPLACE) | |
| suspend fun insertUser(user: User)//cохранение нового пользователя | |
| @Query("SELECT EXISTS(SELECT * FROM users WHERE login = :login)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.room.Entity | |
| import androidx.room.PrimaryKey | |
| @Entity(tableName = "users")//превращает класс в таблицу | |
| data class User ( | |
| @PrimaryKey(autoGenerate = true) val id: Int = 0,//индентификатор для каждой строки | |
| val password: String,//пароль | |
| val firstName: String? = null,//имя |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.lifecycle.ViewModel | |
| import androidx.lifecycle.viewModelScope | |
| import kotlinx.coroutines.flow.SharingStarted | |
| import kotlinx.coroutines.flow.StateFlow | |
| import kotlinx.coroutines.flow.map | |
| import kotlinx.coroutines.flow.stateIn | |
| import kotlinx.coroutines.launch | |
| import java.util.Calendar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.room.Dao | |
| import androidx.room.Delete | |
| import androidx.room.Insert | |
| import androidx.room.Query | |
| import kotlinx.coroutines.flow.Flow | |
| @Dao | |
| interface GoalDao { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.room.Entity | |
| import androidx.room.PrimaryKey | |
| @Entity(tableName = "goals") | |
| data class Goal( | |
| @PrimaryKey(autoGenerate = true) val id: Int = 0, | |
| val userLogin: String,//привязка к пользователю | |
| val title: String,//название цели |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.* | |
| import androidx.compose.foundation.shape.RoundedCornerShape | |
| import androidx.compose.material3.Text | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.ui.Alignment | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.graphics.Color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import android.content.Context | |
| import androidx.room.Database | |
| import androidx.room.Room | |
| import androidx.room.RoomDatabase | |
| @Database(entities = [User::class, Transaction::class, Goal::class], version = 4) | |
| abstract class AppDatabase : RoomDatabase() { | |
| abstract fun userDao(): UserDao |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import com.example.spendly1.Transaction | |
| import com.example.spendly1.CategorySum | |
| import androidx.room.Dao | |
| import androidx.room.Delete | |
| import androidx.room.Insert | |
| import androidx.room.Query | |
| import kotlinx.coroutines.flow.Flow | |
| @Dao |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.room.Entity | |
| import androidx.room.PrimaryKey | |
| @Entity(tableName = "transactions")//бд | |
| data class Transaction( | |
| @PrimaryKey(autoGenerate = true) val id : Int = 0,//присваивание новой записи ID | |
| val userLogin: String,//логин | |
| val title: String,//название |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.spendly1 | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.* | |
| import androidx.compose.material.icons.Icons | |
| import androidx.compose.material.icons.filled.ArrowBack | |
| import androidx.compose.material3.* | |
| import androidx.compose.runtime.* | |
| import androidx.compose.ui.Alignment | |
| import androidx.compose.ui.Modifier |
NewerOlder