<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ The MIT License (MIT)
  ~ Copyright © 2018 NBCO Yandex.Money LLC
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  ~ associated documentation files (the “Software”), to deal in the Software without restriction, including
  ~ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  ~ of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
  ~ following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all copies or substantial
  ~ portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  ~ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  ~ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  ~ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
  ~ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  ~ OTHER DEALINGS IN THE SOFTWARE.
  -->

<ViewAnimator
    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"
    android:id="@+id/rootContainer"
    android:layout_width="@dimen/ym_dialogWidth"
    android:layout_height="wrap_content"
    android:measureAllChildren="false">

    <ScrollView
        android:id="@+id/contentView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <TextView
                style="@style/ym_Text.Header3"
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/ym_screen_indentEnd"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginRight="@dimen/ym_screen_indentEnd"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:layout_marginTop="@dimen/ym_screen_indentTop"
                android:ellipsize="end"
                tools:text="Aliexpress"/>

            <TextView
                style="@style/ym_standardText"
                android:id="@+id/subtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/ym_screen_indentEnd"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginRight="@dimen/ym_screen_indentEnd"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:ellipsize="end"
                tools:text="Программа лояльности, не меняя концепции, изложенной выше, развивает медиабизнес."/>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:layout_marginTop="@dimen/ym_decor_marginTop_m"
                android:background="@color/ym_divider"/>

            <include
                android:id="@+id/paymentOption"
                layout="@layout/ym_item_common"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:background="@color/ym_divider"/>

            <ViewSwitcher
                android:id="@+id/switchesAndPaymentAuthContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:measureAllChildren="false">

                <LinearLayout
                    android:id="@+id/switchesContainer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

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

                        <android.support.v7.widget.SwitchCompat
                            style="@style/ym_Switch"
                            android:id="@+id/allowWalletLinking"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:checked="true"
                            tools:text="@string/ym_allow_wallet_linking"/>

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="1dp"
                            android:layout_gravity="bottom"
                            android:layout_marginLeft="@dimen/ym_screen_indentStart"
                            android:layout_marginStart="@dimen/ym_screen_indentStart"
                            android:background="@color/ym_divider"/>
                    </FrameLayout>

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

                        <android.support.v7.widget.SwitchCompat
                            style="@style/ym_Switch"
                            android:id="@+id/allowRecurringPayments"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:checked="true"
                            android:text="@string/ym_allow_recurring_payments"/>

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="1dp"
                            android:layout_gravity="bottom"
                            android:layout_marginLeft="@dimen/ym_screen_indentStart"
                            android:layout_marginStart="@dimen/ym_screen_indentStart"
                            android:background="@color/ym_divider"/>
                    </FrameLayout>
                </LinearLayout>

                <ViewAnimator
                    android:id="@+id/additionalInfoInputViewContainer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/ym_screen_indentEnd"
                    android:layout_marginLeft="@dimen/ym_screen_indentStart"
                    android:layout_marginRight="@dimen/ym_screen_indentEnd"
                    android:layout_marginStart="@dimen/ym_screen_indentStart"
                    android:layout_marginTop="@dimen/ym_decor_marginTop_m"
                    android:measureAllChildren="false">

                    <ProgressBar
                        android:id="@+id/paymentAuthLoading"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>

                    <ru.yandex.money.android.sdk.impl.paymentAuth.PaymentAuthView
                        android:id="@+id/paymentAuth"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>

                    <ru.yandex.money.android.sdk.utils.CustomTextInputLayout
                        android:id="@+id/phoneInputContainer"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:hintEnabled="false"
                        app:hintTextAppearance="@style/ym_TextAppearance.TextInputLayout">

                        <android.support.design.widget.TextInputEditText
                            style="@style/ym_EditText"
                            android:id="@+id/phoneInput"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:imeOptions="actionDone"
                            android:inputType="phone"
                            android:hint="@string/ym_phone_hint"/>

                    </ru.yandex.money.android.sdk.utils.CustomTextInputLayout>
                </ViewAnimator>
            </ViewSwitcher>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/ym_decor_marginBottom_2xl"
                android:layout_marginEnd="@dimen/ym_screen_indentEnd"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginRight="@dimen/ym_screen_indentEnd"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:layout_marginTop="@dimen/ym_space_2xl"
                android:orientation="horizontal">

                <TextView
                    style="@style/ym_standardText"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="@string/ym_contract_amount"/>

                <TextView
                    style="@style/ym_Text.Sum"
                    android:id="@+id/sum"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:includeFontPadding="false"
                    tools:text="29 675,50 Р"/>
            </LinearLayout>

            <TextView
                style="@style/ym_Button.Rounded"
                android:id="@+id/nextButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/ym_decor_marginBottom_m"
                android:layout_marginEnd="@dimen/ym_screen_indentEnd"
                android:layout_marginLeft="@dimen/ym_screen_indentStart"
                android:layout_marginRight="@dimen/ym_screen_indentEnd"
                android:layout_marginStart="@dimen/ym_screen_indentStart"
                android:text="@string/ym_contract_continue"/>
        </LinearLayout>
    </ScrollView>

    <ru.yandex.money.android.sdk.impl.LoadingView
        android:id="@+id/loadingView"
        android:layout_width="match_parent"
        android:layout_height="@dimen/ym_bottomDialog_maxHeight"
        android:background="@drawable/ym_dialog_background"
        android:visibility="gone"/>

    <ru.yandex.money.android.sdk.impl.ErrorView
        android:id="@+id/errorView"
        android:layout_width="match_parent"
        android:layout_height="@dimen/ym_bottomDialog_maxHeight"
        app:ym_error_button_text="@string/ym_retry"/>
</ViewAnimator>
