Skip to content

Commit

Permalink
refactor(speakers-feature): rework experience for landscape mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Nov 10, 2023
1 parent a77cb86 commit 821d903
Show file tree
Hide file tree
Showing 18 changed files with 295 additions and 352 deletions.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include(":theme-m3:main:mobile")
include(":theme-m3:schedules:schedules-ui")
include(":theme-m3:schedules:schedules-feature")
include(":theme-m3:speakers:speakers-ui")
include(":theme-m3:speakers:speakers-screens")
include(":theme-m3:speakers:speakers-feature")
include(":theme-m3:networking:networking-ui")
include(":theme-m3:networking:networking-feature")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.gdglille.devfest.android.theme.m3.networking.feature.VCardQrCodeScann
import org.gdglille.devfest.android.theme.m3.partners.feature.PartnerDetailOrientableVM
import org.gdglille.devfest.android.theme.m3.schedules.feature.AgendaFiltersVM
import org.gdglille.devfest.android.theme.m3.schedules.feature.ScheduleDetailVM
import org.gdglille.devfest.android.theme.m3.speakers.feature.SpeakerDetailVM
import org.gdglille.devfest.android.theme.m3.speakers.feature.SpeakerDetailOrientableVM
import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme
import org.gdglille.devfest.models.ui.ExportNetworkingUi
import org.gdglille.devfest.repositories.AgendaRepository
Expand Down Expand Up @@ -163,7 +163,7 @@ fun MainMobile(
route = "speakers/{speakerId}",
arguments = listOf(navArgument("speakerId") { type = NavType.StringType })
) {
SpeakerDetailVM(
SpeakerDetailOrientableVM(
speakerId = it.arguments?.getString("speakerId")!!,
agendaRepository = agendaRepository,
alarmScheduler = alarmScheduler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.gdglille.devfest.android.theme.m3.navigation.Screen
import org.gdglille.devfest.android.theme.m3.networking.feature.NetworkingPages
import org.gdglille.devfest.android.theme.m3.partners.feature.PartnersListVM
import org.gdglille.devfest.android.theme.m3.schedules.feature.ScheduleListVM
import org.gdglille.devfest.android.theme.m3.speakers.feature.SpeakersListVM
import org.gdglille.devfest.android.theme.m3.speakers.feature.SpeakersListOrientableVM
import org.gdglille.devfest.models.ui.ExportNetworkingUi
import org.gdglille.devfest.repositories.AgendaRepository
import org.gdglille.devfest.repositories.EventRepository
Expand Down Expand Up @@ -158,7 +158,7 @@ fun Home(
)
}
composable(Screen.SpeakerList.route) {
SpeakersListVM(
SpeakersListOrientableVM(
speakerRepository = speakerRepository,
onSpeakerClicked = onSpeakerClicked
)
Expand Down
5 changes: 1 addition & 4 deletions theme-m3/speakers/speakers-feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ android {

dependencies {
implementation(projects.shared.core)
implementation(projects.themeM3.schedules.schedulesUi)
implementation(projects.themeM3.speakers.speakersUi)
implementation(projects.themeM3.speakers.speakersScreens)
implementation(projects.themeM3.navigation)
implementation(projects.themeM3.style.schedules)
implementation(projects.themeM3.style.speakers)
implementation(projects.themeM3.style.theme)

implementation(libs.kotlinx.collections)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.gdglille.devfest.android.theme.m3.speakers.feature

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.viewmodel.compose.viewModel
import org.gdglille.devfest.AlarmScheduler
import org.gdglille.devfest.android.theme.m3.speakers.screens.SpeakerDetailOrientable
import org.gdglille.devfest.android.theme.m3.style.R
import org.gdglille.devfest.android.theme.m3.style.appbars.TopAppBar
import org.gdglille.devfest.repositories.AgendaRepository

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SpeakerDetailOrientableVM(
speakerId: String,
agendaRepository: AgendaRepository,
alarmScheduler: AlarmScheduler,
onTalkClicked: (id: String) -> Unit,
onLinkClicked: (url: String) -> Unit,
onBackClicked: () -> Unit,
modifier: Modifier = Modifier,
viewModel: SpeakerDetailViewModel = viewModel(
factory = SpeakerDetailViewModel.Factory.create(speakerId, agendaRepository, alarmScheduler)
)
) {
val context = LocalContext.current
val uiState = viewModel.uiState.collectAsState()
Scaffold(
modifier = modifier,
topBar = {
TopAppBar(
title = stringResource(id = R.string.screen_speaker_detail),
navigationIcon = { Back(onClick = onBackClicked) }
)
},
content = {
when (uiState.value) {
is SpeakerUiState.Loading -> SpeakerDetailOrientable(
speaker = (uiState.value as SpeakerUiState.Loading).speaker,
contentPadding = it,
onTalkClicked = {},
onFavoriteClicked = {},
onLinkClicked = {}
)

is SpeakerUiState.Failure -> Text(text = stringResource(id = R.string.text_error))
is SpeakerUiState.Success -> SpeakerDetailOrientable(
speaker = (uiState.value as SpeakerUiState.Success).speaker,
contentPadding = it,
onTalkClicked = onTalkClicked,
onFavoriteClicked = {
viewModel.markAsFavorite(context, it)
},
onLinkClicked = onLinkClicked,
)
}
}
)
}

This file was deleted.

Loading

0 comments on commit 821d903

Please sign in to comment.