#30 added textfieldStates to editScreen
This commit is contained in:
		
							parent
							
								
									bfde19caaf
								
							
						
					
					
						commit
						48a1a50a5f
					
				
					 1 changed files with 29 additions and 21 deletions
				
			
		|  | @ -1,49 +1,57 @@ | ||||||
| package be.ugent.sel.studeez.screens.timer_edit.editScreens | package be.ugent.sel.studeez.screens.timer_edit.editScreens | ||||||
| 
 | 
 | ||||||
|  | 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.foundation.layout.fillMaxHeight | ||||||
| import androidx.compose.foundation.layout.fillMaxWidth | import androidx.compose.foundation.layout.fillMaxWidth | ||||||
| import androidx.compose.foundation.rememberScrollState | import androidx.compose.foundation.rememberScrollState | ||||||
| import androidx.compose.foundation.verticalScroll | import androidx.compose.foundation.verticalScroll | ||||||
| import androidx.compose.material.OutlinedTextField | import androidx.compose.runtime.* | ||||||
| import androidx.compose.material.Text |  | ||||||
| import androidx.compose.runtime.Composable |  | ||||||
| import androidx.compose.ui.Alignment | 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 | ||||||
| import be.ugent.sel.studeez.common.composable.LabelledInputField | import be.ugent.sel.studeez.common.composable.LabelledInputField | ||||||
| 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.data.local.models.timer_info.TimerInfo | import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo | ||||||
| 
 | 
 | ||||||
| abstract class AbstractTimerEditScreen(private val timerInfo: TimerInfo) { | abstract class AbstractTimerEditScreen(private val timerInfo: TimerInfo) { | ||||||
| 
 | 
 | ||||||
|     @Composable |     @Composable | ||||||
|     operator fun invoke(onSaveClick: (TimerInfo) -> Unit) { |     operator fun invoke(onSaveClick: (TimerInfo) -> Unit) { | ||||||
|         // TODO klassen hierarchie voor uistate | 
 | ||||||
|         // TODO klassen extras implementeren |         var name by remember { mutableStateOf(timerInfo.name) } | ||||||
|  |         var description by remember { mutableStateOf(timerInfo.description) } | ||||||
|  | 
 | ||||||
|  |         // This shall rerun whenever name and description change | ||||||
|  |         timerInfo.name = name | ||||||
|  |         timerInfo.description = description | ||||||
| 
 | 
 | ||||||
|         Column( |         Column( | ||||||
|             modifier = Modifier.fillMaxWidth().fillMaxHeight(), |             verticalArrangement = Arrangement.SpaceBetween, | ||||||
|  |             modifier = Modifier.fillMaxHeight().verticalScroll(rememberScrollState()), | ||||||
|  |         ) { | ||||||
|  |             Column( | ||||||
|  |                 modifier = Modifier.fillMaxWidth(), | ||||||
|                 horizontalAlignment = Alignment.CenterHorizontally |                 horizontalAlignment = Alignment.CenterHorizontally | ||||||
|             ) { |             ) { | ||||||
| 
 | 
 | ||||||
|                 // Fields that every timer shares (ommited id) |                 // Fields that every timer shares (ommited id) | ||||||
|                 LabelledInputField( |                 LabelledInputField( | ||||||
|                 value = timerInfo.name, |                     value = name, | ||||||
|                 onNewValue = {}, |                     onNewValue = { name = it }, | ||||||
|                     label = R.string.name |                     label = R.string.name | ||||||
|                 ) |                 ) | ||||||
|                 LabelledInputField( |                 LabelledInputField( | ||||||
|                 value = timerInfo.description, |                     value = description, | ||||||
|                 onNewValue = {}, |                     onNewValue = { description = it }, | ||||||
|                     label = R.string.description, |                     label = R.string.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
	
	 lbarraga
						lbarraga