timepicker button met popup-klok functionaliteit
This commit is contained in:
		
							parent
							
								
									6b7ec41f32
								
							
						
					
					
						commit
						5b0cff2376
					
				
					 10 changed files with 112 additions and 0 deletions
				
			
		|  | @ -0,0 +1,47 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import android.app.TimePickerDialog | ||||
| import android.app.TimePickerDialog.OnTimeSetListener | ||||
| import android.content.Context | ||||
| import androidx.compose.foundation.BorderStroke | ||||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||
| import androidx.compose.material.Button | ||||
| import androidx.compose.material.ButtonColors | ||||
| import androidx.compose.material.ButtonDefaults | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.platform.LocalContext | ||||
| import androidx.compose.ui.unit.dp | ||||
| import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds | ||||
| import java.util.* | ||||
| 
 | ||||
| // TODO codeduplicatie met Tibo, later wegdoen | ||||
| @Composable | ||||
| fun TimePickerButton( | ||||
|     hoursMinutesSeconds: HoursMinutesSeconds, | ||||
|     modifier: Modifier = Modifier, | ||||
|     colors: ButtonColors = ButtonDefaults.buttonColors(), | ||||
|     border: BorderStroke? = null, | ||||
|     onTimeSetListener: OnTimeSetListener | ||||
| ) { | ||||
|     val context = LocalContext.current | ||||
|     Button( | ||||
|         onClick = { pickDuration(context, onTimeSetListener) }, | ||||
|         modifier = modifier, | ||||
|         shape = RoundedCornerShape(20.dp), | ||||
|         colors = colors, | ||||
|         border = border | ||||
|     ) { | ||||
|         Text(text = hoursMinutesSeconds.toString()) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // TODO idem codedup Tibo | ||||
| private fun pickDuration(context: Context, listener: OnTimeSetListener) { | ||||
|     val mCalendar = Calendar.getInstance() | ||||
|     val mHour = mCalendar[Calendar.HOUR] | ||||
|     val mMinute = mCalendar[Calendar.MINUTE] | ||||
|     val mTimePickerDialog = TimePickerDialog(context, listener, mHour, mMinute, true) | ||||
|     mTimePickerDialog.show() | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.data | ||||
| 
 | ||||
| class EditTimerState { | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.data.local.models.timer_info | ||||
| 
 | ||||
| interface TimerInfoVisitor { | ||||
| } | ||||
|  | @ -0,0 +1,35 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit | ||||
| 
 | ||||
| import android.annotation.SuppressLint | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.Modifier | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.common.composable.BasicButton | ||||
| import be.ugent.sel.studeez.common.ext.basicButton | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.EndlessTimerInfo | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.PomodoroTimerInfo | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfoVisitor | ||||
| 
 | ||||
| class GetTimerEditView: TimerInfoVisitor<Unit> { | ||||
| 
 | ||||
|     @SuppressLint("ComposableNaming") | ||||
|     override fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @SuppressLint("ComposableNaming") | ||||
|     override fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @SuppressLint("ComposableNaming") | ||||
|     override fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,2 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit | ||||
| 
 | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit | ||||
| 
 | ||||
| class TimerEditViewModel { | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit | ||||
| 
 | ||||
| abstract class AbstractTimerEditScreen { | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit.editScreens | ||||
| 
 | ||||
| class BreakTimerEditScreen { | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit | ||||
| 
 | ||||
| class CustomTimerEditScreen { | ||||
| } | ||||
|  | @ -0,0 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.timer_edit.editScreens | ||||
| 
 | ||||
| class EndlessTimerEditScreen { | ||||
| } | ||||
		Reference in a new issue
	
	 lbarraga
						lbarraga