<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fabSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        app:srcCompat="@drawable/save_24dp"
        android:contentDescription="@string/save"
        android:layout_margin="16dp" />

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <com.google.android.material.tabs.TabItem
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/card"/>
            <com.google.android.material.tabs.TabItem
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/barcode"/>
            <com.google.android.material.tabs.TabItem
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/photos"/>
        </com.google.android.material.tabs.TabLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <ScrollView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@color/inputContrastBackground"
                app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TableLayout
                android:id="@+id/cardPart"
                android:visibility="gone">
                <!-- Store -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <com.google.android.material.card.MaterialCardView
                        android:layout_width="@dimen/cardThumbnailSize"
                        android:layout_height="@dimen/cardThumbnailSize"
                        android:layout_marginEnd="@dimen/activity_margin"
                        android:layout_gravity="center_vertical"
                        app:cardCornerRadius="4dp"
                        android:paddingHorizontal="@dimen/inputPadding"
                        app:cardElevation="0dp"
                        app:cardBackgroundColor="@android:color/transparent"
                        android:outlineProvider="none">

                        <ImageView
                            android:id="@+id/thumbnail"
                            android:layout_width="@dimen/cardThumbnailSize"
                            android:layout_height="@dimen/cardThumbnailSize"
                            android:contentDescription="@string/thumbnailDescription"
                            android:src="@mipmap/ic_launcher"/>

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

                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/storeNameField"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/storeName">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/storeNameEdit"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true" />

                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Card ID -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/cardIdField"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/cardId">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/cardIdView"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:singleLine="true" />

                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Note -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/noteField"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/note">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/noteEdit"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            />

                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Group -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <com.google.android.material.chip.ChipGroup
                        android:id="@+id/groupChips"
                        android:layout_height="match_parent"
                        android:layout_width="match_parent"
                        android:padding="@dimen/inputPadding"
                        android:textSize="@dimen/inputSize" />
                </LinearLayout>

                <!-- Balance -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <!-- Balance -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/balanceView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/balance"
                        android:labelFor="@+id/balanceField">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/balanceField"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="numberDecimal"
                            android:digits="0123456789.,$" />

                    </com.google.android.material.textfield.TextInputLayout>

                    <!-- Currency -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/balanceCurrencyView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/currency"
                        android:labelFor="@+id/balanceCurrencyField">

                        <AutoCompleteTextView
                            android:id="@+id/balanceCurrencyField"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="none"/>

                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Expiration -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <!-- Expiry date -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/expiryView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/expiryDate"
                        android:labelFor="@+id/expiryField">

                        <AutoCompleteTextView
                            android:id="@+id/expiryField"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="none"/>
                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>
            </TableLayout>
            <TableLayout
                android:id="@+id/barcodePart"
                android:visibility="gone">

                <!-- Barcode ID -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <!-- Barcode ID -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/barcodeIdView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/barcodeId"
                        android:labelFor="@+id/barcodeIdView">

                        <AutoCompleteTextView
                            android:id="@+id/barcodeIdField"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="none"/>

                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Barcode type -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding"
                    android:orientation="horizontal">

                    <!-- Barcode type -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/barcodeTypeView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/barcodeType"
                        android:labelFor="@+id/barcodeTypeField">

                        <AutoCompleteTextView
                            android:id="@+id/barcodeTypeField"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="none"/>
                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <!-- Barcode -->
                <View
                    android:layout_height="@dimen/inputBorderThickness"
                    android:layout_width="match_parent" />

                <LinearLayout android:orientation="horizontal"
                              android:padding="10.0dip"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:visibility="gone"
                              android:id="@+id/barcodeLayout">
                    <ImageView
                        android:layout_width="0dp"
                        android:layout_height="@dimen/barcode_disp_height"
                        android:layout_gravity="center_horizontal"
                        android:padding="10.0dp"
                        android:background="#ffffff"
                        android:id="@+id/barcode"
                        android:layout_weight="1.0"/>
                </LinearLayout>

                <!-- Buttons -->
                <LinearLayout android:orientation="horizontal"
                    android:padding="10.0dip"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/barcodeCaptureLayout">
                    <Button android:id="@+id/enterButton"
                        android:layout_margin="@dimen/inputMargin"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:text="@string/editBarcode"
                        android:textColor="#FFFFFF"
                        android:layout_weight="1.0"/>
                </LinearLayout>
            </TableLayout>

            <TableLayout
                android:id="@+id/picturesPart"
                android:visibility="gone"
                tools:visibility="visible">

                <!-- Front image -->
                <LinearLayout
                    android:id="@+id/frontImageHolder"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding">

                    <!-- Front image -->
                    <com.google.android.material.card.MaterialCardView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_marginStart="@dimen/activity_margin"
                        android:layout_marginTop="@dimen/activity_margin"
                        android:layout_marginEnd="@dimen/activity_margin"
                        android:layout_marginBottom="@dimen/activity_margin"
                        android:paddingHorizontal="@dimen/inputPadding"
                        app:cardCornerRadius="4dp"
                        app:cardElevation="0dp">

                        <ImageView
                            android:id="@+id/frontImage"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:adjustViewBounds="true"
                            android:minHeight="50dp"
                            android:contentDescription="@string/frontImageDescription"
                            android:scaleType="fitCenter"
                            app:srcCompat="@drawable/ic_camera_white" />

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

                <!-- Back image -->
                <LinearLayout
                    android:id="@+id/backImageHolder"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingHorizontal="@dimen/inputPadding"
                    android:paddingTop="@dimen/inputPadding">

                    <!-- Back image -->
                    <com.google.android.material.card.MaterialCardView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_marginStart="@dimen/activity_margin"
                        android:layout_marginTop="@dimen/activity_margin"
                        android:layout_marginEnd="@dimen/activity_margin"
                        android:layout_marginBottom="@dimen/activity_margin"
                        android:paddingHorizontal="@dimen/inputPadding"
                        app:cardCornerRadius="4dp"
                        app:cardElevation="0dp">

                        <ImageView
                            android:id="@+id/backImage"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:adjustViewBounds="true"
                            android:minHeight="50dp"
                            android:contentDescription="@string/backImageDescription"
                            android:scaleType="fitCenter"
                            app:srcCompat="@drawable/ic_camera_white" />

                    </com.google.android.material.card.MaterialCardView>
                </LinearLayout>
            </TableLayout>
        </TableLayout>
    </ScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
