<?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">

    <data>

        <variable
            name="viewModel"
            type="com.doverfuelingsolutions.issp.view.UpgradeActivity.UpdateViewModel" />

        <variable
            name="handler"
            type="com.doverfuelingsolutions.issp.view.UpgradeActivity" />

        <import type="android.view.View" />
    </data>

    <LinearLayout
        style="@style/wrap"
        android:layout_gravity="center"
        android:background="@drawable/border_gray"
        android:elevation="60dp"
        android:gravity="center_horizontal"
        android:minWidth="600dp"
        android:orientation="vertical"
        android:paddingHorizontal="40dp"
        android:paddingVertical="80dp">

        <com.moos.library.CircleProgressView
            android:id="@+id/progressView"
            android:layout_width="240dp"
            android:layout_height="240dp"
            app:circleBroken="true"
            app:end_color="@color/colorPrimary"
            app:end_progress="100"
            app:isTracked="true"
            app:progressDuration="300"
            app:progressTextVisibility="false"
            app:start_color="@color/colorSecondary"
            app:start_progress="0"
            app:track_width="26dp" />

        <TextView
            android:id="@+id/progressText"
            style="@style/wrap"
            android:text="@{@string/download_progress(viewModel.progress), default=@string/download_progress}"
            android:textColor="@color/colorPrimaryVariant"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/errorText"
            style="@style/wrap"
            android:layout_marginTop="40dp"
            android:lineSpacingExtra="2dp"
            android:maxWidth="500dp"
            android:singleLine="false"
            android:text="@{viewModel.errorText, default=@string/download_fail}"
            android:textColor="@color/colorRed"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/versionTitle"
            style="@style/wrap"
            android:layout_gravity="start"
            android:layout_marginTop="60dp"
            android:text="@{@string/new_version(viewModel.version), default=@string/new_version}"
            android:textColor="@color/color333"
            android:textSize="24sp" />

        <TextView
            style="@style/wrap"
            android:layout_gravity="start"
            android:layout_marginTop="14dp"
            android:text="@{@string/publish_at(viewModel.versionPublishTime), default=@string/publish_at}"
            android:textColor="@color/color555"
            android:textSize="18sp" />

        <TextView
            style="@style/wrap"
            android:layout_gravity="start"
            android:layout_marginTop="14dp"
            android:text="@string/version_info_is"
            android:textColor="@color/color555"
            android:textSize="18sp" />

        <TextView
            style="@style/wrap"
            android:layout_gravity="start"
            android:layout_marginTop="8dp"
            android:text="@{viewModel.versionFeature, default=@string/current_version_is_latest}"
            android:textColor="@color/color777"
            android:textSize="16sp" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:orientation="horizontal">

            <Button
                android:id="@+id/buttonAction"
                style="@style/Widget.MaterialComponents.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="12dp"
                android:onClick="@{handler}"
                android:text="@{viewModel.buttonText, default=@string/install_app}"
                android:visibility="@{viewModel.buttonVisible ? View.VISIBLE : View.GONE}" />

            <Button
                android:id="@+id/buttonCancel"
                style="@style/Widget.MaterialComponents.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="12dp"
                android:onClick="@{handler}"
                android:text="@string/cancel_update" />
        </LinearLayout>
    </LinearLayout>
</layout>