<?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="data"
            type="com.topjohnwu.magisk.view.MagiskDialog.Data" />

    </data>

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

        <com.google.android.material.card.MaterialCardView
            style="@style/Widget.Card"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:cardElevation="@dimen/margin_generic"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintWidth_default="percent"
            app:layout_constraintWidth_max="400dp"
            app:layout_constraintWidth_percent=".9">

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

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/dialog_base_start"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_begin="16dp" />

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/dialog_base_end"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    app:layout_constraintGuide_end="16dp" />

                <FrameLayout
                    android:id="@+id/dialog_base_icon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon"
                        gone="@{data.icon == 0}"
                        srcCompat="@{data.icon}"
                        android:layout_gravity="center"
                        android:layout_marginTop="@dimen/margin_generic"
                        app:tint="@color/colorSecondary"
                        tools:src="@drawable/ic_delete" />

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon.Large"
                        gone="@{data.iconRaw == null}"
                        android:layout_gravity="center"
                        android:layout_marginTop="@dimen/margin_generic"
                        android:src="@{data.iconRaw}"
                        tools:src="@drawable/ic_delete" />

                </FrameLayout>

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/dialog_base_title"
                    style="@style/Widget.Text.Title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_generic_half"
                    android:gravity="center"
                    android:text="@{data.title}"
                    app:layout_constraintLeft_toLeftOf="@+id/dialog_base_start"
                    app:layout_constraintRight_toRightOf="@+id/dialog_base_end"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_icon"
                    tools:lines="1"
                    tools:text="@tools:sample/lorem/random" />

                <androidx.core.widget.NestedScrollView
                    android:id="@+id/dialog_base_scroll"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    app:layout_constraintLeft_toLeftOf="@+id/dialog_base_start"
                    app:layout_constraintRight_toRightOf="@+id/dialog_base_end"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_title">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/dialog_base_message"
                            style="@style/Widget.Text"
                            gone="@{data.message.length == 0}"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/margin_generic_half"
                            android:gravity="center"
                            android:text="@{data.message}"
                            tools:lines="3"
                            tools:text="@tools:sample/lorem/random" />

                        <FrameLayout
                            android:id="@+id/dialog_base_container"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />

                    </LinearLayout>

                </androidx.core.widget.NestedScrollView>

                <Space
                    android:id="@+id/dialog_base_space"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/margin_generic"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_scroll" />

                <View
                    android:id="@+id/dialog_base_button_0_divider"
                    style="@style/Widget.Divider.Horizontal"
                    gone="@{data.buttonPositive.icon == 0 &amp;&amp; data.buttonPositive.title.length == 0}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_space" />

                <LinearLayout
                    android:id="@+id/dialog_base_button_1"
                    style="@style/Widget.DialogButton"
                    gone="@{data.buttonPositive.icon == 0 &amp;&amp; data.buttonPositive.title.length == 0}"
                    android:clickable="@{data.buttonPositive.isEnabled()}"
                    android:filterTouchesWhenObscured="true"
                    android:focusable="@{data.buttonPositive.isEnabled()}"
                    android:onClick="@{() -> data.buttonPositive.clicked()}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_0_divider">

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon.DialogButton"
                        gone="@{data.buttonPositive.icon == 0}"
                        srcCompat="@{data.buttonPositive.icon}"
                        tools:src="@drawable/ic_delete" />

                    <androidx.appcompat.widget.AppCompatTextView
                        style="@style/Widget.Text.DialogButton"
                        gone="@{data.buttonPositive.title.length == 0}"
                        android:text="@{data.buttonPositive.title}"
                        tools:text="Button 1" />

                </LinearLayout>

                <View
                    android:id="@+id/dialog_base_button_1_divider"
                    style="@style/Widget.Divider.Horizontal"
                    gone="@{data.buttonNeutral.icon == 0 &amp;&amp; data.buttonNeutral.title.length == 0}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_1" />

                <LinearLayout
                    android:id="@+id/dialog_base_button_2"
                    style="@style/Widget.DialogButton"
                    gone="@{data.buttonNeutral.icon == 0 &amp;&amp; data.buttonNeutral.title.length == 0}"
                    android:clickable="@{data.buttonNeutral.isEnabled()}"
                    android:filterTouchesWhenObscured="true"
                    android:focusable="@{data.buttonNeutral.isEnabled()}"
                    android:onClick="@{() -> data.buttonNeutral.clicked()}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_1_divider">

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon.DialogButton"
                        gone="@{data.buttonNeutral.icon == 0}"
                        srcCompat="@{data.buttonNeutral.icon}"
                        tools:src="@drawable/ic_delete" />

                    <androidx.appcompat.widget.AppCompatTextView
                        style="@style/Widget.Text.DialogButton"
                        gone="@{data.buttonNeutral.title.length == 0}"
                        android:text="@{data.buttonNeutral.title}"
                        tools:text="Button 2" />

                </LinearLayout>

                <View
                    android:id="@+id/dialog_base_button_2_divider"
                    style="@style/Widget.Divider.Horizontal"
                    gone="@{data.buttonNegative.icon == 0 &amp;&amp; data.buttonNegative.title.length == 0}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_2" />

                <LinearLayout
                    android:id="@+id/dialog_base_button_3"
                    style="@style/Widget.DialogButton"
                    gone="@{data.buttonNegative.icon == 0 &amp;&amp; data.buttonNegative.title.length == 0}"
                    android:clickable="@{data.buttonNegative.isEnabled()}"
                    android:filterTouchesWhenObscured="true"
                    android:focusable="@{data.buttonNegative.isEnabled()}"
                    android:onClick="@{() -> data.buttonNegative.clicked()}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_2_divider">

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon.DialogButton"
                        gone="@{data.buttonNegative.icon == 0}"
                        srcCompat="@{data.buttonNegative.icon}"
                        tools:src="@drawable/ic_delete" />

                    <androidx.appcompat.widget.AppCompatTextView
                        style="@style/Widget.Text.DialogButton"
                        gone="@{data.buttonNegative.title.length == 0}"
                        android:text="@{data.buttonNegative.title}"
                        tools:text="Button 3" />

                </LinearLayout>

                <View
                    android:id="@+id/dialog_base_button_3_divider"
                    style="@style/Widget.Divider.Horizontal"
                    gone="@{data.buttonIDGAF.icon == 0 &amp;&amp; data.buttonIDGAF.title.length == 0}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_3" />

                <LinearLayout
                    android:id="@+id/dialog_base_button_4"
                    style="@style/Widget.DialogButton"
                    gone="@{data.buttonIDGAF.icon == 0 &amp;&amp; data.buttonIDGAF.title.length == 0}"
                    android:clickable="@{data.buttonIDGAF.isEnabled()}"
                    android:filterTouchesWhenObscured="true"
                    android:focusable="@{data.buttonIDGAF.isEnabled()}"
                    android:onClick="@{() -> data.buttonIDGAF.clicked()}"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/dialog_base_button_3_divider">

                    <androidx.appcompat.widget.AppCompatImageView
                        style="@style/Widget.Icon.DialogButton"
                        gone="@{data.buttonIDGAF.icon == 0}"
                        srcCompat="@{data.buttonIDGAF.icon}"
                        tools:src="@drawable/ic_delete" />

                    <androidx.appcompat.widget.AppCompatTextView
                        style="@style/Widget.Text.DialogButton"
                        gone="@{data.buttonIDGAF.title.length == 0}"
                        android:text="@{data.buttonIDGAF.title}"
                        tools:text="Button 4" />

                </LinearLayout>


            </androidx.constraintlayout.widget.ConstraintLayout>

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

    </androidx.constraintlayout.widget.ConstraintLayout>


</layout>