diff --git a/app/src/main/java/com/example/mobile_labs/TheatreApplication.kt b/app/src/main/java/com/example/mobile_labs/TheatreApplication.kt index 629d5f8..0ee387f 100644 --- a/app/src/main/java/com/example/mobile_labs/TheatreApplication.kt +++ b/app/src/main/java/com/example/mobile_labs/TheatreApplication.kt @@ -1,8 +1,8 @@ package com.example.mobile_labs import android.app.Application -import com.example.mobile_labs.database.AppContainer -import com.example.mobile_labs.database.AppDataContainer +import com.example.mobile_labs.common.AppContainer +import com.example.mobile_labs.common.AppDataContainer class TheatreApplication : Application() { lateinit var container: AppContainer diff --git a/app/src/main/java/com/example/mobile_labs/database/AppContainer.kt b/app/src/main/java/com/example/mobile_labs/common/AppContainer.kt similarity index 84% rename from app/src/main/java/com/example/mobile_labs/database/AppContainer.kt rename to app/src/main/java/com/example/mobile_labs/common/AppContainer.kt index 0e51cc8..872b32c 100644 --- a/app/src/main/java/com/example/mobile_labs/database/AppContainer.kt +++ b/app/src/main/java/com/example/mobile_labs/common/AppContainer.kt @@ -1,12 +1,11 @@ -package com.example.mobile_labs.database +package com.example.mobile_labs.common import android.content.Context import com.example.mobile_labs.database.event.repository.EventRepository import com.example.mobile_labs.database.event.repository.OfflineEventRepository import com.example.mobile_labs.database.performance.repository.OfflinePerformanceRepository -import com.example.mobile_labs.database.performance.repository.PerformanceRepository import com.example.mobile_labs.database.person.repository.OfflinePersonRepository -import com.example.mobile_labs.database.person.repository.PersonRepository +import com.example.mobile_labs.database.AppDatabase interface AppContainer { val personRepository: PersonRepository diff --git a/app/src/main/java/com/example/mobile_labs/ui/AppViewModelProvider.kt b/app/src/main/java/com/example/mobile_labs/common/AppViewModelProvider.kt similarity index 95% rename from app/src/main/java/com/example/mobile_labs/ui/AppViewModelProvider.kt rename to app/src/main/java/com/example/mobile_labs/common/AppViewModelProvider.kt index e45783d..6ddee02 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/AppViewModelProvider.kt +++ b/app/src/main/java/com/example/mobile_labs/common/AppViewModelProvider.kt @@ -1,4 +1,4 @@ -package com.example.mobile_labs.ui +package com.example.mobile_labs.common import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.createSavedStateHandle diff --git a/app/src/main/java/com/example/mobile_labs/database/performance/repository/PerformanceRepository.kt b/app/src/main/java/com/example/mobile_labs/common/PerformanceRepository.kt similarity index 89% rename from app/src/main/java/com/example/mobile_labs/database/performance/repository/PerformanceRepository.kt rename to app/src/main/java/com/example/mobile_labs/common/PerformanceRepository.kt index 09ab2ac..cc3a23a 100644 --- a/app/src/main/java/com/example/mobile_labs/database/performance/repository/PerformanceRepository.kt +++ b/app/src/main/java/com/example/mobile_labs/common/PerformanceRepository.kt @@ -1,4 +1,4 @@ -package com.example.mobile_labs.database.performance.repository +package com.example.mobile_labs.common import androidx.paging.PagingData import com.example.mobile_labs.database.performance.model.Performance diff --git a/app/src/main/java/com/example/mobile_labs/database/person/repository/PersonRepository.kt b/app/src/main/java/com/example/mobile_labs/common/PersonRepository.kt similarity index 86% rename from app/src/main/java/com/example/mobile_labs/database/person/repository/PersonRepository.kt rename to app/src/main/java/com/example/mobile_labs/common/PersonRepository.kt index f676fb9..8a6f5b1 100644 --- a/app/src/main/java/com/example/mobile_labs/database/person/repository/PersonRepository.kt +++ b/app/src/main/java/com/example/mobile_labs/common/PersonRepository.kt @@ -1,4 +1,4 @@ -package com.example.mobile_labs.database.person.repository +package com.example.mobile_labs.common import androidx.paging.PagingData import com.example.mobile_labs.database.person.model.Person diff --git a/app/src/main/java/com/example/mobile_labs/database/event/repository/OfflineEventRepository.kt b/app/src/main/java/com/example/mobile_labs/database/event/repository/OfflineEventRepository.kt index 5663fcc..2839f9c 100644 --- a/app/src/main/java/com/example/mobile_labs/database/event/repository/OfflineEventRepository.kt +++ b/app/src/main/java/com/example/mobile_labs/database/event/repository/OfflineEventRepository.kt @@ -3,13 +3,11 @@ package com.example.mobile_labs.database.event.repository import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData -import com.example.mobile_labs.database.AppDataContainer +import com.example.mobile_labs.common.AppDataContainer import com.example.mobile_labs.database.event.dao.EventDao import com.example.mobile_labs.database.event.model.Event import com.example.mobile_labs.database.event.model.EventWithPerformance import kotlinx.coroutines.flow.Flow -import java.time.LocalDate -import java.time.format.DateTimeFormatter class OfflineEventRepository(private val eventDao: EventDao) : EventRepository { override fun getAll(): Flow> = eventDao.getAll(); diff --git a/app/src/main/java/com/example/mobile_labs/database/performance/repository/OfflinePerformanceRepository.kt b/app/src/main/java/com/example/mobile_labs/database/performance/repository/OfflinePerformanceRepository.kt index cebf393..c4cb845 100644 --- a/app/src/main/java/com/example/mobile_labs/database/performance/repository/OfflinePerformanceRepository.kt +++ b/app/src/main/java/com/example/mobile_labs/database/performance/repository/OfflinePerformanceRepository.kt @@ -3,13 +3,15 @@ package com.example.mobile_labs.database.performance.repository import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData -import com.example.mobile_labs.database.AppDataContainer +import com.example.mobile_labs.common.PerformanceRepository +import com.example.mobile_labs.common.AppDataContainer import com.example.mobile_labs.database.performance.dao.PerformanceDao import com.example.mobile_labs.database.performance.model.Performance import com.example.mobile_labs.database.performance.model.PerformanceWithPeople import kotlinx.coroutines.flow.Flow -class OfflinePerformanceRepository(private val performanceDao: PerformanceDao) : PerformanceRepository { +class OfflinePerformanceRepository(private val performanceDao: PerformanceDao) : + PerformanceRepository { override fun getAllPerformances(): Flow> = Pager( config = PagingConfig( pageSize = AppDataContainer.LIMIT, diff --git a/app/src/main/java/com/example/mobile_labs/database/person/repository/OfflinePersonRepository.kt b/app/src/main/java/com/example/mobile_labs/database/person/repository/OfflinePersonRepository.kt index c94b1d8..2f45a3d 100644 --- a/app/src/main/java/com/example/mobile_labs/database/person/repository/OfflinePersonRepository.kt +++ b/app/src/main/java/com/example/mobile_labs/database/person/repository/OfflinePersonRepository.kt @@ -3,8 +3,8 @@ package com.example.mobile_labs.database.person.repository import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData -import com.example.mobile_labs.database.AppContainer -import com.example.mobile_labs.database.AppDataContainer +import com.example.mobile_labs.common.PersonRepository +import com.example.mobile_labs.common.AppDataContainer import com.example.mobile_labs.database.person.dao.PersonDao import com.example.mobile_labs.database.person.model.Person import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/com/example/mobile_labs/ui/event/list/EventList.kt b/app/src/main/java/com/example/mobile_labs/ui/event/list/EventList.kt index 41f1206..ccd3896 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/event/list/EventList.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/event/list/EventList.kt @@ -2,15 +2,9 @@ package com.example.mobile_labs.ui.event.list import android.content.res.Configuration import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -19,16 +13,8 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -42,19 +28,11 @@ import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import coil.compose.AsyncImage import com.example.mobile_labs.R -import com.example.mobile_labs.database.AppDatabase -import com.example.mobile_labs.database.event.model.Event import com.example.mobile_labs.database.event.model.EventWithPerformance -import com.example.mobile_labs.database.performance.model.Performance -import com.example.mobile_labs.database.person.model.Person -import com.example.mobile_labs.ui.AppViewModelProvider +import com.example.mobile_labs.common.AppViewModelProvider import com.example.mobile_labs.ui.navigation.Screen -import com.example.mobile_labs.ui.person.list.PeopleListViewModel import com.example.mobile_labs.ui.theme.Mobile_LabsTheme -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.withContext -import java.time.LocalDate import java.time.format.DateTimeFormatter @Composable diff --git a/app/src/main/java/com/example/mobile_labs/ui/event/list/EventListViewModel.kt b/app/src/main/java/com/example/mobile_labs/ui/event/list/EventListViewModel.kt index fae66c7..b7ef76b 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/event/list/EventListViewModel.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/event/list/EventListViewModel.kt @@ -1,17 +1,10 @@ package com.example.mobile_labs.ui.event.list import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import androidx.paging.PagingData -import com.example.mobile_labs.database.AppDataContainer import com.example.mobile_labs.database.event.repository.EventRepository -import com.example.mobile_labs.database.event.model.Event import com.example.mobile_labs.database.event.model.EventWithPerformance import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn class EventListViewModel( private val eventRepository: EventRepository diff --git a/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceList.kt b/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceList.kt index 4060056..e9e7168 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceList.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceList.kt @@ -1,17 +1,10 @@ package com.example.mobile_labs.ui.performance.list -import com.example.mobile_labs.ui.event.list.EventListViewModel import android.content.res.Configuration import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults @@ -20,16 +13,8 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -43,21 +28,11 @@ import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import coil.compose.AsyncImage import com.example.mobile_labs.R -import com.example.mobile_labs.database.AppDatabase -import com.example.mobile_labs.database.event.model.Event -import com.example.mobile_labs.database.event.model.EventWithPerformance import com.example.mobile_labs.database.performance.model.Performance -import com.example.mobile_labs.database.person.model.Person -import com.example.mobile_labs.ui.AppViewModelProvider +import com.example.mobile_labs.common.AppViewModelProvider import com.example.mobile_labs.ui.navigation.Screen -import com.example.mobile_labs.ui.person.list.PeopleList -import com.example.mobile_labs.ui.person.list.PeopleListViewModel import com.example.mobile_labs.ui.theme.Mobile_LabsTheme -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.withContext -import java.time.LocalDate -import java.time.format.DateTimeFormatter @Composable fun PerformanceList( diff --git a/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceListViewModel.kt b/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceListViewModel.kt index 57014c5..918ab95 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceListViewModel.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/performance/list/PerformanceListViewModel.kt @@ -1,17 +1,10 @@ package com.example.mobile_labs.ui.performance.list import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import androidx.paging.PagingData -import com.example.mobile_labs.database.AppDataContainer import com.example.mobile_labs.database.performance.model.Performance -import com.example.mobile_labs.database.performance.repository.PerformanceRepository -import com.example.mobile_labs.database.person.model.Person +import com.example.mobile_labs.common.PerformanceRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn class PerformanceListViewModel( private val performanceRepository: PerformanceRepository diff --git a/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceView.kt b/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceView.kt index f7d9fcd..034587d 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceView.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceView.kt @@ -4,35 +4,24 @@ import android.content.res.Configuration import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.lifecycle.viewmodel.compose.viewModel -import androidx.navigation.NavController import coil.compose.AsyncImage import com.example.mobile_labs.R -import com.example.mobile_labs.database.AppDatabase -import com.example.mobile_labs.database.performance.model.PerformanceWithPeople -import com.example.mobile_labs.ui.AppViewModelProvider +import com.example.mobile_labs.common.AppViewModelProvider import com.example.mobile_labs.ui.theme.Mobile_LabsTheme -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext @OptIn(ExperimentalMaterial3Api::class) @Composable diff --git a/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceViewModel.kt b/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceViewModel.kt index b48bb9f..630cb34 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceViewModel.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/performance/view/PerformanceViewModel.kt @@ -6,9 +6,8 @@ import androidx.compose.runtime.setValue import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.example.mobile_labs.database.performance.model.Performance import com.example.mobile_labs.database.performance.model.PerformanceWithPeople -import com.example.mobile_labs.database.performance.repository.PerformanceRepository +import com.example.mobile_labs.common.PerformanceRepository import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleList.kt b/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleList.kt index accecf4..8d8c50c 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleList.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleList.kt @@ -5,42 +5,22 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.grid.GridCells -import androidx.compose.foundation.lazy.grid.LazyVerticalGrid -import androidx.compose.foundation.lazy.grid.items -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel -import androidx.navigation.NavController import androidx.paging.PagingData import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems @@ -48,17 +28,10 @@ import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import coil.compose.AsyncImage import com.example.mobile_labs.R -import com.example.mobile_labs.ui.navigation.Screen -import com.example.mobile_labs.database.AppDatabase -import com.example.mobile_labs.database.event.model.EventWithPerformance import com.example.mobile_labs.database.person.model.Person -import com.example.mobile_labs.ui.AppViewModelProvider +import com.example.mobile_labs.common.AppViewModelProvider import com.example.mobile_labs.ui.theme.Mobile_LabsTheme -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.withContext -import java.time.LocalDate -import java.time.format.DateTimeFormatter @Composable fun PeopleList( diff --git a/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleListViewModel.kt b/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleListViewModel.kt index a271d5a..1164369 100644 --- a/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleListViewModel.kt +++ b/app/src/main/java/com/example/mobile_labs/ui/person/list/PeopleListViewModel.kt @@ -1,16 +1,10 @@ package com.example.mobile_labs.ui.person.list import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import androidx.paging.PagingData -import com.example.mobile_labs.database.AppDataContainer import com.example.mobile_labs.database.person.model.Person -import com.example.mobile_labs.database.person.repository.PersonRepository +import com.example.mobile_labs.common.PersonRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn class PeopleListViewModel( private val personRepository: PersonRepository