preview + visitor refactor
This commit is contained in:
		
							parent
							
								
									351547f111
								
							
						
					
					
						commit
						9a18bcc414
					
				
					 2 changed files with 22 additions and 12 deletions
				
			
		|  | @ -15,8 +15,10 @@ import androidx.compose.ui.Modifier | |||
| import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.text.font.FontWeight | ||||
| import androidx.compose.ui.text.style.TextAlign | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| import androidx.compose.ui.unit.sp | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||
| import be.ugent.sel.studeez.screens.session.SessionActions | ||||
| import kotlinx.coroutines.delay | ||||
|  | @ -66,7 +68,7 @@ abstract class AbstractSessionScreen { | |||
|     } | ||||
| 
 | ||||
|     @Composable | ||||
|     private fun Timer( | ||||
|     fun Timer( | ||||
|         sessionActions: SessionActions, | ||||
|     ) { | ||||
|         var tikker by remember { mutableStateOf(false) } | ||||
|  | @ -85,8 +87,8 @@ abstract class AbstractSessionScreen { | |||
| 
 | ||||
|         if (!timerEnd && sessionActions.getTimer().hasEnded()) { | ||||
| //        sessionActions.prepareMediaPlayer() | ||||
|             timerEnd = | ||||
|                 true // Placeholder, vanaf hier moet het report opgestart worden en de sessie afgesloten | ||||
|              timerEnd = | ||||
|                  true // Placeholder, vanaf hier moet het report opgestart worden en de sessie afgesloten | ||||
|         } | ||||
| 
 | ||||
|         val hms = sessionActions.getTimer().getHoursMinutesSeconds() | ||||
|  | @ -135,4 +137,15 @@ abstract class AbstractSessionScreen { | |||
|     @Composable | ||||
|     abstract fun motivationString(): String | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun TimerPreview() { | ||||
|     val sessionScreen = object : AbstractSessionScreen() { | ||||
|         @Composable | ||||
|         override fun motivationString(): String = "Test" | ||||
| 
 | ||||
|     } | ||||
|     sessionScreen.Timer(sessionActions = SessionActions({ FunctionalEndlessTimer() }, { "Preview" }, {}, {})) | ||||
| } | ||||
|  | @ -6,15 +6,12 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodor | |||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimerVisitor | ||||
| 
 | ||||
| class GetSessionScreen : FunctionalTimerVisitor<AbstractSessionScreen> { | ||||
|     override fun visitFunctionalCustomTimer(functionalCustomTimer: FunctionalCustomTimer): AbstractSessionScreen { | ||||
|         return CustomSessionScreen(functionalCustomTimer) | ||||
|     } | ||||
|     override fun visitFunctionalCustomTimer(functionalCustomTimer: FunctionalCustomTimer): AbstractSessionScreen = | ||||
|         CustomSessionScreen(functionalCustomTimer) | ||||
| 
 | ||||
|     override fun visitFunctionalEndlessTimer(functionalEndlessTimer: FunctionalEndlessTimer): AbstractSessionScreen { | ||||
|         return EndlessSessionScreen() | ||||
|     } | ||||
|     override fun visitFunctionalEndlessTimer(functionalEndlessTimer: FunctionalEndlessTimer): AbstractSessionScreen = | ||||
|         EndlessSessionScreen() | ||||
| 
 | ||||
|     override fun visitFunctionalBreakTimer(functionalPomodoroTimer: FunctionalPomodoroTimer): AbstractSessionScreen { | ||||
|         return BreakSessionScreen(functionalPomodoroTimer) | ||||
|     } | ||||
|     override fun visitFunctionalBreakTimer(functionalPomodoroTimer: FunctionalPomodoroTimer): AbstractSessionScreen = | ||||
|         BreakSessionScreen(functionalPomodoroTimer) | ||||
| } | ||||
		Reference in a new issue
	
	 Lukas Barragan Torres
						Lukas Barragan Torres