diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 39b737a..9749697 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -9,7 +9,7 @@ android { defaultConfig { applicationId = "com.example.mobile_labs" - minSdk = 24 + minSdk = 26 targetSdk = 33 versionCode = 1 versionName = "1.0" diff --git a/app/src/main/java/com/example/mobile_labs/composeui/navigation/MainNavbar.kt b/app/src/main/java/com/example/mobile_labs/composeui/navigation/MainNavbar.kt index 5c6eb09..acfbcba 100644 --- a/app/src/main/java/com/example/mobile_labs/composeui/navigation/MainNavbar.kt +++ b/app/src/main/java/com/example/mobile_labs/composeui/navigation/MainNavbar.kt @@ -34,6 +34,7 @@ import androidx.navigation.navArgument import com.example.mobile_labs.ui.theme.Mobile_LabsTheme import com.example.mobile_labs.R import com.example.mobile_labs.composeui.About +import com.example.mobile_labs.event.composeui.Schedule import com.example.mobile_labs.performance.composeui.PerformanceView import com.example.mobile_labs.performance.composeui.Repertoire import com.example.mobile_labs.person.composeui.PeopleList @@ -103,10 +104,10 @@ fun Navhost( ) { NavHost( navController, - startDestination = Screen.Repertoire.route, + startDestination = Screen.Schedule.route, modifier.padding(innerPadding) ) { - //composable(Screen.Schedule.route) { StudentList(navController) } + composable(Screen.Schedule.route) { Schedule(navController) } composable(Screen.Repertoire.route) { Repertoire(navController) } composable(Screen.PeopleList.route) { PeopleList(navController) } composable(Screen.About.route) { About() } diff --git a/app/src/main/java/com/example/mobile_labs/composeui/navigation/Screen.kt b/app/src/main/java/com/example/mobile_labs/composeui/navigation/Screen.kt index a529eec..6520232 100644 --- a/app/src/main/java/com/example/mobile_labs/composeui/navigation/Screen.kt +++ b/app/src/main/java/com/example/mobile_labs/composeui/navigation/Screen.kt @@ -34,6 +34,7 @@ enum class Screen( companion object { val bottomBarItems = listOf( + Schedule, Repertoire, PeopleList, About, diff --git a/app/src/main/java/com/example/mobile_labs/event/composeui/Schedule.kt b/app/src/main/java/com/example/mobile_labs/event/composeui/Schedule.kt new file mode 100644 index 0000000..f384205 --- /dev/null +++ b/app/src/main/java/com/example/mobile_labs/event/composeui/Schedule.kt @@ -0,0 +1,71 @@ +package com.example.mobile_labs.event.composeui + +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.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.navigation.NavController +import coil.compose.AsyncImage +import com.example.mobile_labs.composeui.navigation.Screen +import com.example.mobile_labs.event.model.getTestEvents +import com.example.mobile_labs.ui.theme.Mobile_LabsTheme +import java.time.format.DateTimeFormatter + +@Composable +fun Schedule(navController: NavController?) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .padding(all = 10.dp) + .verticalScroll(rememberScrollState())) { + getTestEvents().forEachIndexed() { _, event -> + val performanceId = Screen.PerformanceView.route.replace("{id}", event.performance.id.toString()) + Row(Modifier.padding(all = 10.dp)) { + Text(modifier = Modifier.padding(all = 5.dp), textAlign = TextAlign.Center, text = event.date.format(DateTimeFormatter.ofPattern("dd.MM"))) + AsyncImage(model = event.performance.previewImageURL, + contentDescription = "performance preview image", + contentScale = ContentScale.Crop, + modifier = Modifier + .height(100.dp) + .width(100.dp)) + Button( + modifier = Modifier + .fillMaxWidth() + .padding(all = 10.dp), + onClick = { navController?.navigate(performanceId) }) { + Text(event.performance.title) + } + } + } + } +} + +@Preview(name = "Light Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(name = "Dark Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +fun SchedulePreview() { + Mobile_LabsTheme { + Surface( + color = MaterialTheme.colorScheme.background + ) { + Schedule(navController = null) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/mobile_labs/event/model/Event.kt b/app/src/main/java/com/example/mobile_labs/event/model/Event.kt new file mode 100644 index 0000000..ce7c878 --- /dev/null +++ b/app/src/main/java/com/example/mobile_labs/event/model/Event.kt @@ -0,0 +1,27 @@ +package com.example.mobile_labs.event.model + +import com.example.mobile_labs.performance.model.Performance +import com.example.mobile_labs.person.model.Person +import java.io.Serializable +import java.time.LocalDate + +data class Event( + val date: LocalDate, + val performance: Performance, +) : Serializable + +fun getTestEvents(): List { + val director = Person("Иванов", "Иван", "https://bolshoi.ru/media/members/photos/86_ru_twyyatusbnifnzi_300x300_p.jpg"); + val author = Person("Петров", "Петр", "https://bolshoi.ru/media/members/photos/86_ru_twyyatusbnifnzi_300x300_p.jpg"); + val actors = listOf(director, author); + val performances = listOf( + Performance(0,"Представление #1", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(1,"Представление #2", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(2,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + ) + return listOf( + Event(LocalDate.parse("2023-10-15"), performances[0]), + Event(LocalDate.parse("2023-10-16"), performances[1]), + Event(LocalDate.parse("2023-10-17"), performances[2]) + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/example/mobile_labs/performance/composeui/Repertoire.kt b/app/src/main/java/com/example/mobile_labs/performance/composeui/Repertoire.kt index cf96393..6438da9 100644 --- a/app/src/main/java/com/example/mobile_labs/performance/composeui/Repertoire.kt +++ b/app/src/main/java/com/example/mobile_labs/performance/composeui/Repertoire.kt @@ -51,7 +51,7 @@ fun Repertoire(navController: NavController?) { TextField(value = title, label = {Text(text = "Поиск...")}, onValueChange = { title = it; performances = if (title != "") getTestPerformances().filter { performance -> performance.title.contains(title) } else getTestPerformances() }) performances.forEachIndexed() { index, performance -> - val performanceId = Screen.PerformanceView.route.replace("{id}", index.toString()) + val performanceId = Screen.PerformanceView.route.replace("{id}", performance.id.toString()) Row(Modifier.padding(all = 10.dp)) { AsyncImage(model = performance.previewImageURL, contentDescription = "performance preview image", diff --git a/app/src/main/java/com/example/mobile_labs/performance/model/Performance.kt b/app/src/main/java/com/example/mobile_labs/performance/model/Performance.kt index c672be1..d3b5c34 100644 --- a/app/src/main/java/com/example/mobile_labs/performance/model/Performance.kt +++ b/app/src/main/java/com/example/mobile_labs/performance/model/Performance.kt @@ -4,6 +4,7 @@ import com.example.mobile_labs.person.model.Person import java.io.Serializable data class Performance( + val id: Int, val title: String, val description: String, val author: Person, @@ -18,16 +19,16 @@ fun getTestPerformances(): List { val author = Person("Петров", "Петр", "https://bolshoi.ru/media/members/photos/86_ru_twyyatusbnifnzi_300x300_p.jpg"); val actors = listOf(director, author); return listOf( - Performance("Представление #1", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #2", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), - Performance("Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(0,"Представление #1", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(1,"Представление #2", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(2,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(3,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(4,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(5,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(6,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(7,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(8,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(9,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), + Performance(10,"Представление #3", "Netus quis congue nascetur ullamcorper nibh, nostra iaculis turpis!", author, director, actors, "https://img.freepik.com/free-photo/empty-stage-with-few-props-red-seats_181624-57595.jpg?w=1380&t=st=1696959739~exp=1696960339~hmac=2107448a1d874f1315b5cf246c71df70dc653707c7c8be4a38581d3b73f842ba", "https://www.theatreinparis.com/uploads/images/article/theatre-de-l-athenee-dr.jpg"), ) } \ No newline at end of file