From 601740f258fe5f63d9412ea1316e9bc747b635ee Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Wed, 26 Apr 2023 11:38:09 +0200 Subject: [PATCH 01/23] secondaryscreentemplate error --- .idea/misc.xml | 3 +- .../studeez/navigation/StudeezDestinations.kt | 2 + .../add_timer/AddTimerViewModel.kt | 13 ++++++ .../add_timer/addTimerScreen.kt | 42 +++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt diff --git a/.idea/misc.xml b/.idea/misc.xml index 8978d23..704c883 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,7 @@ + - + diff --git a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt index 760c814..63f9d64 100644 --- a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt +++ b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt @@ -18,4 +18,6 @@ object StudeezDestinations { // Edit screens const val EDIT_PROFILE_SCREEN = "edit_profile" + + const val ADD_TIMER_SCREEN = "add_timer" } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt new file mode 100644 index 0000000..a209f49 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt @@ -0,0 +1,13 @@ +package be.ugent.sel.studeez.screens.timer_overview.add_timer + +import be.ugent.sel.studeez.domain.LogService +import be.ugent.sel.studeez.screens.StudeezViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class AddTimerViewModel @Inject constructor( + logService: LogService +): StudeezViewModel(logService) { + +} diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt new file mode 100644 index 0000000..a26826c --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt @@ -0,0 +1,42 @@ +package be.ugent.sel.studeez.screens.timer_overview.add_timer + +import androidx.compose.runtime.Composable +import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate +import be.ugent.sel.studeez.common.composable.drawer.DrawerActions +import be.ugent.sel.studeez.common.composable.drawer.DrawerViewModel +import be.ugent.sel.studeez.common.composable.drawer.getDrawerActions +import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions +import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel +import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions + +@Composable +fun AddTimerRoute( + open: (String) -> Unit, + openAndPopUp: (String, String) -> Unit + viewModel: AddTimerViewModel, + drawerViewModel: DrawerViewModel, + navBarViewModel: NavigationBarViewModel, +) { + addTimerScreen( + drawerActions = getDrawerActions( + drawerViewModel = drawerViewModel, + open = open, + openAndPopUp = openAndPopUp + ), + navigationBarActions = getNavigationBarActions( + navigationBarViewModel = navBarViewModel, + open = open + ) + ) +} + +fun addTimerScreen( + drawerActions: DrawerActions, + navigationBarActions: NavigationBarActions +) { + SecondaryScreenTemplate( + title = , + popUp = { /*TODO*/ }) { + + } +} \ No newline at end of file From 2ca112ee0e66547dd8ed8a3ecb96643061033eca Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Thu, 27 Apr 2023 17:01:39 +0200 Subject: [PATCH 02/23] LazyColumn not fixed --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 10 + .../common/composable/ButtonComposable.kt | 9 +- .../timer_overview/TimerOverviewScreen.kt | 12 +- .../add_timer/AddTimerUiState.kt | 11 + .../add_timer/AddTimerViewModel.kt | 74 +++++- .../add_timer/addTimerScreen.kt | 215 ++++++++++++++++-- 6 files changed, 303 insertions(+), 28 deletions(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index a6830a5..be8ad00 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -34,6 +34,7 @@ import be.ugent.sel.studeez.screens.session.SessionRoute import be.ugent.sel.studeez.screens.sign_up.SignUpRoute import be.ugent.sel.studeez.screens.splash.SplashRoute import be.ugent.sel.studeez.screens.timer_overview.TimerOverviewRoute +import be.ugent.sel.studeez.screens.timer_overview.add_timer.AddTimerRoute import be.ugent.sel.studeez.screens.timer_selection.TimerSelectionRoute import be.ugent.sel.studeez.ui.theme.StudeezTheme import kotlinx.coroutines.CoroutineScope @@ -167,5 +168,14 @@ fun StudeezNavGraph( navBarViewModel = navBarViewModel, ) } + + composable(StudeezDestinations.ADD_TIMER_SCREEN) { + AddTimerRoute( + open = open, + openAndPopUp = openAndPopUp, + goBack = goBack, + viewModel = hiltViewModel() + ) + } } } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt index b2568aa..79845ec 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt @@ -23,7 +23,14 @@ import be.ugent.sel.studeez.common.ext.card @Composable fun BasicTextButton(@StringRes text: Int, modifier: Modifier, action: () -> Unit) { - TextButton(onClick = action, modifier = modifier) { Text(text = stringResource(text)) } + TextButton( + onClick = action, + modifier = modifier + ) { + Text( + text = stringResource(text) + ) + } } @Composable diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt index fafdf02..3bc6ca7 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt @@ -23,6 +23,7 @@ import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions import be.ugent.sel.studeez.common.ext.basicButton import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo +import be.ugent.sel.studeez.navigation.StudeezDestinations import be.ugent.sel.studeez.resources import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -31,15 +32,18 @@ data class TimerOverviewActions( val getUserTimers: () -> Flow>, val getDefaultTimers: () -> List, val onEditClick: (TimerInfo) -> Unit, + val open: (String) -> Unit, ) fun getTimerOverviewActions( viewModel: TimerOverviewViewModel, + open: (String) -> Unit, ): TimerOverviewActions { return TimerOverviewActions( getUserTimers = viewModel::getUserTimers, getDefaultTimers = viewModel::getDefaultTimers, onEditClick = { viewModel.update(it) }, + open = open ) } @@ -52,7 +56,7 @@ fun TimerOverviewRoute( navBarViewModel: NavigationBarViewModel, ) { TimerOverviewScreen( - timerOverviewActions = getTimerOverviewActions(viewModel), + timerOverviewActions = getTimerOverviewActions(viewModel, open), drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp), navigationBarActions = getNavigationBarActions(navBarViewModel, open), ) @@ -95,7 +99,7 @@ fun TimerOverviewScreen( } } BasicButton(R.string.add_timer, Modifier.basicButton()) { - // TODO + timerOverviewActions.open(StudeezDestinations.ADD_TIMER_SCREEN) } } } @@ -111,7 +115,9 @@ fun TimerOverviewPreview() { timerOverviewActions = TimerOverviewActions( { flowOf() }, { listOf(customTimer, customTimer) }, - {}), + {}, + {} + ), drawerActions = DrawerActions({}, {}, {}, {}, {}), navigationBarActions = NavigationBarActions({}, {}, {}, {}) ) diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt new file mode 100644 index 0000000..9b17121 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt @@ -0,0 +1,11 @@ +package be.ugent.sel.studeez.screens.timer_overview.add_timer + +data class AddTimerUiState( + val studyTimeHours: Float = 1f, + val studyTimeMinutes: Float = 0f, + val withBreaks: Boolean = false, + val breakTime: Float = 5f, + val repeats: Float = 1f, + val name: String = "", + val description: String = "", +) \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt index a209f49..7e79e1e 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt @@ -1,13 +1,85 @@ package be.ugent.sel.studeez.screens.timer_overview.add_timer +import androidx.compose.runtime.mutableStateOf +import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo +import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo +import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.domain.LogService +import be.ugent.sel.studeez.domain.TimerDAO import be.ugent.sel.studeez.screens.StudeezViewModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class AddTimerViewModel @Inject constructor( - logService: LogService + logService: LogService, + private val timerDAO: TimerDAO, ): StudeezViewModel(logService) { + var uiState = mutableStateOf(AddTimerUiState()) + private set + private val studyTimeHours + get() = uiState.value.studyTimeHours + + private val studyTimeMinutes + get() = uiState.value.studyTimeMinutes + + private val breakTime + get() = uiState.value.breakTime + + private val repeats + get() = uiState.value.repeats + + private val name + get() = uiState.value.name + + private val description + get() = uiState.value.description + + fun onStudyTimeHoursChange(newValue: Float) { + uiState.value = uiState.value.copy(studyTimeHours = newValue) + + } + + fun onStudyTimeMinutesChange(newValue: Float) { + uiState.value = uiState.value.copy(studyTimeMinutes = newValue) + } + + fun onWithBreaksChange(newValue: Boolean) { + uiState.value = uiState.value.copy(withBreaks = newValue) + } + + fun onBreakTimeChange(newValue: Float) { + uiState.value = uiState.value.copy(breakTime = newValue) + } + + fun onRepeatsChange(newValue: Float) { + uiState.value = uiState.value.copy(repeats = newValue) + } + + fun addTimer() { + if (uiState.value.withBreaks) { + timerDAO.saveTimer(PomodoroTimerInfo( + name = uiState.value.name, + description = uiState.value.description, + studyTime = studyTimeHours.toInt() * 60 * 60 + studyTimeMinutes.toInt() * 60, + breakTime = breakTime.toInt() * 60, + repeats = repeats.toInt() + )) + } else { + timerDAO.saveTimer(CustomTimerInfo( + name = uiState.value.name, + description = uiState.value.description, + studyTime = studyTimeHours.toInt() * 60 * 60 + studyTimeMinutes.toInt() * 60 + )) + } + } + + fun onNameChange(newValue: String) { + uiState.value = uiState.value.copy(name = newValue) + } + + fun onDescriptionChange(newValue: String) { + uiState.value = uiState.value.copy(description = newValue) + } } diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt index a26826c..6941a05 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt @@ -1,42 +1,211 @@ package be.ugent.sel.studeez.screens.timer_overview.add_timer +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.Checkbox +import androidx.compose.material.Slider +import androidx.compose.material.Text +import androidx.compose.material.TextField import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import be.ugent.sel.studeez.R +import be.ugent.sel.studeez.common.composable.BasicButton import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate -import be.ugent.sel.studeez.common.composable.drawer.DrawerActions -import be.ugent.sel.studeez.common.composable.drawer.DrawerViewModel -import be.ugent.sel.studeez.common.composable.drawer.getDrawerActions -import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions -import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel -import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions +import be.ugent.sel.studeez.resources + +data class AddTimerActions( + val goBack: () -> Unit, + val onStudyTimeHoursChange: (Float) -> Unit, + val onStudyTimeMinutesChange: (Float) -> Unit, + val onBreakTimeChange: (Float) -> Unit, + val onRepeatsChange: (Float) -> Unit, + val onWithBreaksChange: (Boolean) -> Unit, + val addTimer: () -> Unit, + val onNameChange: (String) -> Unit, + val onDescriptionChange: (String) -> Unit, +) + +fun getAddTimerActions( + goBack: () -> Unit, + viewModel: AddTimerViewModel, +): AddTimerActions { + return AddTimerActions( + goBack = goBack, + onWithBreaksChange = viewModel::onWithBreaksChange, + onStudyTimeHoursChange = viewModel::onStudyTimeHoursChange, + onStudyTimeMinutesChange = viewModel::onStudyTimeMinutesChange, + onBreakTimeChange = viewModel::onBreakTimeChange, + onRepeatsChange = viewModel::onRepeatsChange, + addTimer = viewModel::addTimer, + onNameChange = viewModel::onNameChange, + onDescriptionChange = viewModel::onDescriptionChange + ) +} @Composable fun AddTimerRoute( open: (String) -> Unit, - openAndPopUp: (String, String) -> Unit + openAndPopUp: (String, String) -> Unit, + goBack: () -> Unit, viewModel: AddTimerViewModel, - drawerViewModel: DrawerViewModel, - navBarViewModel: NavigationBarViewModel, ) { - addTimerScreen( - drawerActions = getDrawerActions( - drawerViewModel = drawerViewModel, - open = open, - openAndPopUp = openAndPopUp + val uiState by viewModel.uiState + + AddTimerScreen( + addTimerActions = getAddTimerActions( + goBack = goBack, + viewModel = viewModel, ), - navigationBarActions = getNavigationBarActions( - navigationBarViewModel = navBarViewModel, - open = open - ) + uiState = uiState ) } -fun addTimerScreen( - drawerActions: DrawerActions, - navigationBarActions: NavigationBarActions +@Composable +fun AddTimerScreen( + addTimerActions: AddTimerActions, + uiState: AddTimerUiState, ) { SecondaryScreenTemplate( - title = , - popUp = { /*TODO*/ }) { + title = resources().getString(R.string.add_timer), + popUp = addTimerActions.goBack + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp) + ) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Text( + text = "How long do you want to study?", + textAlign = TextAlign.Center + ) + } + LazyColumn( + modifier = Modifier + .padding(16.dp) + ) { + item{ + Text( + text = "${uiState.studyTimeHours.toInt()} hour${ if (uiState.studyTimeHours == 1f) "" else "s"}" + ) + Slider( + value = uiState.studyTimeHours, + onValueChange = { + addTimerActions.onStudyTimeHoursChange(it) + }, + steps = 8, + valueRange = 1f..10f, + enabled = true + ) + + Text( + text = "${uiState.studyTimeMinutes.toInt()} minutes" + ) + Slider( + value = uiState.studyTimeMinutes, + onValueChange = { + addTimerActions.onStudyTimeMinutesChange(it) + }, + steps = 11, + valueRange = 0f..60f, + enabled = true + ) + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Text( + text = "With breaks?", + ) + Checkbox( + checked = uiState.withBreaks, + onCheckedChange = { addTimerActions.onWithBreaksChange(it) } + ) + } + + Text( + text = if (uiState.withBreaks) "breaks of ${uiState.breakTime.toInt()} minutes" else "", + ) + Slider( + value = uiState.breakTime, + onValueChange = { + addTimerActions.onBreakTimeChange(it) + }, + steps = 11, + valueRange = 0f..60f, + enabled = uiState.withBreaks + ) + + Text( + text = if (uiState.withBreaks) "${uiState.repeats.toInt()} breaks" else "" + ) + Slider( + value = uiState.repeats, + onValueChange = { + addTimerActions.onRepeatsChange(it) + }, + steps = 8, + valueRange = 1f..10f, + enabled = uiState.withBreaks + ) + + Text( + text = "Timer name" + ) + TextField( + value = uiState.name, + onValueChange = { addTimerActions.onNameChange(it) } + ) + + Text( + text = "Timer description" + ) + TextField( + value = uiState.description, + onValueChange = { addTimerActions.onDescriptionChange(it) } + ) + + Row( + modifier = Modifier + .fillMaxWidth() + .fillMaxHeight(), + verticalAlignment = Alignment.Bottom, + horizontalArrangement = Arrangement.Center + ) { + BasicButton( + text = R.string.add_timer, + modifier = Modifier, + onClick = addTimerActions.addTimer + ) + } + } + } + } } +} + +@Preview +@Composable +fun AddTimerScreenPreview() { + AddTimerScreen( + addTimerActions = AddTimerActions({}, {}, {}, {}, {}, {}, {}, {}, {}), + uiState = AddTimerUiState() + ) } \ No newline at end of file From 535ef85c6d0a908388833929407df03eecdff245 Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Fri, 28 Apr 2023 11:42:03 +0200 Subject: [PATCH 03/23] LazyColumn in progress of being fixed --- .../add_timer/addTimerScreen.kt | 232 ++++++++++-------- 1 file changed, 124 insertions(+), 108 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt index 6941a05..772917d 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt @@ -1,7 +1,6 @@ package be.ugent.sel.studeez.screens.timer_overview.add_timer import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth @@ -22,6 +21,7 @@ import be.ugent.sel.studeez.R import be.ugent.sel.studeez.common.composable.BasicButton import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate import be.ugent.sel.studeez.resources +import be.ugent.sel.studeez.ui.theme.StudeezTheme data class AddTimerActions( val goBack: () -> Unit, @@ -79,122 +79,137 @@ fun AddTimerScreen( title = resources().getString(R.string.add_timer), popUp = addTimerActions.goBack ) { - Column( + LazyColumn( modifier = Modifier .fillMaxWidth() .padding(16.dp) ) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center - ) { + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Text( + text = "How long do you want to study?", + textAlign = TextAlign.Center + ) + } + } + item { Text( - text = "How long do you want to study?", - textAlign = TextAlign.Center + text = "${uiState.studyTimeHours.toInt()} hour${ if (uiState.studyTimeHours == 1f) "" else "s"}" ) } - - LazyColumn( - modifier = Modifier - .padding(16.dp) - ) { - item{ + item { + Slider( + value = uiState.studyTimeHours, + onValueChange = { + addTimerActions.onStudyTimeHoursChange(it) + }, + steps = 8, + valueRange = 1f..10f, + enabled = true + ) + } + item { + Text( + text = "${uiState.studyTimeMinutes.toInt()} minutes" + ) + } + item { + Slider( + value = uiState.studyTimeMinutes, + onValueChange = { + addTimerActions.onStudyTimeMinutesChange(it) + }, + steps = 11, + valueRange = 0f..60f, + enabled = true + ) + } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { Text( - text = "${uiState.studyTimeHours.toInt()} hour${ if (uiState.studyTimeHours == 1f) "" else "s"}" + text = "With breaks?", ) - Slider( - value = uiState.studyTimeHours, - onValueChange = { - addTimerActions.onStudyTimeHoursChange(it) - }, - steps = 8, - valueRange = 1f..10f, - enabled = true + Checkbox( + checked = uiState.withBreaks, + onCheckedChange = { addTimerActions.onWithBreaksChange(it) } ) - - Text( - text = "${uiState.studyTimeMinutes.toInt()} minutes" + } + } + item { + Text( + text = if (uiState.withBreaks) "breaks of ${uiState.breakTime.toInt()} minutes" else "", + ) + } + item { + Slider( + value = uiState.breakTime, + onValueChange = { + addTimerActions.onBreakTimeChange(it) + }, + steps = 11, + valueRange = 0f..60f, + enabled = uiState.withBreaks + ) + } + item { + Text( + text = if (uiState.withBreaks) "${uiState.repeats.toInt()} breaks" else "" + ) + } + item { + Slider( + value = uiState.repeats, + onValueChange = { + addTimerActions.onRepeatsChange(it) + }, + steps = 8, + valueRange = 1f..10f, + enabled = uiState.withBreaks + ) + } + item { + Text( + text = "Timer name" + ) + } + item { + TextField( + value = uiState.name, + onValueChange = { addTimerActions.onNameChange(it) } + ) + } + item { + Text( + text = "Timer description" + ) + } + item { + TextField( + value = uiState.description, + onValueChange = { addTimerActions.onDescriptionChange(it) } + ) + } + item { + Row( + modifier = Modifier + .fillMaxWidth() + .fillMaxHeight(), + verticalAlignment = Alignment.Bottom, + horizontalArrangement = Arrangement.Center + ) { + BasicButton( + text = R.string.add_timer, + modifier = Modifier, + onClick = addTimerActions.addTimer ) - Slider( - value = uiState.studyTimeMinutes, - onValueChange = { - addTimerActions.onStudyTimeMinutesChange(it) - }, - steps = 11, - valueRange = 0f..60f, - enabled = true - ) - - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center - ) { - Text( - text = "With breaks?", - ) - Checkbox( - checked = uiState.withBreaks, - onCheckedChange = { addTimerActions.onWithBreaksChange(it) } - ) - } - - Text( - text = if (uiState.withBreaks) "breaks of ${uiState.breakTime.toInt()} minutes" else "", - ) - Slider( - value = uiState.breakTime, - onValueChange = { - addTimerActions.onBreakTimeChange(it) - }, - steps = 11, - valueRange = 0f..60f, - enabled = uiState.withBreaks - ) - - Text( - text = if (uiState.withBreaks) "${uiState.repeats.toInt()} breaks" else "" - ) - Slider( - value = uiState.repeats, - onValueChange = { - addTimerActions.onRepeatsChange(it) - }, - steps = 8, - valueRange = 1f..10f, - enabled = uiState.withBreaks - ) - - Text( - text = "Timer name" - ) - TextField( - value = uiState.name, - onValueChange = { addTimerActions.onNameChange(it) } - ) - - Text( - text = "Timer description" - ) - TextField( - value = uiState.description, - onValueChange = { addTimerActions.onDescriptionChange(it) } - ) - - Row( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(), - verticalAlignment = Alignment.Bottom, - horizontalArrangement = Arrangement.Center - ) { - BasicButton( - text = R.string.add_timer, - modifier = Modifier, - onClick = addTimerActions.addTimer - ) - } } } } @@ -203,9 +218,10 @@ fun AddTimerScreen( @Preview @Composable -fun AddTimerScreenPreview() { +fun AddTimerScreenPreview() { StudeezTheme { AddTimerScreen( addTimerActions = AddTimerActions({}, {}, {}, {}, {}, {}, {}, {}, {}), uiState = AddTimerUiState() - ) + ) + } } \ No newline at end of file From 024ce85266790605b89c91f9ed12107170a6799a Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Sat, 29 Apr 2023 17:55:20 +0200 Subject: [PATCH 04/23] #26 select time for custom timer --- .../common/composable/ButtonComposable.kt | 23 ++++++++- .../ugent/sel/studeez/common/ext/ShapeExt.kt | 8 +++ .../models/timer_info/CustomTimerInfo.kt | 2 +- .../timer_overview/TimerOverviewScreen.kt | 9 ++++ .../timer_selection/TimerSelectionScreen.kt | 50 ++++++++++++++++++- app/src/main/res/values/strings.xml | 3 ++ 6 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/common/ext/ShapeExt.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt index 3fa9bd2..9751750 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/ButtonComposable.kt @@ -2,7 +2,6 @@ package be.ugent.sel.studeez.common.composable import androidx.annotation.StringRes import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.* import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -13,6 +12,7 @@ import androidx.compose.ui.unit.sp import be.ugent.sel.studeez.R import be.ugent.sel.studeez.common.ext.basicButton import be.ugent.sel.studeez.common.ext.card +import be.ugent.sel.studeez.common.ext.defaultButtonShape @Composable fun BasicTextButton(@StringRes text: Int, modifier: Modifier, action: () -> Unit) { @@ -30,7 +30,7 @@ fun BasicButton( Button( onClick = onClick, modifier = modifier, - shape = RoundedCornerShape(20.dp), + shape = defaultButtonShape(), colors = colors, border = border, ) { @@ -47,6 +47,25 @@ fun BasicButtonPreview() { BasicButton(text = R.string.add_timer, modifier = Modifier.basicButton()) {} } +@Composable +fun NotInternationalisedButton( + text: String, + modifier: Modifier = Modifier, + colors: ButtonColors = ButtonDefaults.buttonColors(), + border: BorderStroke? = null, + onClick: () -> Unit +) { + Button( + onClick = onClick, + modifier = modifier, + shape = defaultButtonShape(), + colors = colors, + border = border + ) { + Text(text = text) + } +} + @Composable fun StealthButton( @StringRes text: Int, diff --git a/app/src/main/java/be/ugent/sel/studeez/common/ext/ShapeExt.kt b/app/src/main/java/be/ugent/sel/studeez/common/ext/ShapeExt.kt new file mode 100644 index 0000000..2114a74 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/common/ext/ShapeExt.kt @@ -0,0 +1,8 @@ +package be.ugent.sel.studeez.common.ext + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.ui.unit.dp + +fun defaultButtonShape(): RoundedCornerShape { + return RoundedCornerShape(20.dp) +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt index 5e06536..d33ecc4 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt @@ -6,7 +6,7 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer class CustomTimerInfo( name: String, description: String, - private val studyTime: Int, + var studyTime: Int, id: String = "" ): TimerInfo(id, name, description) { diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt index 9489a30..d6d7b07 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt @@ -61,6 +61,15 @@ fun TimerOverviewScreen( ) { Column { LazyColumn { + // Custom timer, select new duration each time + item { + TimerEntry(timerInfo = CustomTimerInfo( + name = resources().getString(R.string.custom_name), + description = resources().getString(R.string.custom_name), + studyTime = 0 + )) + } + // Default Timers, cannot be edited items(timerOverviewActions.getDefaultTimers()) { TimerEntry(timerInfo = it) {} diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt index ac46b5c..2f8fcac 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt @@ -1,22 +1,29 @@ package be.ugent.sel.studeez.screens.timer_selection +import android.app.TimePickerDialog +import android.content.Context import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import be.ugent.sel.studeez.R +import be.ugent.sel.studeez.common.composable.NotInternationalisedButton import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate import be.ugent.sel.studeez.common.composable.StealthButton import be.ugent.sel.studeez.common.composable.TimerEntry +import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.resources import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf +import java.util.* data class TimerSelectionActions( val getAllTimers: () -> Flow>, val startSession: (TimerInfo) -> Unit, + val pickDuration: (Context, CustomTimerInfo) -> Unit ) fun getTimerSelectionActions( @@ -26,6 +33,21 @@ fun getTimerSelectionActions( return TimerSelectionActions( getAllTimers = viewModel::getAllTimers, startSession = { viewModel.startSession(open, it) }, + pickDuration = { context, timerInfo -> + val mCalendar = Calendar.getInstance() + val mHour = mCalendar[Calendar.HOUR] + val mMinute = mCalendar[Calendar.MINUTE] + + val mTimePickerDialog = TimePickerDialog( + context, + { _, hour : Int, minute: Int -> timerInfo.studyTime = hour * 60 * 60 + minute * 60 }, + mHour, + mMinute, + true + ) + + mTimePickerDialog.show() + } ) } @@ -52,6 +74,32 @@ fun TimerSelectionScreen( popUp = popUp ) { LazyColumn { + // Custom timer with duration selection button + item { + val timerInfo = CustomTimerInfo( + name = resources().getString(R.string.custom_name), + description = resources().getString(R.string.custom_name), + studyTime = 0 + ) + val context = LocalContext.current + + TimerEntry( + timerInfo = timerInfo, + leftButton = { + StealthButton( + text = R.string.start, + onClick = { timerSelectionActions.startSession(timerInfo) } + ) + }, + rightButton = { + NotInternationalisedButton( + text = resources().getString(R.string.pick_time), + onClick = { timerSelectionActions.pickDuration(context, timerInfo) } + ) + } + ) + } + // All timers items(timers.value) { timerInfo -> TimerEntry( @@ -72,7 +120,7 @@ fun TimerSelectionScreen( @Composable fun TimerSelectionPreview() { TimerSelectionScreen( - timerSelectionActions = TimerSelectionActions({ flowOf() }, {}), + timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { _, _ -> {}}), popUp = {} ) } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bb643d3..1876cee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,7 @@ Timers Edit Add timer + Select time Focus! Focus one more time! @@ -73,6 +74,8 @@ Done! Take a break! + Custom + Select how long you want to study Settings From 3bf0157adcb5478f4af4b205ed9fd1fb58375a1a Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Sun, 30 Apr 2023 12:26:29 +0200 Subject: [PATCH 05/23] #26 Show selected time --- .../timer_selection/TimerSelectionScreen.kt | 78 ++++++++++--------- .../TimerSelectionViewModel.kt | 6 ++ 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt index 2f8fcac..780b50a 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt @@ -18,12 +18,12 @@ import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.resources import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf -import java.util.* data class TimerSelectionActions( val getAllTimers: () -> Flow>, val startSession: (TimerInfo) -> Unit, - val pickDuration: (Context, CustomTimerInfo) -> Unit + val pickDuration: (Context) -> Unit, + val customTimeStudyTime: Int ) fun getTimerSelectionActions( @@ -33,21 +33,20 @@ fun getTimerSelectionActions( return TimerSelectionActions( getAllTimers = viewModel::getAllTimers, startSession = { viewModel.startSession(open, it) }, - pickDuration = { context, timerInfo -> - val mCalendar = Calendar.getInstance() - val mHour = mCalendar[Calendar.HOUR] - val mMinute = mCalendar[Calendar.MINUTE] - - val mTimePickerDialog = TimePickerDialog( + pickDuration = { context -> + val dialog = TimePickerDialog( context, - { _, hour : Int, minute: Int -> timerInfo.studyTime = hour * 60 * 60 + minute * 60 }, - mHour, - mMinute, + { _, hour: Int, minute: Int -> + viewModel.customTimerStudyTime.value = hour * 60 * 60 + minute * 60 + }, + 0, + 0, true ) - mTimePickerDialog.show() - } + dialog.show() + }, + customTimeStudyTime = viewModel.customTimerStudyTime.value ) } @@ -76,28 +75,7 @@ fun TimerSelectionScreen( LazyColumn { // Custom timer with duration selection button item { - val timerInfo = CustomTimerInfo( - name = resources().getString(R.string.custom_name), - description = resources().getString(R.string.custom_name), - studyTime = 0 - ) - val context = LocalContext.current - - TimerEntry( - timerInfo = timerInfo, - leftButton = { - StealthButton( - text = R.string.start, - onClick = { timerSelectionActions.startSession(timerInfo) } - ) - }, - rightButton = { - NotInternationalisedButton( - text = resources().getString(R.string.pick_time), - onClick = { timerSelectionActions.pickDuration(context, timerInfo) } - ) - } - ) + CustomTimerEntry(timerSelectionActions) } // All timers @@ -116,11 +94,39 @@ fun TimerSelectionScreen( } } +@Composable +fun CustomTimerEntry( + timerSelectionActions: TimerSelectionActions +) { + val timerInfo = CustomTimerInfo( + name = resources().getString(R.string.custom_name), + description = resources().getString(R.string.custom_description), + studyTime = timerSelectionActions.customTimeStudyTime + ) + val context = LocalContext.current + + TimerEntry( + timerInfo = timerInfo, + leftButton = { + StealthButton( + text = R.string.start, + onClick = { timerSelectionActions.startSession(timerInfo) } + ) + }, + rightButton = { + NotInternationalisedButton( + text = String.format("%02d:%02d", timerInfo.studyTime / 3600, (timerInfo.studyTime % 3600) / 60), + onClick = { timerSelectionActions.pickDuration(context) } + ) + } + ) +} + @Preview @Composable fun TimerSelectionPreview() { TimerSelectionScreen( - timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { _, _ -> {}}), + timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { {} }, 0), popUp = {} ) } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionViewModel.kt index c555bfa..ab42973 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionViewModel.kt @@ -1,5 +1,9 @@ package be.ugent.sel.studeez.screens.timer_selection +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import be.ugent.sel.studeez.data.SelectedTimerState import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.domain.LogService @@ -17,6 +21,8 @@ class TimerSelectionViewModel @Inject constructor( logService: LogService ) : StudeezViewModel(logService) { + var customTimerStudyTime: MutableState = mutableStateOf(0) + fun getAllTimers() : Flow> { return timerDAO.getAllTimers() } From 0a409421a85300686021b6670fcdd08aca74bc65 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 10:09:13 +0200 Subject: [PATCH 06/23] Cleanup destinations --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 90 ++++++++++--------- .../composable/drawer/DrawerComposable.kt | 11 ++- .../composable/drawer/DrawerViewModel.kt | 16 +++- .../navbar/NavigationBarComposable.kt | 8 +- .../navbar/NavigationBarViewModel.kt | 6 +- .../studeez/navigation/StudeezDestinations.kt | 26 +++--- .../sel/studeez/screens/home/HomeScreen.kt | 2 +- 7 files changed, 93 insertions(+), 66 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index c8a133b..ae460ff 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -91,7 +91,7 @@ fun resources(): Resources { @Composable fun StudeezNavGraph( appState: StudeezAppstate, - modifier: Modifier, + modifier: Modifier = Modifier, ) { val drawerViewModel: DrawerViewModel = hiltViewModel() val navBarViewModel: NavigationBarViewModel = hiltViewModel() @@ -113,8 +113,46 @@ fun StudeezNavGraph( startDestination = StudeezDestinations.SPLASH_SCREEN, modifier = modifier, ) { + // NavBar + composable(StudeezDestinations.HOME_SCREEN) { + HomeRoute( + open, + viewModel = hiltViewModel(), + drawerActions = drawerActions, + navigationBarActions = navigationBarActions, + ) + } + composable(StudeezDestinations.TASKS_SCREEN) { + // TODO + } + composable(StudeezDestinations.SESSIONS_SCREEN) { + // TODO + } + + composable(StudeezDestinations.PROFILE_SCREEN) { + ProfileRoute( + open, + viewModel = hiltViewModel(), + drawerActions = drawerActions, + navigationBarActions = navigationBarActions, + ) + } + + // Drawer + composable(StudeezDestinations.TIMER_SCREEN) { + TimerOverviewRoute( + viewModel = hiltViewModel(), + drawerActions = drawerActions, + ) + } + + composable(StudeezDestinations.SETTINGS_SCREEN) { + // TODO + } + + // Login flow composable(StudeezDestinations.SPLASH_SCREEN) { SplashRoute( openAndPopUp, @@ -136,31 +174,12 @@ fun StudeezNavGraph( ) } - composable(StudeezDestinations.HOME_SCREEN) { - HomeRoute( + // Studying flow + composable(StudeezDestinations.TIMER_SELECTION_SCREEN) { + TimerSelectionRoute( open, + goBack, viewModel = hiltViewModel(), - drawerActions = drawerActions, - navigationBarActions = navigationBarActions, - ) - } - - // TODO Tasks screen - // TODO Sessions screen - - composable(StudeezDestinations.PROFILE_SCREEN) { - ProfileRoute( - open, - viewModel = hiltViewModel(), - drawerActions = drawerActions, - navigationBarActions = navigationBarActions, - ) - } - - composable(StudeezDestinations.TIMER_OVERVIEW_SCREEN) { - TimerOverviewRoute( - viewModel = hiltViewModel(), - drawerActions = drawerActions, ) } @@ -172,8 +191,12 @@ fun StudeezNavGraph( ) } - // TODO Timers screen - // TODO Settings screen + composable(StudeezDestinations.SESSION_RECAP) { + SessionRecapRoute( + openAndPopUp = openAndPopUp, + viewModel = hiltViewModel() + ) + } // Edit screens composable(StudeezDestinations.EDIT_PROFILE_SCREEN) { @@ -183,20 +206,5 @@ fun StudeezNavGraph( viewModel = hiltViewModel(), ) } - - composable(StudeezDestinations.TIMER_SELECTION_SCREEN) { - TimerSelectionRoute( - open, - goBack, - viewModel = hiltViewModel(), - ) - } - - composable(StudeezDestinations.SESSION_RECAP) { - SessionRecapRoute( - openAndPopUp = openAndPopUp, - viewModel = hiltViewModel() - ) - } } } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt index 47571f5..9510b0d 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt @@ -1,5 +1,6 @@ package be.ugent.sel.studeez.common.composable.drawer +import android.content.Context import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -16,6 +17,7 @@ import androidx.compose.material.icons.outlined.Info import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.vectorResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -28,7 +30,7 @@ data class DrawerActions( val onTimersClick: () -> Unit, val onSettingsClick: () -> Unit, val onLogoutClick: () -> Unit, - val onAboutClick: () -> Unit, + val onAboutClick: (Context) -> Unit, ) fun getDrawerActions( @@ -41,7 +43,9 @@ fun getDrawerActions( onTimersClick = { drawerViewModel.onTimersClick(open) }, onSettingsClick = { drawerViewModel.onSettingsClick(open) }, onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) }, - onAboutClick = { drawerViewModel.onAboutClick(open) }, + onAboutClick = { context -> + drawerViewModel.onAboutClick(open, context = context) + }, ) } @@ -79,10 +83,11 @@ fun Drawer( ) } + val context = LocalContext.current DrawerEntry( icon = Icons.Outlined.Info, text = resources().getString(R.string.about), - onClick = drawerActions.onAboutClick, + onClick = { drawerActions.onAboutClick(context) }, ) } } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerViewModel.kt index d16d930..e55c342 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerViewModel.kt @@ -1,5 +1,10 @@ package be.ugent.sel.studeez.common.composable.drawer +import android.content.Context +import android.content.Intent +import android.net.Uri +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.LocalContext import be.ugent.sel.studeez.domain.AccountDAO import be.ugent.sel.studeez.domain.LogService import be.ugent.sel.studeez.navigation.StudeezDestinations @@ -9,6 +14,8 @@ import be.ugent.sel.studeez.screens.StudeezViewModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +const val REPO_URL: String = "https://github.ugent.be/SELab1/project2023-groep14/" + @HiltViewModel class DrawerViewModel @Inject constructor( private val accountDAO: AccountDAO, @@ -20,11 +27,11 @@ class DrawerViewModel @Inject constructor( } fun onTimersClick(openAndPopup: (String) -> Unit) { - openAndPopup(StudeezDestinations.TIMER_OVERVIEW_SCREEN) + openAndPopup(StudeezDestinations.TIMER_SCREEN) } fun onSettingsClick(open: (String) -> Unit) { - // TODO + open(StudeezDestinations.SETTINGS_SCREEN) } fun onLogoutClick(openAndPopUp: (String, String) -> Unit) { @@ -34,7 +41,8 @@ class DrawerViewModel @Inject constructor( } } - fun onAboutClick(open: (String) -> Unit) { - // TODO + fun onAboutClick(open: (String) -> Unit, context: Context) { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(REPO_URL)) + context.startActivity(intent) } } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt index 79186b5..d84910e 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt @@ -14,6 +14,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN import be.ugent.sel.studeez.resources import be.ugent.sel.studeez.ui.theme.StudeezTheme import be.ugent.sel.studeez.R.string as AppText @@ -71,8 +73,7 @@ fun NavigationBar( ) }, label = { Text(text = resources().getString(AppText.tasks)) }, - // TODO selected = navigationBarActions.isSelectedTab(TASKS_SCREEN), - selected = false, + selected = navigationBarActions.isSelectedTab(TASKS_SCREEN), onClick = navigationBarActions.onTasksClick ) @@ -86,8 +87,7 @@ fun NavigationBar( ) }, label = { Text(text = resources().getString(AppText.sessions)) }, - // TODO selected = navigationBarActions.isSelectedTab(SESSIONS_SCREEN), - selected = false, + selected = navigationBarActions.isSelectedTab(SESSIONS_SCREEN), onClick = navigationBarActions.onSessionsClick ) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt index 1e4bd0d..8c68832 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt @@ -4,6 +4,8 @@ import be.ugent.sel.studeez.domain.AccountDAO import be.ugent.sel.studeez.domain.LogService import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN import be.ugent.sel.studeez.screens.StudeezViewModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -19,11 +21,11 @@ class NavigationBarViewModel @Inject constructor( } fun onTasksClick(open: (String) -> Unit) { - // TODO + open(TASKS_SCREEN) } fun onSessionsClick(open: (String) -> Unit) { - // TODO + open(SESSIONS_SCREEN) } fun onProfileClick(open: (String) -> Unit) { diff --git a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt index ab10c22..bb78b0b 100644 --- a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt +++ b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt @@ -1,21 +1,25 @@ package be.ugent.sel.studeez.navigation object StudeezDestinations { - const val SPLASH_SCREEN = "splash" - const val SIGN_UP_SCREEN = "signup" - const val LOGIN_SCREEN = "login" - + // NavBar const val HOME_SCREEN = "home" - const val TIMER_OVERVIEW_SCREEN = "timer_overview" + const val TASKS_SCREEN = "tasks" + const val SESSIONS_SCREEN = "sessions" + const val PROFILE_SCREEN = "profile" + + // Drawer + const val TIMER_SCREEN = "timer_overview" + const val SETTINGS_SCREEN = "settings" + + // Login flow + const val SPLASH_SCREEN = "splash" + const val LOGIN_SCREEN = "login" + const val SIGN_UP_SCREEN = "signup" + + // Studying flow const val TIMER_SELECTION_SCREEN = "timer_selection" const val SESSION_SCREEN = "session" const val SESSION_RECAP = "session_recap" - // const val TASKS_SCREEN = "tasks" - // const val SESSIONS_SCREEN = "sessions" - const val PROFILE_SCREEN = "profile" - -// const val TIMERS_SCREEN = "timers" -// const val SETTINGS_SCREEN = "settings" // Edit screens const val EDIT_PROFILE_SCREEN = "edit_profile" diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt index 1f760e5..1e9be33 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt @@ -39,7 +39,7 @@ fun HomeScreen( title = resources().getString(R.string.home), drawerActions = drawerActions, navigationBarActions = navigationBarActions, - barAction = { FriendsAction() } + // TODO barAction = { FriendsAction() } ) { BasicButton(R.string.start_session, Modifier.basicButton()) { onStartSessionClick() From da79195e8da8b03513e1a4f30d3edd8e13d82872 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 12:35:08 +0200 Subject: [PATCH 07/23] #67 working popup, not styled --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 33 +++---- .../FloatingActionButtonComposable.kt | 85 ++++++++++++++++--- .../composable/PrimaryScreenComposable.kt | 10 ++- .../navbar/NavigationBarComposable.kt | 21 ++++- .../navbar/NavigationBarViewModel.kt | 15 ++++ .../studeez/navigation/StudeezDestinations.kt | 7 +- .../sel/studeez/screens/home/HomeScreen.kt | 4 +- .../studeez/screens/profile/ProfileScreen.kt | 2 +- 8 files changed, 141 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index ae460ff..584649f 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -2,18 +2,8 @@ package be.ugent.sel.studeez import android.content.res.Resources import androidx.compose.foundation.layout.padding -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.ScaffoldState -import androidx.compose.material.Snackbar -import androidx.compose.material.SnackbarHost -import androidx.compose.material.Surface -import androidx.compose.material.rememberScaffoldState -import androidx.compose.runtime.Composable -import androidx.compose.runtime.ReadOnlyComposable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.material.* +import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext @@ -119,7 +109,7 @@ fun StudeezNavGraph( open, viewModel = hiltViewModel(), drawerActions = drawerActions, - navigationBarActions = navigationBarActions, + navigationBarActions = navigationBarActions ) } @@ -136,7 +126,7 @@ fun StudeezNavGraph( open, viewModel = hiltViewModel(), drawerActions = drawerActions, - navigationBarActions = navigationBarActions, + navigationBarActions = navigationBarActions ) } @@ -198,7 +188,20 @@ fun StudeezNavGraph( ) } - // Edit screens + // Friends flow + composable(StudeezDestinations.SEARCH_FRIENDS_SCREEN) { + // TODO + } + + // Create & edit screens + composable(StudeezDestinations.CREATE_TASK_SCREEN) { + // TODO + } + + composable(StudeezDestinations.CREATE_SESSION_SCREEN) { + // TODO + } + composable(StudeezDestinations.EDIT_PROFILE_SCREEN) { EditProfileRoute( goBack, diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt index 15005fa..078d6fb 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt @@ -1,5 +1,8 @@ package be.ugent.sel.studeez.common.composable +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.updateTransition +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.material.FloatingActionButton @@ -11,36 +14,88 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.DateRange import androidx.compose.material.icons.filled.Person -import androidx.compose.runtime.Composable +import androidx.compose.runtime.* import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.rotate import androidx.compose.ui.tooling.preview.Preview import be.ugent.sel.studeez.ui.theme.StudeezTheme +const val TRANSITION = "transition" +enum class MultiFloatingState { + Expanded, + Collapsed +} + +data class AddButtonActions( + val onTaskClick: () -> Unit, + val onFriendClick: () -> Unit, + val onSessionClick: () -> Unit +) + @Composable -fun CollapsedAddButton() { - FloatingActionButton( - onClick = { /* TODO popup add options */ } +fun AddButton( + addButtonActions: AddButtonActions +) { + var multiFloatingState by remember { + mutableStateOf(MultiFloatingState.Collapsed) + } + + // Rotate the button when expanded, normal when collapsed. + val transition = updateTransition(targetState = multiFloatingState, label = TRANSITION) + val rotate by transition.animateFloat(label = TRANSITION) { + when (it) { + MultiFloatingState.Expanded -> 315f + MultiFloatingState.Collapsed -> 0f + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Top ) { - Icon(imageVector = Icons.Default.Add, contentDescription = "fab") + // Show minis when expanded. + if (multiFloatingState == MultiFloatingState.Expanded) { + ExpandedAddButton(addButtonActions = addButtonActions) + } + + // The base add button + FloatingActionButton( + onClick = { + // Toggle expanded/collapsed. + multiFloatingState = when (transition.currentState) { + MultiFloatingState.Collapsed -> MultiFloatingState.Expanded + MultiFloatingState.Expanded -> MultiFloatingState.Collapsed + } + } + ) { + Icon( + imageVector = Icons.Default.Add, + contentDescription = "fab", + modifier = Modifier.rotate(rotate) // The rotation + ) + } } } @Composable -fun ExpandedAddButton() { - Row() { - IconButton(onClick = { /* TODO Go to next step */ }) { +fun ExpandedAddButton( + addButtonActions: AddButtonActions +) { + Row { + IconButton(onClick = addButtonActions.onTaskClick) { Column (horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.Check, contentDescription = "Task") Text(text = "Task") } } - IconButton(onClick = { /* TODO Go to next step */ }) { + IconButton(onClick = addButtonActions.onFriendClick) { Column (horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.Person, contentDescription = "Friend") Text(text = "Friend") } } - IconButton(onClick = { /* TODO Go to next step */ }) { + IconButton(onClick = addButtonActions.onSessionClick) { Column (horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.DateRange, contentDescription = "Session") Text(text = "Session") @@ -51,12 +106,16 @@ fun ExpandedAddButton() { @Preview @Composable -fun CollapsedAddButtonPreview() { - StudeezTheme { CollapsedAddButton() } +fun AddButtonPreview() { + StudeezTheme { AddButton( + addButtonActions = AddButtonActions({}, {}, {}) + )} } @Preview @Composable fun ExpandedAddButtonPreview() { - StudeezTheme { ExpandedAddButton() } + StudeezTheme { ExpandedAddButton( + addButtonActions = AddButtonActions({}, {}, {}) + ) } } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt index 79dec41..0cbfb0b 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt @@ -56,8 +56,12 @@ fun PrimaryScreenTemplate( bottomBar = { NavigationBar(navigationBarActions) }, floatingActionButtonPosition = FabPosition.Center, - isFloatingActionButtonDocked = true, - floatingActionButton = { CollapsedAddButton() } + isFloatingActionButtonDocked = false, + floatingActionButton = { AddButton(AddButtonActions( + onTaskClick = navigationBarActions.onAddTaskClick, + onFriendClick = navigationBarActions.onAddFriendClick, + onSessionClick = navigationBarActions.onAddSessionClick + )) } ) { content(it) } @@ -70,7 +74,7 @@ fun PrimaryScreenPreview() { PrimaryScreenTemplate( "Preview screen", DrawerActions({}, {}, {}, {}, {}), - NavigationBarActions({ false }, {}, {}, {}, {}), + NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {}), { IconButton(onClick = { /*TODO*/ }) { Icon( diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt index d84910e..b2393d8 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt @@ -22,10 +22,16 @@ import be.ugent.sel.studeez.R.string as AppText data class NavigationBarActions( val isSelectedTab: (String) -> Boolean, + val onHomeClick: () -> Unit, val onTasksClick: () -> Unit, val onSessionsClick: () -> Unit, val onProfileClick: () -> Unit, + + // AddButton + val onAddTaskClick: () -> Unit, + val onAddFriendClick: () -> Unit, + val onAddSessionClick: () -> Unit ) fun getNavigationBarActions( @@ -37,6 +43,7 @@ fun getNavigationBarActions( isSelectedTab = { screen -> screen == getCurrentScreen() }, + onHomeClick = { navigationBarViewModel.onHomeClick(open) }, @@ -49,6 +56,18 @@ fun getNavigationBarActions( onProfileClick = { navigationBarViewModel.onProfileClick(open) }, + + onAddTaskClick = { + navigationBarViewModel.onAddTaskClick(open) + }, + + onAddFriendClick = { + navigationBarViewModel.onAddFriendClick(open) + }, + + onAddSessionClick = { + navigationBarViewModel.onAddSessionClick(open) + } ) } @@ -110,7 +129,7 @@ fun NavigationBar( fun NavigationBarPreview() { StudeezTheme { NavigationBar( - navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}), + navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {}), ) } } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt index 8c68832..ab9256b 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt @@ -2,8 +2,11 @@ package be.ugent.sel.studeez.common.composable.navbar import be.ugent.sel.studeez.domain.AccountDAO import be.ugent.sel.studeez.domain.LogService +import be.ugent.sel.studeez.navigation.StudeezDestinations.CREATE_SESSION_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.CREATE_TASK_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN +import be.ugent.sel.studeez.navigation.StudeezDestinations.SEARCH_FRIENDS_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN import be.ugent.sel.studeez.screens.StudeezViewModel @@ -31,4 +34,16 @@ class NavigationBarViewModel @Inject constructor( fun onProfileClick(open: (String) -> Unit) { open(PROFILE_SCREEN) } + + fun onAddTaskClick(open: (String) -> Unit) { + open(CREATE_TASK_SCREEN) + } + + fun onAddFriendClick(open: (String) -> Unit) { + open(SEARCH_FRIENDS_SCREEN) + } + + fun onAddSessionClick(open: (String) -> Unit) { + open(CREATE_SESSION_SCREEN) + } } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt index bb78b0b..0d55dec 100644 --- a/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt +++ b/app/src/main/java/be/ugent/sel/studeez/navigation/StudeezDestinations.kt @@ -21,6 +21,11 @@ object StudeezDestinations { const val SESSION_SCREEN = "session" const val SESSION_RECAP = "session_recap" - // Edit screens + // Friends flow + const val SEARCH_FRIENDS_SCREEN = "search_friends" + + // Create & edit screens + const val CREATE_TASK_SCREEN = "create_task" + const val CREATE_SESSION_SCREEN = "create_session" const val EDIT_PROFILE_SCREEN = "edit_profile" } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt index 1e9be33..f02852e 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/home/HomeScreen.kt @@ -33,7 +33,7 @@ fun HomeRoute( fun HomeScreen( onStartSessionClick: () -> Unit, drawerActions: DrawerActions, - navigationBarActions: NavigationBarActions, + navigationBarActions: NavigationBarActions ) { PrimaryScreenTemplate( title = resources().getString(R.string.home), @@ -63,6 +63,6 @@ fun HomeScreenPreview() { HomeScreen( onStartSessionClick = {}, drawerActions = DrawerActions({}, {}, {}, {}, {}), - navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}) + navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {}) ) } diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileScreen.kt index 0b4a67f..9c76337 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileScreen.kt @@ -88,6 +88,6 @@ fun ProfileScreenPreview() { ProfileScreen( profileActions = ProfileActions({ null }, {}), drawerActions = DrawerActions({}, {}, {}, {}, {}), - navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}) + navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {}) ) } \ No newline at end of file From 2c62e13caad4ea6eb128818c27a86872123d0359 Mon Sep 17 00:00:00 2001 From: lbarraga Date: Mon, 1 May 2023 12:51:46 +0200 Subject: [PATCH 08/23] timepicker button met popup-klok functionaliteit --- .../composable/TimePickerButtonComposable.kt | 47 +++++++++++++++++++ .../ugent/sel/studeez/data/EditTimerState.kt | 4 ++ .../models/timer_info/TimerInfoVisitor.kt | 4 ++ .../screens/timer_edit/GetTimerEditScreen.kt | 35 ++++++++++++++ .../screens/timer_edit/TimerEditScreen.kt | 2 + .../screens/timer_edit/TimerEditViewModel.kt | 4 ++ .../editScreens/AbstractTimerEditScreen.kt | 4 ++ .../editScreens/BreakTimerEditScreen.kt | 4 ++ .../editScreens/CustomTimerEditScreen.kt | 4 ++ .../editScreens/EndlessTimerEditScreen.kt | 4 ++ 10 files changed, 112 insertions(+) create mode 100644 app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/data/EditTimerState.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/GetTimerEditScreen.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditScreen.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditViewModel.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/AbstractTimerEditScreen.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/BreakTimerEditScreen.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/CustomTimerEditScreen.kt create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/EndlessTimerEditScreen.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt new file mode 100644 index 0000000..869d724 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt @@ -0,0 +1,47 @@ +package be.ugent.sel.studeez.common.composable + +import android.app.TimePickerDialog +import android.app.TimePickerDialog.OnTimeSetListener +import android.content.Context +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button +import androidx.compose.material.ButtonColors +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp +import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds +import java.util.* + +// TODO codeduplicatie met Tibo, later wegdoen +@Composable +fun TimePickerButton( + hoursMinutesSeconds: HoursMinutesSeconds, + modifier: Modifier = Modifier, + colors: ButtonColors = ButtonDefaults.buttonColors(), + border: BorderStroke? = null, + onTimeSetListener: OnTimeSetListener +) { + val context = LocalContext.current + Button( + onClick = { pickDuration(context, onTimeSetListener) }, + modifier = modifier, + shape = RoundedCornerShape(20.dp), + colors = colors, + border = border + ) { + Text(text = hoursMinutesSeconds.toString()) + } +} + +// TODO idem codedup Tibo +private fun pickDuration(context: Context, listener: OnTimeSetListener) { + val mCalendar = Calendar.getInstance() + val mHour = mCalendar[Calendar.HOUR] + val mMinute = mCalendar[Calendar.MINUTE] + val mTimePickerDialog = TimePickerDialog(context, listener, mHour, mMinute, true) + mTimePickerDialog.show() +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/EditTimerState.kt b/app/src/main/java/be/ugent/sel/studeez/data/EditTimerState.kt new file mode 100644 index 0000000..9686e94 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/data/EditTimerState.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.data + +class EditTimerState { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt new file mode 100644 index 0000000..0dedc94 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.data.local.models.timer_info + +interface TimerInfoVisitor { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/GetTimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/GetTimerEditScreen.kt new file mode 100644 index 0000000..c6579e8 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/GetTimerEditScreen.kt @@ -0,0 +1,35 @@ +package be.ugent.sel.studeez.screens.timer_edit + +import android.annotation.SuppressLint +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import be.ugent.sel.studeez.R +import be.ugent.sel.studeez.common.composable.BasicButton +import be.ugent.sel.studeez.common.ext.basicButton +import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo +import be.ugent.sel.studeez.data.local.models.timer_info.EndlessTimerInfo +import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo +import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfoVisitor + +class GetTimerEditView: TimerInfoVisitor { + + @SuppressLint("ComposableNaming") + override fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo) { + + } + + @SuppressLint("ComposableNaming") + override fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo) { + + } + + @SuppressLint("ComposableNaming") + override fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo) { + + } + + +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditScreen.kt new file mode 100644 index 0000000..ac1ff8a --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditScreen.kt @@ -0,0 +1,2 @@ +package be.ugent.sel.studeez.screens.timer_edit + diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditViewModel.kt new file mode 100644 index 0000000..20f5952 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/TimerEditViewModel.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.screens.timer_edit + +class TimerEditViewModel { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/AbstractTimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/AbstractTimerEditScreen.kt new file mode 100644 index 0000000..59b04e7 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/AbstractTimerEditScreen.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.screens.timer_edit + +abstract class AbstractTimerEditScreen { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/BreakTimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/BreakTimerEditScreen.kt new file mode 100644 index 0000000..1405682 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/BreakTimerEditScreen.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.screens.timer_edit.editScreens + +class BreakTimerEditScreen { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/CustomTimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/CustomTimerEditScreen.kt new file mode 100644 index 0000000..bbe66ec --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/CustomTimerEditScreen.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.screens.timer_edit + +class CustomTimerEditScreen { +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/EndlessTimerEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/EndlessTimerEditScreen.kt new file mode 100644 index 0000000..5c6263d --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_edit/editScreens/EndlessTimerEditScreen.kt @@ -0,0 +1,4 @@ +package be.ugent.sel.studeez.screens.timer_edit.editScreens + +class EndlessTimerEditScreen { +} \ No newline at end of file From 7046a2a98546c9799038079fd866821daddd3301 Mon Sep 17 00:00:00 2001 From: lbarraga Date: Mon, 1 May 2023 12:53:35 +0200 Subject: [PATCH 09/23] HMS now takes ints and has totalseconds and tostring functions --- .../timer_functional/HoursMinutesSeconds.kt | 15 +++++++++++++-- .../data/local/models/timer_functional/Time.kt | 6 +----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/HoursMinutesSeconds.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/HoursMinutesSeconds.kt index 856aa26..2f630c9 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/HoursMinutesSeconds.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/HoursMinutesSeconds.kt @@ -1,4 +1,15 @@ package be.ugent.sel.studeez.data.local.models.timer_functional -data class HoursMinutesSeconds(val hours: String, val minutes: String, val seconds: String -) \ No newline at end of file +data class HoursMinutesSeconds(val hours: Int, val minutes: Int, val seconds: Int) { + + fun getTotalSeconds(): Int { + return hours * 60 * 60 + minutes * 60 + seconds + } + + override fun toString(): String { + val hoursString = hours.toString().padStart(2, '0') + val minutesString = minutes.toString().padStart(2, '0') + val secondsString = seconds.toString().padStart(2, '0') + return "$hoursString : $minutesString : $secondsString" + } +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/Time.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/Time.kt index ec7702d..c512d96 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/Time.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/Time.kt @@ -17,11 +17,7 @@ class Time(initialTime: Int) { val minutes: Int = (time / (60)) % 60 val seconds: Int = time % 60 - return HoursMinutesSeconds( - hours.toString().padStart(2, '0'), - minutes.toString().padStart(2, '0'), - seconds.toString().padStart(2, '0') - ) + return HoursMinutesSeconds(hours, minutes, seconds) } } \ No newline at end of file From 964cd8a6ae816ff08a59b7a32f6cf021f37b212c Mon Sep 17 00:00:00 2001 From: lbarraga Date: Mon, 1 May 2023 12:54:24 +0200 Subject: [PATCH 10/23] added singleLine parameter (default false) --- .../sel/studeez/common/composable/TextFieldComposable.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/TextFieldComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/TextFieldComposable.kt index 2c0b450..47dbb0b 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/TextFieldComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/TextFieldComposable.kt @@ -41,10 +41,12 @@ fun BasicField( fun LabelledInputField( value: String, onNewValue: (String) -> Unit, - @StringRes label: Int + @StringRes label: Int, + singleLine: Boolean = false ) { OutlinedTextField( value = value, + singleLine = singleLine, onValueChange = onNewValue, label = { Text(text = stringResource(id = label)) }, modifier = Modifier.fieldModifier() From 3c73c5a853d412fddb44cf19bf235a7b3156d2e9 Mon Sep 17 00:00:00 2001 From: lbarraga Date: Mon, 1 May 2023 12:56:50 +0200 Subject: [PATCH 11/23] added visitor to TimerInfo --- .../data/local/models/timer_info/CustomTimerInfo.kt | 5 ++++- .../data/local/models/timer_info/EndlessTimerInfo.kt | 4 ++++ .../data/local/models/timer_info/PomodoroTimerInfo.kt | 11 ++++++++--- .../studeez/data/local/models/timer_info/TimerInfo.kt | 5 +++-- .../data/local/models/timer_info/TimerInfoVisitor.kt | 9 ++++++++- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt index d33ecc4..d88e39f 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/CustomTimerInfo.kt @@ -10,7 +10,6 @@ class CustomTimerInfo( id: String = "" ): TimerInfo(id, name, description) { - override fun getFunctionalTimer(): FunctionalTimer { return FunctionalCustomTimer(studyTime) } @@ -24,4 +23,8 @@ class CustomTimerInfo( ) } + override fun accept(visitor: TimerInfoVisitor): T { + return visitor.visitCustomTimerInfo(this) + } + } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/EndlessTimerInfo.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/EndlessTimerInfo.kt index d459a4e..45f7fd7 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/EndlessTimerInfo.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/EndlessTimerInfo.kt @@ -22,4 +22,8 @@ class EndlessTimerInfo( ) } + override fun accept(visitor: TimerInfoVisitor): T { + return visitor.visitEndlessTimerInfo(this) + } + } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/PomodoroTimerInfo.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/PomodoroTimerInfo.kt index 18bcea6..dbbb0be 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/PomodoroTimerInfo.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/PomodoroTimerInfo.kt @@ -2,13 +2,14 @@ package be.ugent.sel.studeez.data.local.models.timer_info import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer +import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimerVisitor class PomodoroTimerInfo( name: String, description: String, - private val studyTime: Int, - private val breakTime: Int, - private val repeats: Int, + val studyTime: Int, + val breakTime: Int, + val repeats: Int, id: String = "" ): TimerInfo(id, name, description) { @@ -28,4 +29,8 @@ class PomodoroTimerInfo( ) } + override fun accept(visitor: TimerInfoVisitor): T { + return visitor.visitBreakTimerInfo(this) + } + } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfo.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfo.kt index 343e7e3..e4deded 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfo.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfo.kt @@ -7,8 +7,8 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer */ abstract class TimerInfo( val id: String, - val name: String, - val description: String + var name: String, + var description: String ) { /** @@ -21,6 +21,7 @@ abstract class TimerInfo( * TODO implementaties hebben nog hardgecodeerde strings. */ abstract fun asJson(): Map + abstract fun accept(visitor: TimerInfoVisitor): T } diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt index 0dedc94..e331c8d 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_info/TimerInfoVisitor.kt @@ -1,4 +1,11 @@ package be.ugent.sel.studeez.data.local.models.timer_info -interface TimerInfoVisitor { +interface TimerInfoVisitor { + + fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo): T + + fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo): T + + fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo): T + } \ No newline at end of file From 89b9c231237c7135ef7f5195725fc495ff14cdd7 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 13:32:52 +0200 Subject: [PATCH 12/23] Use TimePickerButton --- .../composable/TimePickerButtonComposable.kt | 15 +++++---- .../timer_selection/TimerSelectionScreen.kt | 33 +++++++------------ 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt index 869d724..02bd0d7 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/TimePickerButtonComposable.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.unit.dp import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds import java.util.* -// TODO codeduplicatie met Tibo, later wegdoen @Composable fun TimePickerButton( hoursMinutesSeconds: HoursMinutesSeconds, @@ -37,11 +36,13 @@ fun TimePickerButton( } } -// TODO idem codedup Tibo private fun pickDuration(context: Context, listener: OnTimeSetListener) { - val mCalendar = Calendar.getInstance() - val mHour = mCalendar[Calendar.HOUR] - val mMinute = mCalendar[Calendar.MINUTE] - val mTimePickerDialog = TimePickerDialog(context, listener, mHour, mMinute, true) - mTimePickerDialog.show() + val timePickerDialog = TimePickerDialog( + context, + listener, + 0, + 0, + true + ) + timePickerDialog.show() } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt index 780b50a..5ef775e 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt @@ -1,7 +1,6 @@ package be.ugent.sel.studeez.screens.timer_selection -import android.app.TimePickerDialog -import android.content.Context +import android.widget.TimePicker import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable @@ -9,10 +8,12 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import be.ugent.sel.studeez.R -import be.ugent.sel.studeez.common.composable.NotInternationalisedButton import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate import be.ugent.sel.studeez.common.composable.StealthButton +import be.ugent.sel.studeez.common.composable.TimePickerButton import be.ugent.sel.studeez.common.composable.TimerEntry +import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds +import be.ugent.sel.studeez.data.local.models.timer_functional.Time import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.resources @@ -22,7 +23,7 @@ import kotlinx.coroutines.flow.flowOf data class TimerSelectionActions( val getAllTimers: () -> Flow>, val startSession: (TimerInfo) -> Unit, - val pickDuration: (Context) -> Unit, + val pickDuration: (TimePicker?, Int, Int) -> Unit, val customTimeStudyTime: Int ) @@ -33,18 +34,8 @@ fun getTimerSelectionActions( return TimerSelectionActions( getAllTimers = viewModel::getAllTimers, startSession = { viewModel.startSession(open, it) }, - pickDuration = { context -> - val dialog = TimePickerDialog( - context, - { _, hour: Int, minute: Int -> - viewModel.customTimerStudyTime.value = hour * 60 * 60 + minute * 60 - }, - 0, - 0, - true - ) - - dialog.show() + pickDuration = { _, hour: Int, minute: Int -> + viewModel.customTimerStudyTime.value = hour * 60 * 60 + minute * 60 }, customTimeStudyTime = viewModel.customTimerStudyTime.value ) @@ -103,7 +94,7 @@ fun CustomTimerEntry( description = resources().getString(R.string.custom_description), studyTime = timerSelectionActions.customTimeStudyTime ) - val context = LocalContext.current + val hms: HoursMinutesSeconds = Time(timerInfo.studyTime).getAsHMS() TimerEntry( timerInfo = timerInfo, @@ -114,9 +105,9 @@ fun CustomTimerEntry( ) }, rightButton = { - NotInternationalisedButton( - text = String.format("%02d:%02d", timerInfo.studyTime / 3600, (timerInfo.studyTime % 3600) / 60), - onClick = { timerSelectionActions.pickDuration(context) } + TimePickerButton( + hoursMinutesSeconds = hms, + onTimeSetListener = timerSelectionActions.pickDuration ) } ) @@ -126,7 +117,7 @@ fun CustomTimerEntry( @Composable fun TimerSelectionPreview() { TimerSelectionScreen( - timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { {} }, 0), + timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { _, _, _ -> {} }, 0), popUp = {} ) } \ No newline at end of file From b2e29417958101368c289e8ea15b112e6ab0a1e9 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:04:40 +0200 Subject: [PATCH 13/23] Restructuring strings --- app/src/main/res/values/strings.xml | 69 ++++++++++++++++------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5b9f561..e6e4ddc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,6 @@ - + + Studeez Username Email @@ -7,34 +8,22 @@ Repeat password Menu - - Confirm - Save - Discard - Cancel - Go back - Next - Start + + Confirm + Save + Discard + Cancel + Go back + Next + Start - - Success! - Try again - Something wrong happened. Please try again. - Please insert a valid email. + + Success! + Try again + Something wrong happened. Please try again. + Please insert a valid email. - - Create account - Your password should have at least six characters and include one digit, one lower case letter and one upper case letter. - Passwords do not match. - Already have an account? Log in. - - - Don\'t have an account yet? Sign up. - Sign in - Enter your login details - Forgot password? Click to get recovery email. - Check your inbox for the recovery email. - Password cannot be empty. + Home @@ -54,10 +43,8 @@ Editing profile Delete profile - - Friends + - Log out Profile Picture Normal user @@ -81,4 +68,26 @@ About Studeez + + + + Create account + Your password should have at least six characters and include one digit, one lower case letter and one upper case letter. + Passwords do not match. + Already have an account? Log in. + + + Don\'t have an account yet? Sign up. + Sign in + Enter your login details + Forgot password? Click to get recovery email. + Check your inbox for the recovery email. + Password cannot be empty. + + + + + + Friends + From dfd97c8d33508bfc8de74d8b4246130d9b932834 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:13:18 +0200 Subject: [PATCH 14/23] Temp sessions screen for feedback --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 6 ++- .../screens/sessions/SessionsScreen.kt | 42 +++++++++++++++++++ app/src/main/res/values/strings.xml | 2 + 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/sessions/SessionsScreen.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index 584649f..9dfb136 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -28,6 +28,7 @@ import be.ugent.sel.studeez.screens.profile.EditProfileRoute import be.ugent.sel.studeez.screens.profile.ProfileRoute import be.ugent.sel.studeez.screens.session.SessionRoute import be.ugent.sel.studeez.screens.session_recap.SessionRecapRoute +import be.ugent.sel.studeez.screens.sessions.SessionsRoute import be.ugent.sel.studeez.screens.sign_up.SignUpRoute import be.ugent.sel.studeez.screens.splash.SplashRoute import be.ugent.sel.studeez.screens.timer_overview.TimerOverviewRoute @@ -118,7 +119,10 @@ fun StudeezNavGraph( } composable(StudeezDestinations.SESSIONS_SCREEN) { - // TODO + SessionsRoute( + drawerActions = drawerActions, + navigationBarActions = navigationBarActions + ) } composable(StudeezDestinations.PROFILE_SCREEN) { diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/sessions/SessionsScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/sessions/SessionsScreen.kt new file mode 100644 index 0000000..fe60ca8 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/sessions/SessionsScreen.kt @@ -0,0 +1,42 @@ +package be.ugent.sel.studeez.screens.sessions + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate +import be.ugent.sel.studeez.common.composable.drawer.DrawerActions +import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions +import be.ugent.sel.studeez.resources +import be.ugent.sel.studeez.R.string as AppText + +@Composable +fun SessionsRoute( + // viewModel: SessionsViewModel, + drawerActions: DrawerActions, + navigationBarActions: NavigationBarActions +) { + SessionsScreen( + drawerActions = drawerActions, + navigationBarActions = navigationBarActions + ) +} + +@Composable +fun SessionsScreen( + drawerActions: DrawerActions, + navigationBarActions: NavigationBarActions +) { + PrimaryScreenTemplate( + title = resources().getString(AppText.upcoming_sessions), + drawerActions = drawerActions, + navigationBarActions = navigationBarActions + ) { + Text( + text = resources().getString(AppText.sessions_temp_description), + modifier = Modifier.fillMaxSize(), + textAlign = TextAlign.Center + ) + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e6e4ddc..9922860 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,8 +33,10 @@ Tasks + Looks like you found the sessions screen! In here, your upcoming studying sessions with friends will be listed. You can accept invites or edit your own. Sessions End session + Upcoming sessions Profile From e458927c281a15f55724a9991d6e6b696f2cf60e Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:19:45 +0200 Subject: [PATCH 15/23] Temp settings screen for feedback --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 5 ++- .../screens/settings/SettingsScreen.kt | 37 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/screens/settings/SettingsScreen.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index 9dfb136..90f20fd 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -29,6 +29,7 @@ import be.ugent.sel.studeez.screens.profile.ProfileRoute import be.ugent.sel.studeez.screens.session.SessionRoute import be.ugent.sel.studeez.screens.session_recap.SessionRecapRoute import be.ugent.sel.studeez.screens.sessions.SessionsRoute +import be.ugent.sel.studeez.screens.settings.SettingsRoute import be.ugent.sel.studeez.screens.sign_up.SignUpRoute import be.ugent.sel.studeez.screens.splash.SplashRoute import be.ugent.sel.studeez.screens.timer_overview.TimerOverviewRoute @@ -143,7 +144,9 @@ fun StudeezNavGraph( } composable(StudeezDestinations.SETTINGS_SCREEN) { - // TODO + SettingsRoute( + drawerActions = drawerActions + ) } // Login flow diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/settings/SettingsScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/settings/SettingsScreen.kt new file mode 100644 index 0000000..e1098b7 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/screens/settings/SettingsScreen.kt @@ -0,0 +1,37 @@ +package be.ugent.sel.studeez.screens.settings + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign +import be.ugent.sel.studeez.common.composable.DrawerScreenTemplate +import be.ugent.sel.studeez.common.composable.drawer.DrawerActions +import be.ugent.sel.studeez.resources +import be.ugent.sel.studeez.R.string as AppText + +@Composable +fun SettingsRoute( + // viewModel: SettingsViewModel, + drawerActions: DrawerActions +) { + SettingsScreen( + drawerActions = drawerActions + ) +} + +@Composable +fun SettingsScreen( + drawerActions: DrawerActions +) { + DrawerScreenTemplate( + title = resources().getString(AppText.settings), + drawerActions = drawerActions + ) { + Text( + text = resources().getString(AppText.settings_temp_description), + modifier = Modifier.fillMaxSize(), + textAlign = TextAlign.Center + ) + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9922860..0ed2493 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,7 @@ Take a break! + Looks like you found the settings screen! In the future, this will enable you to edit your preferenes such as light/dark mode, end sessions automatically when we detect you are gone etc. Settings From 5a2632c08a96c6f253698d08e5de50c032a2fd3d Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:28:50 +0200 Subject: [PATCH 16/23] Add snackbars for missing features --- .../composable/navbar/NavigationBarComposable.kt | 2 -- .../composable/navbar/NavigationBarViewModel.kt | 14 ++++++++------ app/src/main/res/values/strings.xml | 9 +++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt index b2393d8..0c4110d 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt @@ -60,11 +60,9 @@ fun getNavigationBarActions( onAddTaskClick = { navigationBarViewModel.onAddTaskClick(open) }, - onAddFriendClick = { navigationBarViewModel.onAddFriendClick(open) }, - onAddSessionClick = { navigationBarViewModel.onAddSessionClick(open) } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt index ab9256b..e7678e5 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarViewModel.kt @@ -1,17 +1,16 @@ package be.ugent.sel.studeez.common.composable.navbar +import be.ugent.sel.studeez.common.snackbar.SnackbarManager import be.ugent.sel.studeez.domain.AccountDAO import be.ugent.sel.studeez.domain.LogService -import be.ugent.sel.studeez.navigation.StudeezDestinations.CREATE_SESSION_SCREEN -import be.ugent.sel.studeez.navigation.StudeezDestinations.CREATE_TASK_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN -import be.ugent.sel.studeez.navigation.StudeezDestinations.SEARCH_FRIENDS_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.SESSIONS_SCREEN import be.ugent.sel.studeez.navigation.StudeezDestinations.TASKS_SCREEN import be.ugent.sel.studeez.screens.StudeezViewModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import be.ugent.sel.studeez.R.string as AppText @HiltViewModel class NavigationBarViewModel @Inject constructor( @@ -36,14 +35,17 @@ class NavigationBarViewModel @Inject constructor( } fun onAddTaskClick(open: (String) -> Unit) { - open(CREATE_TASK_SCREEN) + // TODO open(CREATE_TASK_SCREEN) + SnackbarManager.showMessage(AppText.create_task_not_possible_yet) // TODO Remove } fun onAddFriendClick(open: (String) -> Unit) { - open(SEARCH_FRIENDS_SCREEN) + // TODO open(SEARCH_FRIENDS_SCREEN) + SnackbarManager.showMessage(AppText.add_friend_not_possible_yet) // TODO Remove } fun onAddSessionClick(open: (String) -> Unit) { - open(CREATE_SESSION_SCREEN) + // TODO open(CREATE_SESSION_SCREEN) + SnackbarManager.showMessage(AppText.create_session_not_possible_yet) // TODO Remove } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0ed2493..2608612 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -92,5 +92,14 @@ Friends + Adding friends still needs to be implemented. Hang on tight! + + + + + Creating tasks still needs to be implemented. Hang on tight! + + + Creating sessions still needs to be implemented. Hang on tight! From f74da5abc37e2caaffd6a620bce666c76b9705cf Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:45:35 +0200 Subject: [PATCH 17/23] #67 fab styling --- .../FloatingActionButtonComposable.kt | 20 +++++++++++++------ .../composable/drawer/DrawerComposable.kt | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt index 078d6fb..7ef6c2a 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt @@ -2,9 +2,7 @@ package be.ugent.sel.studeez.common.composable import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.updateTransition -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.* import androidx.compose.material.FloatingActionButton import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -19,9 +17,11 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import be.ugent.sel.studeez.ui.theme.StudeezTheme const val TRANSITION = "transition" +val HEIGHT_DIFFERENCE = 30.dp enum class MultiFloatingState { Expanded, Collapsed @@ -83,20 +83,28 @@ fun ExpandedAddButton( addButtonActions: AddButtonActions ) { Row { - IconButton(onClick = addButtonActions.onTaskClick) { + IconButton( + onClick = addButtonActions.onTaskClick, + modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) + ) { Column (horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.Check, contentDescription = "Task") Text(text = "Task") } } + IconButton(onClick = addButtonActions.onFriendClick) { Column (horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.Person, contentDescription = "Friend") Text(text = "Friend") } } - IconButton(onClick = addButtonActions.onSessionClick) { - Column (horizontalAlignment = Alignment.CenterHorizontally) { + + IconButton( + onClick = addButtonActions.onSessionClick, + modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) + ) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { Icon(imageVector = Icons.Default.DateRange, contentDescription = "Session") Text(text = "Session") } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt index 9510b0d..7b2d3f8 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt @@ -101,7 +101,7 @@ fun DrawerEntry( Row( horizontalArrangement = Arrangement.Center, modifier = Modifier - .clickable(onClick = { onClick() }) + .clickable(onClick = onClick) .fillMaxWidth() ) { Box( From e65c2fe0029a4f0a33f811503ee14237be8ea81c Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 21:33:51 +0200 Subject: [PATCH 18/23] #67 fab unfixed pos --- .../FloatingActionButtonComposable.kt | 76 +++++++++++++------ .../composable/PrimaryScreenComposable.kt | 2 +- .../navbar/NavigationBarComposable.kt | 2 +- .../be/ugent/sel/studeez/ui/theme/Theme.kt | 4 +- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt index 7ef6c2a..10ed586 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt @@ -2,7 +2,10 @@ package be.ugent.sel.studeez.common.composable import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.updateTransition -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding import androidx.compose.material.FloatingActionButton import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -16,9 +19,12 @@ import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import be.ugent.sel.studeez.resources import be.ugent.sel.studeez.ui.theme.StudeezTheme +import be.ugent.sel.studeez.R.string as AppText const val TRANSITION = "transition" val HEIGHT_DIFFERENCE = 30.dp @@ -56,7 +62,9 @@ fun AddButton( ) { // Show minis when expanded. if (multiFloatingState == MultiFloatingState.Expanded) { - ExpandedAddButton(addButtonActions = addButtonActions) + ExpandedAddButton( + addButtonActions = addButtonActions + ) } // The base add button @@ -83,35 +91,57 @@ fun ExpandedAddButton( addButtonActions: AddButtonActions ) { Row { - IconButton( + ExpandedEntry( + name = AppText.task, + imageVector = Icons.Default.Check, onClick = addButtonActions.onTaskClick, modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) - ) { - Column (horizontalAlignment = Alignment.CenterHorizontally) { - Icon(imageVector = Icons.Default.Check, contentDescription = "Task") - Text(text = "Task") - } - } + ) - IconButton(onClick = addButtonActions.onFriendClick) { - Column (horizontalAlignment = Alignment.CenterHorizontally) { - Icon(imageVector = Icons.Default.Person, contentDescription = "Friend") - Text(text = "Friend") - } - } + ExpandedEntry( + name = AppText.friend, + imageVector = Icons.Default.Person, + onClick = addButtonActions.onFriendClick + ) - IconButton( + ExpandedEntry( + name = AppText.session, + imageVector = Icons.Default.DateRange, onClick = addButtonActions.onSessionClick, modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) - ) { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Icon(imageVector = Icons.Default.DateRange, contentDescription = "Session") - Text(text = "Session") - } - } + ) } } +@Composable +fun ExpandedEntry( + name: Int, + imageVector: ImageVector, + onClick: () -> Unit, + modifier: Modifier = Modifier +) { + IconButton( + onClick = onClick, + modifier = modifier + ) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Icon( + imageVector = imageVector, + contentDescription = resources().getString(name), + // TODO Dark overlay + // tint = colors.surface + ) + Text( + text = resources().getString(name), + // TODO Dark overlay + // color = colors.surface + ) + } + + } + +} + @Preview @Composable fun AddButtonPreview() { @@ -123,7 +153,7 @@ fun AddButtonPreview() { @Preview @Composable fun ExpandedAddButtonPreview() { - StudeezTheme { ExpandedAddButton( + StudeezTheme { ExpandedAddButton ( addButtonActions = AddButtonActions({}, {}, {}) ) } } \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt index 0cbfb0b..0b3ee6e 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/PrimaryScreenComposable.kt @@ -56,7 +56,7 @@ fun PrimaryScreenTemplate( bottomBar = { NavigationBar(navigationBarActions) }, floatingActionButtonPosition = FabPosition.Center, - isFloatingActionButtonDocked = false, + isFloatingActionButtonDocked = true, floatingActionButton = { AddButton(AddButtonActions( onTaskClick = navigationBarActions.onAddTaskClick, onFriendClick = navigationBarActions.onAddFriendClick, diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt index 0c4110d..56b81eb 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/NavigationBarComposable.kt @@ -95,7 +95,7 @@ fun NavigationBar( ) // Hack to space the entries in the navigation bar, make space for fab - BottomNavigationItem(icon = {}, onClick = {}, selected = false) + BottomNavigationItem(icon = {}, onClick = {}, selected = false, enabled = false) BottomNavigationItem( icon = { diff --git a/app/src/main/java/be/ugent/sel/studeez/ui/theme/Theme.kt b/app/src/main/java/be/ugent/sel/studeez/ui/theme/Theme.kt index bc2c315..9a29e85 100644 --- a/app/src/main/java/be/ugent/sel/studeez/ui/theme/Theme.kt +++ b/app/src/main/java/be/ugent/sel/studeez/ui/theme/Theme.kt @@ -12,7 +12,9 @@ import androidx.compose.ui.graphics.Color private val DarkColorPalette = darkColors( primary = Blue100, primaryVariant = Blue120, - secondary = Yellow100 + secondary = Yellow100, + + onPrimary = Color.White ) private val LightColorPalette = lightColors( From 5788053c7544905711b8383708a4fb1813f33675 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 21:43:58 +0200 Subject: [PATCH 19/23] #67 fix fab position --- .../FloatingActionButtonComposable.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt index 10ed586..e62165f 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt @@ -2,10 +2,8 @@ package be.ugent.sel.studeez.common.composable import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.updateTransition -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.* import androidx.compose.material.FloatingActionButton import androidx.compose.material.Icon import androidx.compose.material.IconButton @@ -60,11 +58,13 @@ fun AddButton( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top ) { - // Show minis when expanded. - if (multiFloatingState == MultiFloatingState.Expanded) { - ExpandedAddButton( - addButtonActions = addButtonActions - ) + Box { + // Show minis when expanded. + if (multiFloatingState == MultiFloatingState.Expanded) { + ExpandedAddButton( + addButtonActions = addButtonActions + ) + } } // The base add button @@ -75,7 +75,8 @@ fun AddButton( MultiFloatingState.Collapsed -> MultiFloatingState.Expanded MultiFloatingState.Expanded -> MultiFloatingState.Collapsed } - } + }, + modifier = Modifier.padding(bottom = if (multiFloatingState == MultiFloatingState.Expanded) 78.dp else 0.dp) ) { Icon( imageVector = Icons.Default.Add, From 4b4c9539f83f5ac92fd959f35a715847d7655222 Mon Sep 17 00:00:00 2001 From: Rune Dyselinck Date: Tue, 2 May 2023 13:57:03 +0200 Subject: [PATCH 20/23] addTimer finished --- .../java/be/ugent/sel/studeez/StudeezApp.kt | 1 - .../composable/navbar/TimePickerComposable.kt | 24 +++ .../add_timer/AddTimerUiState.kt | 13 +- .../add_timer/AddTimerViewModel.kt | 34 +-- .../add_timer/addTimerScreen.kt | 201 +++++++++++------- .../timer_selection/TimerSelectionScreen.kt | 4 +- app/src/main/res/values/strings.xml | 15 ++ 7 files changed, 193 insertions(+), 99 deletions(-) create mode 100644 app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/TimePickerComposable.kt diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index be8ad00..d7465b0 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -172,7 +172,6 @@ fun StudeezNavGraph( composable(StudeezDestinations.ADD_TIMER_SCREEN) { AddTimerRoute( open = open, - openAndPopUp = openAndPopUp, goBack = goBack, viewModel = hiltViewModel() ) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/TimePickerComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/TimePickerComposable.kt new file mode 100644 index 0000000..3a59519 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/navbar/TimePickerComposable.kt @@ -0,0 +1,24 @@ +package be.ugent.sel.studeez.common.composable.navbar + +import android.app.TimePickerDialog +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +@Composable +fun BasicTimePicker( + onHoursChange: (Int) -> Unit, + onMinutesChange: (Int) -> Unit, + Hours: Int, + Minutes: Int, +): TimePickerDialog { + return TimePickerDialog( + LocalContext.current, + { _, mHour: Int, mMinute: Int -> + onHoursChange(mHour) + onMinutesChange(mMinute) + }, + Hours, + Minutes, + true + ) +} diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt index 9b17121..fcfa79a 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerUiState.kt @@ -1,11 +1,12 @@ package be.ugent.sel.studeez.screens.timer_overview.add_timer data class AddTimerUiState( - val studyTimeHours: Float = 1f, - val studyTimeMinutes: Float = 0f, + val studyTimeHours: Int = 1, + val studyTimeMinutes: Int = 0, val withBreaks: Boolean = false, - val breakTime: Float = 5f, - val repeats: Float = 1f, - val name: String = "", - val description: String = "", + val breakTimeMinutes: Int = 5, + val breakTimeHours: Int = 0, + val repeats: Int = 1, + val name: String = "Timer", + val description: String = "Long study session", ) \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt index 7e79e1e..d507974 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/AddTimerViewModel.kt @@ -3,7 +3,6 @@ package be.ugent.sel.studeez.screens.timer_overview.add_timer import androidx.compose.runtime.mutableStateOf import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo -import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo import be.ugent.sel.studeez.domain.LogService import be.ugent.sel.studeez.domain.TimerDAO import be.ugent.sel.studeez.screens.StudeezViewModel @@ -24,8 +23,11 @@ class AddTimerViewModel @Inject constructor( private val studyTimeMinutes get() = uiState.value.studyTimeMinutes - private val breakTime - get() = uiState.value.breakTime + private val breakTimeHours + get() = uiState.value.breakTimeHours + + private val breakTimeMinutes + get() = uiState.value.breakTimeMinutes private val repeats get() = uiState.value.repeats @@ -36,24 +38,28 @@ class AddTimerViewModel @Inject constructor( private val description get() = uiState.value.description - fun onStudyTimeHoursChange(newValue: Float) { + fun onStudyTimeHoursChange(newValue: Int) { uiState.value = uiState.value.copy(studyTimeHours = newValue) } - fun onStudyTimeMinutesChange(newValue: Float) { + fun onStudyTimeMinutesChange(newValue: Int) { uiState.value = uiState.value.copy(studyTimeMinutes = newValue) } - fun onWithBreaksChange(newValue: Boolean) { - uiState.value = uiState.value.copy(withBreaks = newValue) + fun onWithBreaksChange() { + uiState.value = uiState.value.copy(withBreaks = !uiState.value.withBreaks) } - fun onBreakTimeChange(newValue: Float) { - uiState.value = uiState.value.copy(breakTime = newValue) + fun onBreakTimeHourChange(newValue: Int) { + uiState.value = uiState.value.copy(breakTimeHours = newValue) } - fun onRepeatsChange(newValue: Float) { + fun onBreakTimeMinutesChange(newValue: Int) { + uiState.value = uiState.value.copy(breakTimeMinutes = newValue) + } + + fun onRepeatsChange(newValue: Int) { uiState.value = uiState.value.copy(repeats = newValue) } @@ -62,15 +68,15 @@ class AddTimerViewModel @Inject constructor( timerDAO.saveTimer(PomodoroTimerInfo( name = uiState.value.name, description = uiState.value.description, - studyTime = studyTimeHours.toInt() * 60 * 60 + studyTimeMinutes.toInt() * 60, - breakTime = breakTime.toInt() * 60, - repeats = repeats.toInt() + studyTime = studyTimeHours * 60 * 60 + studyTimeMinutes * 60, + breakTime = breakTimeHours * 60 * 60 + breakTimeMinutes * 60, + repeats = repeats )) } else { timerDAO.saveTimer(CustomTimerInfo( name = uiState.value.name, description = uiState.value.description, - studyTime = studyTimeHours.toInt() * 60 * 60 + studyTimeMinutes.toInt() * 60 + studyTime = studyTimeHours * 60 * 60 + studyTimeMinutes * 60 )) } } diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt index 772917d..77bdeda 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/add_timer/addTimerScreen.kt @@ -6,45 +6,54 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.Button import androidx.compose.material.Checkbox -import androidx.compose.material.Slider import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +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 be.ugent.sel.studeez.R import be.ugent.sel.studeez.common.composable.BasicButton import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate +import be.ugent.sel.studeez.common.composable.navbar.BasicTimePicker +import be.ugent.sel.studeez.navigation.StudeezDestinations import be.ugent.sel.studeez.resources import be.ugent.sel.studeez.ui.theme.StudeezTheme data class AddTimerActions( + val open: (String) -> Unit, val goBack: () -> Unit, - val onStudyTimeHoursChange: (Float) -> Unit, - val onStudyTimeMinutesChange: (Float) -> Unit, - val onBreakTimeChange: (Float) -> Unit, - val onRepeatsChange: (Float) -> Unit, - val onWithBreaksChange: (Boolean) -> Unit, + val onStudyTimeHoursChange: (Int) -> Unit, + val onStudyTimeMinutesChange: (Int) -> Unit, + val onBreakTimeHourChange: (Int) -> Unit, + val onBreakTimeMinutesChange: (Int) -> Unit, + val onRepeatsChange: (Int) -> Unit, + val onWithBreaksChange: () -> Unit, val addTimer: () -> Unit, val onNameChange: (String) -> Unit, val onDescriptionChange: (String) -> Unit, ) fun getAddTimerActions( + open: (String) -> Unit, goBack: () -> Unit, viewModel: AddTimerViewModel, ): AddTimerActions { return AddTimerActions( + open = open, goBack = goBack, onWithBreaksChange = viewModel::onWithBreaksChange, onStudyTimeHoursChange = viewModel::onStudyTimeHoursChange, onStudyTimeMinutesChange = viewModel::onStudyTimeMinutesChange, - onBreakTimeChange = viewModel::onBreakTimeChange, + onBreakTimeHourChange = viewModel::onBreakTimeHourChange, + onBreakTimeMinutesChange = viewModel::onBreakTimeMinutesChange, onRepeatsChange = viewModel::onRepeatsChange, addTimer = viewModel::addTimer, onNameChange = viewModel::onNameChange, @@ -55,7 +64,6 @@ fun getAddTimerActions( @Composable fun AddTimerRoute( open: (String) -> Unit, - openAndPopUp: (String, String) -> Unit, goBack: () -> Unit, viewModel: AddTimerViewModel, ) { @@ -63,6 +71,7 @@ fun AddTimerRoute( AddTimerScreen( addTimerActions = getAddTimerActions( + open = open, goBack = goBack, viewModel = viewModel, ), @@ -75,6 +84,20 @@ fun AddTimerScreen( addTimerActions: AddTimerActions, uiState: AddTimerUiState, ) { + val mStudyTimePicker = BasicTimePicker( + onHoursChange = addTimerActions.onStudyTimeHoursChange, + onMinutesChange = addTimerActions.onStudyTimeMinutesChange, + Hours = uiState.studyTimeHours, + Minutes = uiState.studyTimeMinutes + ) + + val mBreakTimePicker = BasicTimePicker( + onHoursChange = addTimerActions.onBreakTimeHourChange, + onMinutesChange = addTimerActions.onBreakTimeMinutesChange, + Hours = uiState.breakTimeHours, + Minutes = uiState.breakTimeMinutes + ) + SecondaryScreenTemplate( title = resources().getString(R.string.add_timer), popUp = addTimerActions.goBack @@ -82,52 +105,40 @@ fun AddTimerScreen( LazyColumn( modifier = Modifier .fillMaxWidth() - .padding(16.dp) + .padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally ) { item { Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center + modifier = Modifier + .padding(16.dp) ) { Text( - text = "How long do you want to study?", + text = stringResource(R.string.addTimer_question), textAlign = TextAlign.Center ) } } + item { Text( - text = "${uiState.studyTimeHours.toInt()} hour${ if (uiState.studyTimeHours == 1f) "" else "s"}" + text = uiState.studyTimeHours.toString() + stringResource(R.string.addTimer_studytime_1) + uiState.studyTimeMinutes + stringResource( + R.string.addTimer_studytime_2) ) } + item { - Slider( - value = uiState.studyTimeHours, - onValueChange = { - addTimerActions.onStudyTimeHoursChange(it) + Button( + onClick = { + mStudyTimePicker.show() }, - steps = 8, - valueRange = 1f..10f, - enabled = true - ) - } - item { - Text( - text = "${uiState.studyTimeMinutes.toInt()} minutes" - ) - } - item { - Slider( - value = uiState.studyTimeMinutes, - onValueChange = { - addTimerActions.onStudyTimeMinutesChange(it) - }, - steps = 11, - valueRange = 0f..60f, - enabled = true - ) + ) { + Text( + text = stringResource(R.string.addTimer_timepicker), + ) + } } + item { Row( modifier = Modifier.fillMaxWidth(), @@ -135,68 +146,99 @@ fun AddTimerScreen( horizontalArrangement = Arrangement.Center ) { Text( - text = "With breaks?", + text = stringResource(R.string.addTimer_break_question), ) Checkbox( checked = uiState.withBreaks, - onCheckedChange = { addTimerActions.onWithBreaksChange(it) } + onCheckedChange = { addTimerActions.onWithBreaksChange() } ) } } + + if (uiState.withBreaks) { + item { + Text( + text = if (uiState.repeats == 1) uiState.repeats.toString() + stringResource( + R.string.addTimer_break_1) + else uiState.repeats.toString() + stringResource( + R.string.addTimer_break_s) + ) + TextField( + value = uiState.repeats.toString(), + onValueChange = { it: String -> + it.toIntOrNull()?.let { it1 -> + addTimerActions.onRepeatsChange( + kotlin.math.abs(it1) + ) + } + } + ) + } + + item { + Text( + text = uiState.breakTimeHours.toString() + stringResource(R.string.breakTime_1) + uiState.breakTimeMinutes + stringResource( + R.string.breakTime_2) + ) + } + + item { + Button( + onClick = { + mBreakTimePicker.show() + }, + ) { + Text( + text = stringResource(R.string.addTimer_timepicker), + ) + } + } + } + item { Text( - text = if (uiState.withBreaks) "breaks of ${uiState.breakTime.toInt()} minutes" else "", - ) - } - item { - Slider( - value = uiState.breakTime, - onValueChange = { - addTimerActions.onBreakTimeChange(it) - }, - steps = 11, - valueRange = 0f..60f, - enabled = uiState.withBreaks - ) - } - item { - Text( - text = if (uiState.withBreaks) "${uiState.repeats.toInt()} breaks" else "" - ) - } - item { - Slider( - value = uiState.repeats, - onValueChange = { - addTimerActions.onRepeatsChange(it) - }, - steps = 8, - valueRange = 1f..10f, - enabled = uiState.withBreaks - ) - } - item { - Text( - text = "Timer name" + text = stringResource(R.string.addTimer_name) ) } + item { TextField( value = uiState.name, onValueChange = { addTimerActions.onNameChange(it) } ) } + + item { + if (uiState.name == "") { + Text( + text = stringResource(R.string.addTimer_name_error), + color = Color.Red + ) + } + } + item { Text( - text = "Timer description" + text = stringResource(R.string.addTimer_description) ) } + item { TextField( value = uiState.description, onValueChange = { addTimerActions.onDescriptionChange(it) } ) } + + item { + if (uiState.description == "") { + Text( + text = stringResource(R.string.addTimer_description_error), + color = Color.Red + ) + } + } + item { Row( modifier = Modifier @@ -208,7 +250,12 @@ fun AddTimerScreen( BasicButton( text = R.string.add_timer, modifier = Modifier, - onClick = addTimerActions.addTimer + onClick = { + if (uiState.description != "" && uiState.name != "") { + addTimerActions.addTimer() + addTimerActions.open(StudeezDestinations.TIMER_OVERVIEW_SCREEN) + } + } ) } } @@ -220,8 +267,8 @@ fun AddTimerScreen( @Composable fun AddTimerScreenPreview() { StudeezTheme { AddTimerScreen( - addTimerActions = AddTimerActions({}, {}, {}, {}, {}, {}, {}, {}, {}), + addTimerActions = AddTimerActions({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}), uiState = AddTimerUiState() ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt index 47e7f91..a3318bc 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_selection/TimerSelectionScreen.kt @@ -64,7 +64,9 @@ fun TimerSelectionScreen( drawerActions = drawerActions, navigationBarActions = navigationBarActions, ) { - LazyColumn(verticalArrangement = Arrangement.spacedBy(7.dp)) { + LazyColumn( + verticalArrangement = Arrangement.spacedBy(7.dp), + ) { // All timers items(timers.value) { timerInfo -> TimerEntry( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 39abda6..50df45b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -79,4 +79,19 @@ About Studeez + + Timer description cannot be empty! + Timer description + Timer name cannot be empty! + Timer name + Open Time Picker + " hours and " + " minutes of breaktime" + " break" + " breaks" + With breaks? + " hours and " + " minutes of studytime" + How long do you want to study? + From 1bf96c2200932f72b2492e16b9e04aefb9ee58b7 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Tue, 2 May 2023 22:22:23 +0200 Subject: [PATCH 21/23] Add missing resources #94 --- app/src/main/res/values/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2608612..935dc7d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,10 +31,12 @@ Tasks + Task Looks like you found the sessions screen! In here, your upcoming studying sessions with friends will be listed. You can accept invites or edit your own. Sessions + Session End session Upcoming sessions @@ -92,6 +94,7 @@ Friends + Friend Adding friends still needs to be implemented. Hang on tight! From aea49295a0bb54cbfc7c6b31014d8c51f68603a4 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Tue, 2 May 2023 22:41:04 +0200 Subject: [PATCH 22/23] Exit profile edit screen on save #94 --- .../ugent/sel/studeez/screens/profile/ProfileEditScreen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileEditScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileEditScreen.kt index 3dbe270..c6fcbaf 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileEditScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/profile/ProfileEditScreen.kt @@ -63,7 +63,10 @@ fun EditProfileScreen( BasicTextButton( text = R.string.save, Modifier.textButton(), - action = editProfileActions.onSaveClick + action = { + editProfileActions.onSaveClick() + goBack() + } ) BasicTextButton( text = R.string.delete_profile, From 3ff2ed225ba83d80a17b87a440707ba8535fde4f Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Tue, 2 May 2023 22:44:53 +0200 Subject: [PATCH 23/23] Codestyle #94 --- .../FloatingActionButtonComposable.kt | 26 +++++-------------- .../composable/drawer/DrawerComposable.kt | 4 +-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt index e62165f..bc40ead 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/FloatingActionButtonComposable.kt @@ -26,10 +26,6 @@ import be.ugent.sel.studeez.R.string as AppText const val TRANSITION = "transition" val HEIGHT_DIFFERENCE = 30.dp -enum class MultiFloatingState { - Expanded, - Collapsed -} data class AddButtonActions( val onTaskClick: () -> Unit, @@ -41,18 +37,11 @@ data class AddButtonActions( fun AddButton( addButtonActions: AddButtonActions ) { - var multiFloatingState by remember { - mutableStateOf(MultiFloatingState.Collapsed) - } + var isExpanded by remember { mutableStateOf(false) } // Rotate the button when expanded, normal when collapsed. - val transition = updateTransition(targetState = multiFloatingState, label = TRANSITION) - val rotate by transition.animateFloat(label = TRANSITION) { - when (it) { - MultiFloatingState.Expanded -> 315f - MultiFloatingState.Collapsed -> 0f - } - } + val transition = updateTransition(targetState = isExpanded, label = TRANSITION) + val rotate by transition.animateFloat(label = TRANSITION) { expanded -> if (expanded) 315f else 0f } Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -60,7 +49,7 @@ fun AddButton( ) { Box { // Show minis when expanded. - if (multiFloatingState == MultiFloatingState.Expanded) { + if (isExpanded) { ExpandedAddButton( addButtonActions = addButtonActions ) @@ -71,12 +60,9 @@ fun AddButton( FloatingActionButton( onClick = { // Toggle expanded/collapsed. - multiFloatingState = when (transition.currentState) { - MultiFloatingState.Collapsed -> MultiFloatingState.Expanded - MultiFloatingState.Expanded -> MultiFloatingState.Collapsed - } + isExpanded = !isExpanded }, - modifier = Modifier.padding(bottom = if (multiFloatingState == MultiFloatingState.Expanded) 78.dp else 0.dp) + modifier = Modifier.padding(bottom = if (isExpanded) 78.dp else 0.dp) ) { Icon( imageVector = Icons.Default.Add, diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt index 7b2d3f8..2d4eab3 100644 --- a/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/drawer/DrawerComposable.kt @@ -43,9 +43,7 @@ fun getDrawerActions( onTimersClick = { drawerViewModel.onTimersClick(open) }, onSettingsClick = { drawerViewModel.onSettingsClick(open) }, onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) }, - onAboutClick = { context -> - drawerViewModel.onAboutClick(open, context = context) - }, + onAboutClick = { context -> drawerViewModel.onAboutClick(open, context = context) }, ) }