Adds min height to new chat
This commit is contained in:
parent
662d77cb7e
commit
8fc201121d
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.core.extensions
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import androidx.annotation.FloatRange
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
|
||||
val height = displayMetrics.heightPixels
|
||||
behavior.setPeekHeight((height * percentage).toInt(), true)
|
||||
}
|
@ -16,12 +16,15 @@
|
||||
|
||||
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.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage
|
||||
import im.vector.app.databinding.FragmentNewChatBottomSheetBinding
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import javax.inject.Inject
|
||||
@ -53,6 +56,12 @@ class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
(this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.5f)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "NewChatBottomSheet"
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.replaceChildFragment
|
||||
import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage
|
||||
import im.vector.app.databinding.FragmentSpacesBottomSheetBinding
|
||||
|
||||
class SpaceListBottomSheet : BottomSheetDialogFragment() {
|
||||
@ -48,14 +49,6 @@ class SpaceListBottomSheet : BottomSheetDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
|
||||
val height = displayMetrics.heightPixels
|
||||
behavior.setPeekHeight((height * percentage).toInt(), true)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "SpacesBottomSheet"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user