#109 refactor forms to be more consistent
This commit is contained in:
parent
0341fcf137
commit
05e8951edf
5 changed files with 46 additions and 39 deletions
|
@ -0,0 +1,22 @@
|
||||||
|
package be.ugent.sel.studeez.common.composable
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun FormComposable(
|
||||||
|
title: String,
|
||||||
|
popUp: () -> Unit,
|
||||||
|
content: @Composable () -> Unit,
|
||||||
|
) {
|
||||||
|
SecondaryScreenTemplate(title = title, popUp = popUp) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier.verticalScroll(rememberScrollState()),
|
||||||
|
) {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||||
import be.ugent.sel.studeez.common.composable.DeleteButton
|
import be.ugent.sel.studeez.common.composable.DeleteButton
|
||||||
import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate
|
import be.ugent.sel.studeez.common.composable.FormComposable
|
||||||
import be.ugent.sel.studeez.common.ext.basicButton
|
import be.ugent.sel.studeez.common.ext.basicButton
|
||||||
import be.ugent.sel.studeez.common.ext.fieldModifier
|
import be.ugent.sel.studeez.common.ext.fieldModifier
|
||||||
import be.ugent.sel.studeez.resources
|
import be.ugent.sel.studeez.resources
|
||||||
|
@ -71,7 +71,7 @@ fun SubjectForm(
|
||||||
onColorChange: (Color) -> Unit,
|
onColorChange: (Color) -> Unit,
|
||||||
extraButton: @Composable () -> Unit = {},
|
extraButton: @Composable () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
SecondaryScreenTemplate(
|
FormComposable(
|
||||||
title = resources().getString(title),
|
title = resources().getString(title),
|
||||||
popUp = goBack,
|
popUp = goBack,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||||
import be.ugent.sel.studeez.common.composable.DeleteButton
|
import be.ugent.sel.studeez.common.composable.DeleteButton
|
||||||
import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate
|
import be.ugent.sel.studeez.common.composable.FormComposable
|
||||||
import be.ugent.sel.studeez.common.ext.basicButton
|
import be.ugent.sel.studeez.common.ext.basicButton
|
||||||
import be.ugent.sel.studeez.common.ext.fieldModifier
|
import be.ugent.sel.studeez.common.ext.fieldModifier
|
||||||
import be.ugent.sel.studeez.resources
|
import be.ugent.sel.studeez.resources
|
||||||
|
@ -62,7 +62,7 @@ fun TaskForm(
|
||||||
onNameChange: (String) -> Unit,
|
onNameChange: (String) -> Unit,
|
||||||
extraButton: @Composable () -> Unit = {}
|
extraButton: @Composable () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
SecondaryScreenTemplate(
|
FormComposable(
|
||||||
title = resources().getString(title),
|
title = resources().getString(title),
|
||||||
popUp = goBack,
|
popUp = goBack,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package be.ugent.sel.studeez.screens.timer_form
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate
|
import be.ugent.sel.studeez.common.composable.FormComposable
|
||||||
import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo
|
import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo
|
||||||
import be.ugent.sel.studeez.R.string as AppText
|
import be.ugent.sel.studeez.R.string as AppText
|
||||||
|
|
||||||
|
@ -36,7 +36,10 @@ fun TimerFormScreen(
|
||||||
) {
|
) {
|
||||||
val timerFormScreen = getTimerInfo().accept(GetTimerFormScreen())
|
val timerFormScreen = getTimerInfo().accept(GetTimerFormScreen())
|
||||||
|
|
||||||
SecondaryScreenTemplate(title = stringResource(id = label), popUp = popUp) {
|
FormComposable(
|
||||||
|
title = stringResource(id = label),
|
||||||
|
popUp = popUp
|
||||||
|
) {
|
||||||
timerFormScreen(onConfirmClick)
|
timerFormScreen(onConfirmClick)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,7 @@
|
||||||
package be.ugent.sel.studeez.screens.timer_form.form_screens
|
package be.ugent.sel.studeez.screens.timer_form.form_screens
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import be.ugent.sel.studeez.R
|
import be.ugent.sel.studeez.R
|
||||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||||
|
@ -32,32 +22,24 @@ abstract class AbstractTimerFormScreen(private val timerInfo: TimerInfo) {
|
||||||
timerInfo.name = name
|
timerInfo.name = name
|
||||||
timerInfo.description = description
|
timerInfo.description = description
|
||||||
|
|
||||||
Column(
|
Column {
|
||||||
verticalArrangement = Arrangement.SpaceBetween,
|
|
||||||
modifier = Modifier.fillMaxHeight().verticalScroll(rememberScrollState()),
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
|
|
||||||
// Fields that every timer shares (ommited id)
|
// Fields that every timer shares (ommited id)
|
||||||
LabelledInputField(
|
LabelledInputField(
|
||||||
value = name,
|
value = name,
|
||||||
onNewValue = { name = it },
|
onNewValue = { name = it },
|
||||||
label = R.string.name
|
label = R.string.name
|
||||||
)
|
)
|
||||||
|
|
||||||
LabelledInputField(
|
LabelledInputField(
|
||||||
value = description,
|
value = description,
|
||||||
onNewValue = { description = it },
|
onNewValue = { description = it },
|
||||||
label = AppText.description,
|
label = AppText.description,
|
||||||
singleLine = false
|
singleLine = false
|
||||||
)
|
)
|
||||||
|
|
||||||
ExtraFields()
|
ExtraFields()
|
||||||
|
|
||||||
}
|
|
||||||
BasicButton(R.string.save, Modifier.basicButton()) {
|
BasicButton(R.string.save, Modifier.basicButton()) {
|
||||||
onSaveClick(timerInfo)
|
onSaveClick(timerInfo)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue