Callback interface for the choice of the duration
This commit is contained in:
parent
4da11bbdc0
commit
5abc196536
|
@ -53,7 +53,9 @@ class LocationSharingFragment @Inject constructor(
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
private val matrixItemColorProvider: MatrixItemColorProvider,
|
private val matrixItemColorProvider: MatrixItemColorProvider,
|
||||||
private val vectorFeatures: VectorFeatures,
|
private val vectorFeatures: VectorFeatures,
|
||||||
) : VectorBaseFragment<FragmentLocationSharingBinding>(), LocationTargetChangeListener {
|
) : VectorBaseFragment<FragmentLocationSharingBinding>(),
|
||||||
|
LocationTargetChangeListener,
|
||||||
|
ChooseLiveDurationBottomSheet.DurationChoiceListener {
|
||||||
|
|
||||||
private val viewModel: LocationSharingViewModel by fragmentViewModel()
|
private val viewModel: LocationSharingViewModel by fragmentViewModel()
|
||||||
|
|
||||||
|
@ -236,11 +238,12 @@ class LocationSharingFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startLiveLocationSharing() {
|
private fun startLiveLocationSharing() {
|
||||||
// TODO. Get duration from user
|
ChooseLiveDurationBottomSheet.newInstance(this)
|
||||||
ChooseLiveDurationBottomSheet.newInstance()
|
|
||||||
.show(requireActivity().supportFragmentManager, "DISPLAY_CHOOSE_DURATION_OPTIONS")
|
.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) {
|
private fun updateMap(state: LocationSharingViewState) {
|
||||||
|
|
|
@ -30,19 +30,31 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActi
|
||||||
class ChooseLiveDurationBottomSheet :
|
class ChooseLiveDurationBottomSheet :
|
||||||
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
|
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
|
||||||
|
|
||||||
// TODO create interface callback to set the chosen duration
|
|
||||||
// TODO show same UI as in Figma
|
// TODO show same UI as in Figma
|
||||||
// TODO handle choice of user
|
// TODO handle choice of user
|
||||||
|
|
||||||
|
var durationChoiceListener: DurationChoiceListener? = null
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetChooseLiveLocationShareDurationBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetChooseLiveLocationShareDurationBinding {
|
||||||
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false)
|
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()
|
// we are not using state for this one as it's static, so no need to override invalidate()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(): ChooseLiveDurationBottomSheet {
|
fun newInstance(durationChoiceListener: DurationChoiceListener): ChooseLiveDurationBottomSheet {
|
||||||
return ChooseLiveDurationBottomSheet()
|
val bottomSheet = ChooseLiveDurationBottomSheet()
|
||||||
|
bottomSheet.durationChoiceListener = durationChoiceListener
|
||||||
|
return bottomSheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DurationChoiceListener {
|
||||||
|
fun onDurationChoice(durationMillis: Long)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue