Callback interface for the choice of the duration

This commit is contained in:
Maxime NATUREL 2022-03-30 14:53:32 +02:00
parent 4da11bbdc0
commit 5abc196536
2 changed files with 23 additions and 8 deletions

View File

@ -53,7 +53,9 @@ class LocationSharingFragment @Inject constructor(
private val avatarRenderer: AvatarRenderer,
private val matrixItemColorProvider: MatrixItemColorProvider,
private val vectorFeatures: VectorFeatures,
) : VectorBaseFragment<FragmentLocationSharingBinding>(), LocationTargetChangeListener {
) : VectorBaseFragment<FragmentLocationSharingBinding>(),
LocationTargetChangeListener,
ChooseLiveDurationBottomSheet.DurationChoiceListener {
private val viewModel: LocationSharingViewModel by fragmentViewModel()
@ -236,11 +238,12 @@ class LocationSharingFragment @Inject constructor(
}
private fun startLiveLocationSharing() {
// TODO. Get duration from user
ChooseLiveDurationBottomSheet.newInstance()
ChooseLiveDurationBottomSheet.newInstance(this)
.show(requireActivity().supportFragmentManager, "DISPLAY_CHOOSE_DURATION_OPTIONS")
//val duration = 30 * 1000L
//viewModel.handle(LocationSharingAction.StartLiveLocationSharing(duration))
}
override fun onDurationChoice(durationMillis: Long) {
viewModel.handle(LocationSharingAction.StartLiveLocationSharing(durationMillis))
}
private fun updateMap(state: LocationSharingViewState) {

View File

@ -30,19 +30,31 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActi
class ChooseLiveDurationBottomSheet :
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
// TODO create interface callback to set the chosen duration
// TODO show same UI as in Figma
// TODO handle choice of user
var durationChoiceListener: DurationChoiceListener? = null
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetChooseLiveLocationShareDurationBinding {
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false)
}
override fun onDestroyView() {
durationChoiceListener = null
super.onDestroyView()
}
// we are not using state for this one as it's static, so no need to override invalidate()
companion object {
fun newInstance(): ChooseLiveDurationBottomSheet {
return ChooseLiveDurationBottomSheet()
fun newInstance(durationChoiceListener: DurationChoiceListener): ChooseLiveDurationBottomSheet {
val bottomSheet = ChooseLiveDurationBottomSheet()
bottomSheet.durationChoiceListener = durationChoiceListener
return bottomSheet
}
}
interface DurationChoiceListener {
fun onDurationChoice(durationMillis: Long)
}
}