Skip to content

Commit

Permalink
refactor: Improve the Options BottomSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
teixeira0x committed Jan 29, 2025
1 parent 393e684 commit d07ac67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.teixeira0x.subtypo.ui.optionlist.dialog
import android.content.Context
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.teixeira0x.subtypo.ui.common.databinding.LayoutOptionListModalBinding
import com.teixeira0x.subtypo.ui.optionlist.adapter.OptionListAdapter
Expand All @@ -31,6 +32,10 @@ inline fun showOptionListDialog(
crossinline optionClickListener: (Int, OptionItem) -> Unit,
) {
BottomSheetDialog(context).apply {
behavior.apply {
peekHeight = BottomSheetBehavior.PEEK_HEIGHT_AUTO
state = BottomSheetBehavior.STATE_EXPANDED
}
configureDialog()

setContentView(
Expand Down
7 changes: 3 additions & 4 deletions common-ui/src/main/res/layout/layout_option_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_small"
android:foreground="@drawable/ripple_effect"
android:paddingHorizontal="@dimen/padding_small"
android:foreground="?attr/selectableItemBackground"
android:paddingHorizontal="@dimen/sheet_dialog_padding"
android:paddingVertical="@dimen/padding_medium">

<ImageView
Expand All @@ -24,7 +23,7 @@
android:layout_centerVertical="true"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textAppearance="?attr/textAppearanceTitleLarge"
android:textSize="16sp" />

</RelativeLayout>
5 changes: 3 additions & 2 deletions common-ui/src/main/res/layout/layout_option_list_modal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
android:layout_height="wrap_content"
android:layout_below="@id/drag_handle"
android:visibility="gone"
android:textSize="18sp"
android:paddingVertical="@dimen/padding_small"
android:paddingHorizontal="@dimen/sheet_dialog_padding"
android:textAppearance="?attr/textAppearanceTitleLarge" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="@dimen/padding_medium"
android:paddingHorizontal="@dimen/sheet_dialog_padding"
android:paddingBottom="@dimen/padding_small"
android:layout_below="@id/tv_title" />

</RelativeLayout>

0 comments on commit d07ac67

Please sign in to comment.