-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New Layout] Adds peek height (min height) to new layout bottom sheets #7103
Changes from 3 commits
662d77c
8fc2011
55c60c9
85f16e8
e0f327e
f4b5cfc
50b042e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixes space list and new chat bottom sheets showing too small in New App Layout (especially evident in landscape) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All those new BottomSheet should extend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to make the changes 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks! |
||
|
||
companion object { | ||
const val TAG = "NewChatBottomSheet" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WindowManager. defaultDisplay
andgetMetrics
are deprecated in 30. Could you add API 30 implementation? And also, please, use suppress on a line, where it's needed, not on whole function