mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge pull request #7103 from vector-im/bugfix/eric/landscape-bottom-sheet-peek
[New Layout] Adds peek height (min height) to new layout bottom sheets
This commit is contained in:
commit
01e1d74c72
4 changed files with 39 additions and 15 deletions
1
changelog.d/7103.bugfix
Normal file
1
changelog.d/7103.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixes space list and new chat bottom sheets showing too small in New App Layout (especially evident in landscape)
|
|
@ -25,6 +25,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.annotation.FloatRange
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewbinding.ViewBinding
|
||||
|
@ -39,6 +40,7 @@ import im.vector.app.core.extensions.toMvRxBundle
|
|||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import io.github.hyuwah.draggableviewlib.Utils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import reactivecircus.flowbinding.android.view.clicks
|
||||
|
@ -165,6 +167,13 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe
|
|||
forceExpandState()
|
||||
}
|
||||
|
||||
protected fun setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) {
|
||||
context?.let {
|
||||
val screenHeight = Utils.getScreenHeight(it)
|
||||
bottomSheetBehavior?.setPeekHeight((screenHeight * percentage).toInt(), true)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun forceExpandState() {
|
||||
if (showExpanded) {
|
||||
// Force the bottom sheet to be expanded
|
||||
|
|
|
@ -16,43 +16,50 @@
|
|||
|
||||
package im.vector.app.features.home.room.list.home
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.databinding.FragmentNewChatBottomSheetBinding
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class NewChatBottomSheet : BottomSheetDialogFragment() {
|
||||
class NewChatBottomSheet : VectorBaseBottomSheetDialogFragment<FragmentNewChatBottomSheetBinding>() {
|
||||
|
||||
@Inject lateinit var navigator: Navigator
|
||||
|
||||
private lateinit var binding: FragmentNewChatBottomSheetBinding
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentNewChatBottomSheetBinding {
|
||||
return FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
initFABs()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initFABs() {
|
||||
binding.startChat.setOnClickListener {
|
||||
views.startChat.debouncedClicks {
|
||||
navigator.openCreateDirectRoom(requireActivity())
|
||||
}
|
||||
|
||||
binding.createRoom.setOnClickListener {
|
||||
views.createRoom.debouncedClicks {
|
||||
navigator.openCreateRoom(requireActivity())
|
||||
}
|
||||
|
||||
binding.exploreRooms.setOnClickListener {
|
||||
views.exploreRooms.debouncedClicks {
|
||||
navigator.openRoomDirectory(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
setPeekHeightAsScreenPercentage(0.5f)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "NewChatBottomSheet"
|
||||
}
|
||||
|
|
|
@ -16,25 +16,32 @@
|
|||
|
||||
package im.vector.app.features.spaces
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.replaceChildFragment
|
||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.databinding.FragmentSpacesBottomSheetBinding
|
||||
|
||||
class SpaceListBottomSheet : BottomSheetDialogFragment() {
|
||||
class SpaceListBottomSheet : VectorBaseBottomSheetDialogFragment<FragmentSpacesBottomSheetBinding>() {
|
||||
|
||||
private lateinit var binding: FragmentSpacesBottomSheetBinding
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSpacesBottomSheetBinding {
|
||||
return FragmentSpacesBottomSheetBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = FragmentSpacesBottomSheetBinding.inflate(inflater, container, false)
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
if (savedInstanceState == null) {
|
||||
replaceChildFragment(R.id.space_list, SpaceListFragment::class.java)
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
setPeekHeightAsScreenPercentage(0.75f)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in a new issue