#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 be.ugent.sel.studeez.common.composable.BasicButton | ||||
| 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.fieldModifier | ||||
| import be.ugent.sel.studeez.resources | ||||
|  | @ -71,7 +71,7 @@ fun SubjectForm( | |||
|     onColorChange: (Color) -> Unit, | ||||
|     extraButton: @Composable () -> Unit = {}, | ||||
| ) { | ||||
|     SecondaryScreenTemplate( | ||||
|     FormComposable( | ||||
|         title = resources().getString(title), | ||||
|         popUp = goBack, | ||||
|     ) { | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ import androidx.compose.ui.res.stringResource | |||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import be.ugent.sel.studeez.common.composable.BasicButton | ||||
| 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.fieldModifier | ||||
| import be.ugent.sel.studeez.resources | ||||
|  | @ -62,7 +62,7 @@ fun TaskForm( | |||
|     onNameChange: (String) -> Unit, | ||||
|     extraButton: @Composable () -> Unit = {} | ||||
| ) { | ||||
|     SecondaryScreenTemplate( | ||||
|     FormComposable( | ||||
|         title = resources().getString(title), | ||||
|         popUp = goBack, | ||||
|     ) { | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ package be.ugent.sel.studeez.screens.timer_form | |||
| import androidx.annotation.StringRes | ||||
| import androidx.compose.runtime.Composable | ||||
| 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.R.string as AppText | ||||
| 
 | ||||
|  | @ -36,7 +36,10 @@ fun TimerFormScreen( | |||
| ) { | ||||
|     val timerFormScreen = getTimerInfo().accept(GetTimerFormScreen()) | ||||
| 
 | ||||
|     SecondaryScreenTemplate(title = stringResource(id = label), popUp = popUp) { | ||||
|     FormComposable( | ||||
|         title = stringResource(id = label), | ||||
|         popUp = popUp | ||||
|     ) { | ||||
|         timerFormScreen(onConfirmClick) | ||||
|     } | ||||
| } | ||||
|  | @ -1,17 +1,7 @@ | |||
| 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.fillMaxHeight | ||||
| 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.runtime.* | ||||
| import androidx.compose.ui.Modifier | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.common.composable.BasicButton | ||||
|  | @ -32,32 +22,24 @@ abstract class AbstractTimerFormScreen(private val timerInfo: TimerInfo) { | |||
|         timerInfo.name = name | ||||
|         timerInfo.description = description | ||||
| 
 | ||||
|         Column( | ||||
|             verticalArrangement = Arrangement.SpaceBetween, | ||||
|             modifier = Modifier.fillMaxHeight().verticalScroll(rememberScrollState()), | ||||
|         ) { | ||||
|             Column( | ||||
|                 modifier = Modifier.fillMaxWidth(), | ||||
|                 horizontalAlignment = Alignment.CenterHorizontally | ||||
|             ) { | ||||
|         Column { | ||||
| 
 | ||||
|                 // Fields that every timer shares (ommited id) | ||||
|                 LabelledInputField( | ||||
|                     value = name, | ||||
|                     onNewValue = { name = it }, | ||||
|                     label = R.string.name | ||||
|                 ) | ||||
|             // Fields that every timer shares (ommited id) | ||||
|             LabelledInputField( | ||||
|                 value = name, | ||||
|                 onNewValue = { name = it }, | ||||
|                 label = R.string.name | ||||
|             ) | ||||
| 
 | ||||
|                 LabelledInputField( | ||||
|                     value = description, | ||||
|                     onNewValue = { description = it }, | ||||
|                     label = AppText.description, | ||||
|                     singleLine = false | ||||
|                 ) | ||||
|             LabelledInputField( | ||||
|                 value = description, | ||||
|                 onNewValue = { description = it }, | ||||
|                 label = AppText.description, | ||||
|                 singleLine = false | ||||
|             ) | ||||
| 
 | ||||
|                 ExtraFields() | ||||
|             ExtraFields() | ||||
| 
 | ||||
|             } | ||||
|             BasicButton(R.string.save, Modifier.basicButton()) { | ||||
|                 onSaveClick(timerInfo) | ||||
|             } | ||||
|  |  | |||
		Reference in a new issue