<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="viewModel"
            type="com.topjohnwu.magisk.redesign.settings.SettingsViewModel" />

    </data>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:fillViewport="true"
        android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
        android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l2}"
        tools:layout_marginTop="24dp"
        tools:paddingTop="@dimen/l1">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:paddingTop="@dimen/l1"
            android:layout_height="wrap_content">

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/settings_card_dark"
                style="?styleCardNormal"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/l1"
                android:onClick="@{() -> viewModel.darkModePressed()}"
                app:layout_constraintEnd_toStartOf="@+id/settings_card_redesign"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <androidx.appcompat.widget.AppCompatImageView
                        android:id="@+id/settings_card_dark_icon"
                        style="?styleIconNormal"
                        android:background="@null"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:srcCompat="@drawable/ic_day_night" />

                    <androidx.appcompat.widget.AppCompatImageView
                        android:id="@+id/settings_card_dark_pointer"
                        style="?styleIconNormal"
                        android:background="@null"
                        android:rotation="180"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:srcCompat="@drawable/ic_back_md2" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="@null"
                        android:gravity="start|center_vertical"
                        android:singleLine="true"
                        android:text="@string/settings_dark_mode_title"
                        android:textAppearance="?appearanceTextBodyNormal"
                        android:textStyle="bold"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toStartOf="@+id/settings_card_dark_pointer"
                        app:layout_constraintStart_toEndOf="@+id/settings_card_dark_icon"
                        app:layout_constraintTop_toTopOf="parent" />

                </androidx.constraintlayout.widget.ConstraintLayout>

            </com.google.android.material.card.MaterialCardView>

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/settings_card_redesign"
                style="?styleCardNormal"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/l1"
                android:layout_marginRight="@dimen/l1"
                android:layout_marginBottom="@dimen/l1"
                android:onClick="@{() -> viewModel.toggle(viewModel.redesign)}"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/settings_card_dark"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="start"
                        android:paddingStart="@dimen/l1"
                        android:text="Redesign"
                        android:textAppearance="?appearanceTextBodyNormal"
                        android:textStyle="bold"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toStartOf="@+id/settings_card_redesign_switch"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <com.google.android.material.switchmaterial.SwitchMaterial
                        android:id="@+id/settings_card_redesign_switch"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginEnd="@dimen/l_50"
                        android:layout_gravity="center"
                        android:checked="@={viewModel.redesign}"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                </androidx.constraintlayout.widget.ConstraintLayout>

            </com.google.android.material.card.MaterialCardView>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.core.widget.NestedScrollView>

</layout>