UI to select the duration
This commit is contained in:
parent
5abc196536
commit
c18a9230e5
@ -16,12 +16,29 @@
|
||||
|
||||
package im.vector.app.features.location.live.duration
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.databinding.BottomSheetChooseLiveLocationShareDurationBinding
|
||||
import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActionViewModel
|
||||
|
||||
/**
|
||||
* 15 minutes.
|
||||
*/
|
||||
private const val DURATION_IN_MS_OPTION_1 = 15 * 60_000L
|
||||
|
||||
/**
|
||||
* 1 hour.
|
||||
*/
|
||||
private const val DURATION_IN_MS_OPTION_2 = 60 * 60_000L
|
||||
|
||||
/**
|
||||
* 8 hours.
|
||||
*/
|
||||
private const val DURATION_IN_MS_OPTION_3 = 8 * 60 * 60_000L
|
||||
|
||||
/**
|
||||
* Bottom sheet displaying list of options to choose the duration of the live sharing.
|
||||
@ -30,8 +47,7 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActi
|
||||
class ChooseLiveDurationBottomSheet :
|
||||
VectorBaseBottomSheetDialogFragment<BottomSheetChooseLiveLocationShareDurationBinding>() {
|
||||
|
||||
// TODO show same UI as in Figma
|
||||
// TODO handle choice of user
|
||||
// TODO fix text color problem of button in dqrk mode
|
||||
|
||||
var durationChoiceListener: DurationChoiceListener? = null
|
||||
|
||||
@ -39,6 +55,11 @@ class ChooseLiveDurationBottomSheet :
|
||||
return BottomSheetChooseLiveLocationShareDurationBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initConfirmButton()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
durationChoiceListener = null
|
||||
super.onDestroyView()
|
||||
@ -46,6 +67,23 @@ class ChooseLiveDurationBottomSheet :
|
||||
|
||||
// we are not using state for this one as it's static, so no need to override invalidate()
|
||||
|
||||
private fun initConfirmButton() {
|
||||
views.liveLocShareChooseDurationConfirm.setOnClickListener {
|
||||
val currentChoice = getCurrentChoice()
|
||||
durationChoiceListener?.onDurationChoice(currentChoice)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentChoice(): Long {
|
||||
return when (views.liveLocShareChooseDurationOptions.checkedRadioButtonId) {
|
||||
R.id.liveLocShareChooseDurationOption1 -> DURATION_IN_MS_OPTION_1
|
||||
R.id.liveLocShareChooseDurationOption2 -> DURATION_IN_MS_OPTION_2
|
||||
R.id.liveLocShareChooseDurationOption3 -> DURATION_IN_MS_OPTION_3
|
||||
else -> DURATION_IN_MS_OPTION_1
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(durationChoiceListener: DurationChoiceListener): ChooseLiveDurationBottomSheet {
|
||||
val bottomSheet = ChooseLiveDurationBottomSheet()
|
||||
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<size android:height="1dp" />
|
||||
<solid android:color="?vctr_list_separator_system" />
|
||||
</shape>
|
@ -2,17 +2,61 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottomSheetLiveLocShareChooseDurationTitle"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:id="@+id/liveLocShareChooseDurationTitle"
|
||||
style="@style/Widget.Vector.TextView.Subtitle.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="8dp"
|
||||
android:textColor="?vctr_content_primary"
|
||||
android:text="@string/location_share_live_select_duration_title" />
|
||||
android:paddingHorizontal="15dp"
|
||||
android:paddingVertical="24dp"
|
||||
android:text="@string/location_share_live_select_duration_title"
|
||||
android:textColor="?vctr_content_primary" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/liveLocShareChooseDurationOptions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="@drawable/divider_horizontal_system"
|
||||
android:showDividers="beginning|middle|end">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/liveLocShareChooseDurationOption1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="22dp"
|
||||
android:checked="true"
|
||||
android:text="@string/location_share_live_select_duration_option_1" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/liveLocShareChooseDurationOption2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="22dp"
|
||||
android:text="@string/location_share_live_select_duration_option_2" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/liveLocShareChooseDurationOption3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="22dp"
|
||||
android:text="@string/location_share_live_select_duration_option_3" />
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/liveLocShareChooseDurationConfirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="12dp"
|
||||
android:text="@string/action_share" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user