From 024ce85266790605b89c91f9ed12107170a6799a Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Sat, 29 Apr 2023 17:55:20 +0200 Subject: [PATCH 01/19] #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 02/19] #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 03/19] 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 04/19] #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 05/19] 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 06/19] 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 07/19] 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 08/19] 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 09/19] 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 10/19] 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 11/19] 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 12/19] 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 13/19] 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 14/19] #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 15/19] #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 16/19] #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 1bf96c2200932f72b2492e16b9e04aefb9ee58b7 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Tue, 2 May 2023 22:22:23 +0200 Subject: [PATCH 17/19] 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 18/19] 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 19/19] 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) }, ) }