Merge branch 'development' into addTimer
This commit is contained in:
		
						commit
						3e721be32c
					
				
					 37 changed files with 694 additions and 193 deletions
				
			
		| 
						 | 
				
			
			@ -33,13 +33,13 @@ fun HomeRoute(
 | 
			
		|||
fun HomeScreen(
 | 
			
		||||
    onStartSessionClick: () -> Unit,
 | 
			
		||||
    drawerActions: DrawerActions,
 | 
			
		||||
    navigationBarActions: NavigationBarActions,
 | 
			
		||||
    navigationBarActions: NavigationBarActions
 | 
			
		||||
) {
 | 
			
		||||
    PrimaryScreenTemplate(
 | 
			
		||||
        title = resources().getString(R.string.home),
 | 
			
		||||
        drawerActions = drawerActions,
 | 
			
		||||
        navigationBarActions = navigationBarActions,
 | 
			
		||||
        barAction = { FriendsAction() }
 | 
			
		||||
        // TODO barAction = { FriendsAction() }
 | 
			
		||||
    ) {
 | 
			
		||||
        BasicButton(R.string.start_session, Modifier.basicButton()) {
 | 
			
		||||
            onStartSessionClick()
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +63,6 @@ fun HomeScreenPreview() {
 | 
			
		|||
    HomeScreen(
 | 
			
		||||
        onStartSessionClick = {},
 | 
			
		||||
        drawerActions = DrawerActions({}, {}, {}, {}, {}),
 | 
			
		||||
        navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {})
 | 
			
		||||
        navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {})
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,6 +88,6 @@ fun ProfileScreenPreview() {
 | 
			
		|||
    ProfileScreen(
 | 
			
		||||
        profileActions = ProfileActions({ null }, {}),
 | 
			
		||||
        drawerActions = DrawerActions({}, {}, {}, {}, {}),
 | 
			
		||||
        navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {})
 | 
			
		||||
        navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}, {}, {}, {})
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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<Unit> {
 | 
			
		||||
 | 
			
		||||
    @SuppressLint("ComposableNaming")
 | 
			
		||||
    override fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressLint("ComposableNaming")
 | 
			
		||||
    override fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressLint("ComposableNaming")
 | 
			
		||||
    override fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit
 | 
			
		||||
 | 
			
		||||
class TimerEditViewModel {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit
 | 
			
		||||
 | 
			
		||||
abstract class AbstractTimerEditScreen {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit.editScreens
 | 
			
		||||
 | 
			
		||||
class BreakTimerEditScreen {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit
 | 
			
		||||
 | 
			
		||||
class CustomTimerEditScreen {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_edit.editScreens
 | 
			
		||||
 | 
			
		||||
class EndlessTimerEditScreen {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -64,6 +64,14 @@ fun TimerOverviewScreen(
 | 
			
		|||
        drawerActions = drawerActions
 | 
			
		||||
    ) {
 | 
			
		||||
        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) {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,20 @@
 | 
			
		|||
package be.ugent.sel.studeez.screens.timer_selection
 | 
			
		||||
 | 
			
		||||
import android.widget.TimePicker
 | 
			
		||||
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.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
 | 
			
		||||
import kotlinx.coroutines.flow.Flow
 | 
			
		||||
| 
						 | 
				
			
			@ -17,6 +23,8 @@ import kotlinx.coroutines.flow.flowOf
 | 
			
		|||
data class TimerSelectionActions(
 | 
			
		||||
    val getAllTimers: () -> Flow<List<TimerInfo>>,
 | 
			
		||||
    val startSession: (TimerInfo) -> Unit,
 | 
			
		||||
    val pickDuration: (TimePicker?, Int, Int) -> Unit,
 | 
			
		||||
    val customTimeStudyTime: Int
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
fun getTimerSelectionActions(
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +34,10 @@ fun getTimerSelectionActions(
 | 
			
		|||
    return TimerSelectionActions(
 | 
			
		||||
        getAllTimers = viewModel::getAllTimers,
 | 
			
		||||
        startSession = { viewModel.startSession(open, it) },
 | 
			
		||||
        pickDuration = { _, hour: Int, minute: Int ->
 | 
			
		||||
            viewModel.customTimerStudyTime.value = hour * 60 * 60 + minute * 60
 | 
			
		||||
        },
 | 
			
		||||
        customTimeStudyTime = viewModel.customTimerStudyTime.value
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -52,6 +64,11 @@ fun TimerSelectionScreen(
 | 
			
		|||
        popUp = popUp
 | 
			
		||||
    ) {
 | 
			
		||||
        LazyColumn {
 | 
			
		||||
            // Custom timer with duration selection button
 | 
			
		||||
            item {
 | 
			
		||||
                CustomTimerEntry(timerSelectionActions)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // All timers
 | 
			
		||||
            items(timers.value) { timerInfo ->
 | 
			
		||||
                TimerEntry(
 | 
			
		||||
| 
						 | 
				
			
			@ -68,11 +85,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 hms: HoursMinutesSeconds = Time(timerInfo.studyTime).getAsHMS()
 | 
			
		||||
 | 
			
		||||
    TimerEntry(
 | 
			
		||||
        timerInfo = timerInfo,
 | 
			
		||||
        leftButton = {
 | 
			
		||||
            StealthButton(
 | 
			
		||||
                text = R.string.start,
 | 
			
		||||
                onClick = { timerSelectionActions.startSession(timerInfo) }
 | 
			
		||||
            )
 | 
			
		||||
        },
 | 
			
		||||
        rightButton = {
 | 
			
		||||
            TimePickerButton(
 | 
			
		||||
                hoursMinutesSeconds = hms,
 | 
			
		||||
                onTimeSetListener = timerSelectionActions.pickDuration
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Preview
 | 
			
		||||
@Composable
 | 
			
		||||
fun TimerSelectionPreview() {
 | 
			
		||||
    TimerSelectionScreen(
 | 
			
		||||
        timerSelectionActions = TimerSelectionActions({ flowOf() }, {}),
 | 
			
		||||
        timerSelectionActions = TimerSelectionActions({ flowOf() }, {}, { _, _, _ -> {} }, 0),
 | 
			
		||||
        popUp = {}
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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<Int> = mutableStateOf(0)
 | 
			
		||||
 | 
			
		||||
    fun getAllTimers() : Flow<List<TimerInfo>> {
 | 
			
		||||
        return timerDAO.getAllTimers()
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue