Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import one.mixin.android.extension.alertDialogBuilder
import one.mixin.android.extension.dayTime
import one.mixin.android.extension.dp
import one.mixin.android.extension.getClipboardManager
import one.mixin.android.extension.getSafeAreaInsetsBottom
import one.mixin.android.extension.localTime
import one.mixin.android.extension.navigationBarHeight
import one.mixin.android.extension.notNullWithElse
Expand Down Expand Up @@ -111,6 +110,32 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment(
FragmentGroupBottomSheetBinding.bind(contentView)
}

override fun getPeekHeight(
contentView: View,
behavior: BottomSheetBehavior<*>,
): Int {
val titleView = contentView.findViewById<View>(R.id.title) ?: return 0
val scrollContent = contentView.findViewById<View>(R.id.scroll_content) ?: return 0

val width = contentView.measuredWidth.takeIf { it > 0 } ?: contentView.width
val widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY)

titleView.measure(
widthSpec,
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
)
scrollContent.measure(
widthSpec,
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
)

// Calculate height excluding menu layout and adding proper spacing
val menuHeight = menuListLayout?.measuredHeight ?: 0
val spacing = if (menuHeight > 0) 38.dp else 8.dp

return titleView.measuredHeight + scrollContent.measuredHeight - menuHeight - spacing
}

override fun setupDialog(
dialog: Dialog,
style: Int,
Expand Down Expand Up @@ -225,10 +250,14 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment(

contentView.doOnPreDraw {
binding.opsLl.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = requireContext().navigationBarHeight() + 24.dp
bottomMargin = 24.dp
}
// Update peek height only if menu layout exists and has been measured
if (menuListLayout != null && menuListLayout?.measuredHeight != 0) {
val contentHeight = binding.title.height + binding.scrollContent.height -
(menuListLayout?.height ?: 0) - 38.dp
behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight)
}
behavior?.peekHeight = binding.title.height + binding.scrollContent.height -
(menuListLayout?.height ?: 0) - if (menuListLayout != null) 38.dp else 8.dp
}
}

Expand Down Expand Up @@ -405,8 +434,7 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment(
.let { layout ->
menuListLayout = layout
binding.scrollContent.addView(layout)
val safeBottomHeight = layout.getSafeAreaInsetsBottom()
binding.scrollContent.setPadding(0,0,0,safeBottomHeight)
binding.scrollContent.setPadding(0, 0, 0, 0)
binding.moreFl.setOnClickListener {
if (behavior?.state == BottomSheetBehavior.STATE_COLLAPSED) {
behavior?.state = BottomSheetBehavior.STATE_EXPANDED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import one.mixin.android.extension.dp
import one.mixin.android.extension.getClipboardManager
import one.mixin.android.extension.getOtherPath
import one.mixin.android.extension.getParcelableCompat
import one.mixin.android.extension.getSafeAreaInsetsBottom
import one.mixin.android.extension.localTime
import one.mixin.android.extension.navTo
import one.mixin.android.extension.navigationBarHeight
Expand Down Expand Up @@ -170,6 +169,32 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment()
FragmentUserBottomSheetBinding.bind(contentView)
}

override fun getPeekHeight(
contentView: View,
behavior: BottomSheetBehavior<*>,
): Int {
val titleView = contentView.findViewById<View>(R.id.title) ?: return 0
val scrollContent = contentView.findViewById<View>(R.id.scroll_content) ?: return 0

val width = contentView.measuredWidth.takeIf { it > 0 } ?: contentView.width
val widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY)

titleView.measure(
widthSpec,
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
)
scrollContent.measure(
widthSpec,
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
)

// Calculate height excluding menu layout and adding proper spacing
val menuHeight = menuListLayout?.measuredHeight ?: 0
val spacing = if (menuHeight > 0) 38.dp else 8.dp

return titleView.measuredHeight + scrollContent.measuredHeight - menuHeight - spacing
}

override fun setupDialog(
dialog: Dialog,
style: Int,
Expand Down Expand Up @@ -219,12 +244,15 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment()
contentView.doOnPreDraw {
if (!isAdded) return@doOnPreDraw
binding.opLl.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = requireContext().navigationBarHeight() + 24.dp
bottomMargin = 24.dp
}
// Update peek height only if menu layout exists and has been measured
if (menuListLayout != null && menuListLayout?.measuredHeight != 0) {
val contentHeight = binding.title.height +
binding.scrollContent.height -
(menuListLayout?.height ?: 0) - 38.dp
behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight)
}
behavior?.peekHeight =
binding.title.height +
binding.scrollContent.height -
(menuListLayout?.height ?: 0) - if (menuListLayout != null) 38.dp else 8.dp
}
},
)
Expand Down Expand Up @@ -286,12 +314,12 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment()
apps?.let {
binding.avatarGroup.setApps(it)
contentView.doOnPreDraw {
behavior?.peekHeight =
binding.title.height + binding.scrollContent.height -
(
menuListLayout?.height
?: 0
) - if (menuListLayout != null) 38.dp else 8.dp
// Update peek height when apps are loaded
if (menuListLayout != null && menuListLayout?.measuredHeight != 0) {
val contentHeight = binding.title.height + binding.scrollContent.height -
(menuListLayout?.height ?: 0) - 38.dp
behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight)
}
}
}
}
Expand Down Expand Up @@ -619,8 +647,7 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment()
list.createMenuLayout(requireContext()).let { layout ->
menuListLayout = layout
binding.scrollContent.addView(layout)
val safeBottomHeight = layout.getSafeAreaInsetsBottom()
binding.scrollContent.setPadding(0,0,0,safeBottomHeight)
binding.scrollContent.setPadding(0, 0, 0, 0)
binding.moreFl.setOnClickListener {
if (behavior?.state == BottomSheetBehavior.STATE_COLLAPSED) {
behavior?.state = BottomSheetBehavior.STATE_EXPANDED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fun MemberUpgradePaymentButton(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 30.dp)
.padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 12.dp)
) {
var buttonOffset by remember { mutableFloatStateOf(0f) }
val interactionSource = remember { MutableInteractionSource() }
Expand Down Expand Up @@ -95,7 +95,6 @@ fun MemberUpgradePaymentButton(
Button(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.height(48.dp)
.offset(x = buttonOffset.dp),
shape = RoundedCornerShape(24.dp),
Expand Down Expand Up @@ -132,7 +131,7 @@ fun MemberUpgradePaymentButton(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 30.dp)
.padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 12.dp)
) {
val isPlanAvailable = isPlanAvailableInGooglePlay(
selectedPlan,
Expand Down Expand Up @@ -168,7 +167,6 @@ fun MemberUpgradePaymentButton(
!isGooglePlayUnavailable),
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.height(48.dp),
shape = RoundedCornerShape(24.dp),
elevation = ButtonDefaults.elevation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,12 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC
} else {
baseValue.toPlainString()
}
v = BigDecimal(v).multiply(percentageOfBalance).max(BigDecimal.ZERO).setScale(8, RoundingMode.DOWN).toPlainString()
v = BigDecimal(v)
.multiply(percentageOfBalance)
.max(BigDecimal.ZERO)
.setScale(8, RoundingMode.DOWN)
.stripTrailingZeros()
.toPlainString()
updateUI()
}

Expand Down Expand Up @@ -1516,4 +1521,3 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.view.ViewGroup
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.core.view.updateMargins
import androidx.core.view.updatePadding
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.internal.ViewUtils.doOnApplyWindowInsets

Expand All @@ -27,4 +28,13 @@ internal fun BottomSheetDialog.applyBottomSheetContainerInsets(transparentStatus
}

findViewById<View>(com.google.android.material.R.id.coordinator)?.fitsSystemWindows = false
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)?.apply {
fitsSystemWindows = false
doOnApplyWindowInsets(this) { insetView, windowInsets, initialPadding ->
insetView.updatePadding(
bottom = initialPadding.bottom + windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom,
)
windowInsets
}
}
}