nieuwe SessionScreen.kt UI werkt met studystate en alle timer types
This commit is contained in:
		
							parent
							
								
									9d2c53d4e6
								
							
						
					
					
						commit
						3a68712cd9
					
				
					 6 changed files with 17 additions and 6 deletions
				
			
		|  | @ -11,6 +11,11 @@ class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) { | |||
|     } | ||||
| 
 | ||||
|     override fun hasEnded(): Boolean { | ||||
|         return view == StudyState.DONE | ||||
|     } | ||||
| 
 | ||||
|     override fun hasCurrentCountdownEnded(): Boolean { | ||||
|         return time.time == 0 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -6,6 +6,10 @@ class FunctionalEndlessTimer() : FunctionalTimer(0) { | |||
|         return false | ||||
|     } | ||||
| 
 | ||||
|     override fun hasCurrentCountdownEnded(): Boolean { | ||||
|         return false | ||||
|     } | ||||
| 
 | ||||
|     override fun tick() { | ||||
|         time.plusOne() | ||||
|     } | ||||
|  |  | |||
|  | @ -31,4 +31,8 @@ class FunctionalPomodoroTimer( | |||
|     override fun hasEnded(): Boolean { | ||||
|         return breaksRemaining == 0 && time.time == 0 | ||||
|     } | ||||
| 
 | ||||
|     override fun hasCurrentCountdownEnded(): Boolean { | ||||
|         return time.time == 0 | ||||
|     } | ||||
| } | ||||
|  | @ -12,9 +12,7 @@ abstract class FunctionalTimer(initialValue: Int) { | |||
| 
 | ||||
|     abstract fun hasEnded(): Boolean | ||||
| 
 | ||||
|     fun hasCurrentCountdownEnded(): Boolean { | ||||
|         return time.getTime() == 0 | ||||
|     } | ||||
|     abstract fun hasCurrentCountdownEnded(): Boolean | ||||
| 
 | ||||
|     enum class StudyState { | ||||
|         FOCUS, DONE, BREAK, FOCUS_REMAINING | ||||
|  |  | |||
|  | @ -12,7 +12,6 @@ import androidx.compose.foundation.layout.padding | |||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.material.TextButton | ||||
| import androidx.compose.runtime.* | ||||
| import androidx.compose.ui.Alignment | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.LaunchedEffect | ||||
|  | @ -31,7 +30,6 @@ import androidx.compose.ui.unit.sp | |||
| import androidx.hilt.navigation.compose.hiltViewModel | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer.StudyState | ||||
| import be.ugent.sel.studeez.resources | ||||
| import kotlinx.coroutines.delay | ||||
|  | @ -43,6 +41,7 @@ var timerEnd = false | |||
| fun SessionScreen( | ||||
|     open: (String) -> Unit, | ||||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     viewModel: SessionViewModel = hiltViewModel() | ||||
| ) { | ||||
|     val context = LocalContext.current | ||||
|     val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) | ||||
|  | @ -99,7 +98,7 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel(), mediaplayer: Me | |||
|     LaunchedEffect(tikker) { | ||||
|         delay(1.seconds) | ||||
|         viewModel.getTimer().tick() | ||||
|         ticker = !ticker | ||||
|         tikker = !tikker | ||||
|     } | ||||
| 
 | ||||
|     if (viewModel.getTimer().hasCurrentCountdownEnded() && !viewModel.getTimer().hasEnded()) { | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer | |||
| import be.ugent.sel.studeez.domain.LogService | ||||
| import be.ugent.sel.studeez.screens.StudeezViewModel | ||||
| import be.ugent.sel.studeez.data.SelectedTimerState | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer | ||||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||||
| import javax.inject.Inject | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Rune Dyselinck
						Rune Dyselinck