Added numpad floating action button

This commit is contained in:
Sylvain Berfini 2025-01-10 11:00:28 +01:00
parent eac72a0e42
commit 099350244a
2 changed files with 32 additions and 3 deletions

View file

@ -58,6 +58,16 @@ class StartCallFragment : GenericAddressPickerFragment() {
override lateinit var viewModel: StartCallViewModel
private val bottomSheetCallback = object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
if (newState == BottomSheetBehavior.STATE_COLLAPSED || newState == BottomSheetBehavior.STATE_HIDDEN) {
viewModel.isNumpadVisible.value = false
}
}
override fun onSlide(bottomSheet: View, slideOffset: Float) { }
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -144,12 +154,15 @@ class StartCallFragment : GenericAddressPickerFragment() {
}
}
val bottomSheetBehavior = BottomSheetBehavior.from(binding.numpadLayout.root)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallback)
viewModel.isNumpadVisible.observe(viewLifecycleOwner) { visible ->
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.numpadLayout.root)
if (visible) {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
} else {
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
}

View file

@ -267,6 +267,22 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/show_numpad"
android:onClick="@{() -> viewModel.switchBetweenKeyboardAndNumpad()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="@drawable/numpad"
android:contentDescription="@string/content_description_show_numpad"
android:visibility="@{viewModel.isNumpadVisible || viewModel.multipleSelectionMode ? View.GONE : View.VISIBLE}"
app:tint="?attr/color_on_main"
app:backgroundTint="?attr/color_main1_500"
app:shapeAppearanceOverlay="@style/rounded"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include