From 0a409421a85300686021b6670fcdd08aca74bc65 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 10:09:13 +0200 Subject: [PATCH 01/12] 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 02/12] #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 b2e29417958101368c289e8ea15b112e6ab0a1e9 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Mon, 1 May 2023 19:04:40 +0200 Subject: [PATCH 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] #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 08/12] #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 09/12] #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 10/12] 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 11/12] 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 12/12] 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) }, ) }