<?xml version="1.0" encoding="utf-8"?>
<!--
  TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="io.timelimit.android.ui.manage.parent.password.change.ChangeParentPasswordFragment">

    <data>
        <variable
            name="isWorking"
            type="Boolean" />

        <variable
            name="canConfirm"
            type="Boolean" />
    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:padding="8dp"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <androidx.cardview.widget.CardView
                    app:cardUseCompatPadding="true"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:padding="8dp"
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <TextView
                            android:text="@string/manage_parent_change_password_title"
                            android:textAppearance="?android:textAppearanceLarge"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />

                        <EditText
                            android:id="@+id/old_password"
                            android:enabled="@{!safeUnbox(isWorking)}"
                            android:inputType="textPassword"
                            android:hint="@string/manage_parent_change_password_old_password_hint"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />

                        <io.timelimit.android.ui.view.SetPasswordView
                            android:id="@+id/new_password"
                            android:enabled="@{!safeUnbox(isWorking)}"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />

                        <Button
                            android:layout_marginRight="8dp"
                            android:id="@+id/save_button"
                            android:enabled="@{safeUnbox(canConfirm) &amp;&amp; (!safeUnbox(isWorking))}"
                            android:layout_gravity="end"
                            android:text="@string/generic_save"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />

                    </LinearLayout>
                </androidx.cardview.widget.CardView>
            </LinearLayout>
        </ScrollView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
