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 { |     override fun hasEnded(): Boolean { | ||||||
|  |         return view == StudyState.DONE | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     override fun hasCurrentCountdownEnded(): Boolean { | ||||||
|         return time.time == 0 |         return time.time == 0 | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | @ -6,6 +6,10 @@ class FunctionalEndlessTimer() : FunctionalTimer(0) { | ||||||
|         return false |         return false | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     override fun hasCurrentCountdownEnded(): Boolean { | ||||||
|  |         return false | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     override fun tick() { |     override fun tick() { | ||||||
|         time.plusOne() |         time.plusOne() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -31,4 +31,8 @@ class FunctionalPomodoroTimer( | ||||||
|     override fun hasEnded(): Boolean { |     override fun hasEnded(): Boolean { | ||||||
|         return breaksRemaining == 0 && time.time == 0 |         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 |     abstract fun hasEnded(): Boolean | ||||||
| 
 | 
 | ||||||
|     fun hasCurrentCountdownEnded(): Boolean { |     abstract fun hasCurrentCountdownEnded(): Boolean | ||||||
|         return time.getTime() == 0 |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     enum class StudyState { |     enum class StudyState { | ||||||
|         FOCUS, DONE, BREAK, FOCUS_REMAINING |         FOCUS, DONE, BREAK, FOCUS_REMAINING | ||||||
|  |  | ||||||
|  | @ -12,7 +12,6 @@ import androidx.compose.foundation.layout.padding | ||||||
| import androidx.compose.foundation.shape.RoundedCornerShape | import androidx.compose.foundation.shape.RoundedCornerShape | ||||||
| import androidx.compose.material.Text | import androidx.compose.material.Text | ||||||
| import androidx.compose.material.TextButton | import androidx.compose.material.TextButton | ||||||
| import androidx.compose.runtime.* |  | ||||||
| import androidx.compose.ui.Alignment | import androidx.compose.ui.Alignment | ||||||
| import androidx.compose.runtime.Composable | import androidx.compose.runtime.Composable | ||||||
| import androidx.compose.runtime.LaunchedEffect | import androidx.compose.runtime.LaunchedEffect | ||||||
|  | @ -31,7 +30,6 @@ import androidx.compose.ui.unit.sp | ||||||
| import androidx.hilt.navigation.compose.hiltViewModel | import androidx.hilt.navigation.compose.hiltViewModel | ||||||
| import be.ugent.sel.studeez.R | 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.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.data.local.models.timer_functional.FunctionalTimer.StudyState | ||||||
| import be.ugent.sel.studeez.resources | import be.ugent.sel.studeez.resources | ||||||
| import kotlinx.coroutines.delay | import kotlinx.coroutines.delay | ||||||
|  | @ -43,6 +41,7 @@ var timerEnd = false | ||||||
| fun SessionScreen( | fun SessionScreen( | ||||||
|     open: (String) -> Unit, |     open: (String) -> Unit, | ||||||
|     openAndPopUp: (String, String) -> Unit, |     openAndPopUp: (String, String) -> Unit, | ||||||
|  |     viewModel: SessionViewModel = hiltViewModel() | ||||||
| ) { | ) { | ||||||
|     val context = LocalContext.current |     val context = LocalContext.current | ||||||
|     val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) |     val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) | ||||||
|  | @ -99,7 +98,7 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel(), mediaplayer: Me | ||||||
|     LaunchedEffect(tikker) { |     LaunchedEffect(tikker) { | ||||||
|         delay(1.seconds) |         delay(1.seconds) | ||||||
|         viewModel.getTimer().tick() |         viewModel.getTimer().tick() | ||||||
|         ticker = !ticker |         tikker = !tikker | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (viewModel.getTimer().hasCurrentCountdownEnded() && !viewModel.getTimer().hasEnded()) { |     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.domain.LogService | ||||||
| import be.ugent.sel.studeez.screens.StudeezViewModel | import be.ugent.sel.studeez.screens.StudeezViewModel | ||||||
| import be.ugent.sel.studeez.data.SelectedTimerState | 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 dagger.hilt.android.lifecycle.HiltViewModel | ||||||
| import javax.inject.Inject | import javax.inject.Inject | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Rune Dyselinck
						Rune Dyselinck