Skip to content

Commit

Permalink
Click on switch item to toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Sep 26, 2023
1 parent d1f489d commit 509bbb7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ class SettingsFragment : Fragment() {
) {
title.text = titleText
content.text = contentText
root.setOnClickListener {
checked.isChecked = !checked.isChecked
}
viewLifecycleOwner.lifecycleScope.launch {
setting.flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED)
.collect(checked::setChecked)
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout/switch_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/shape_margin_large"
android:background="?android:attr/selectableItemBackground"
android:paddingVertical="12dp">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingEnd="54dp"
android:textAppearance="?textAppearanceBodyLarge"
app:layout_constraintBottom_toTopOf="@id/content"
app:layout_constraintEnd_toStartOf="@id/checked"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingEnd="54dp"
android:textAppearance="?textAppearanceBodyMedium"
android:textColor="?colorOutline"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/checked"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/title_text_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<TextView
android:id="@+id/text"
style="?textAppearanceBodyLarge"
android:textAppearance="?textAppearanceBodyLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
Expand Down

0 comments on commit 509bbb7

Please sign in to comment.