<?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"
        android:layout_margin="16dp"
        android:contentDescription="@string/save"
        app:srcCompat="@drawable/ic_done" />

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            style="?attr/toolbarStyle" />

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent">
            <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/options"/>
            <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>

    <androidx.core.widget.NestedScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        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">

                        <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.imageview.ShapeableImageView
                            android:id="@+id/thumbnailEditIcon"
                            app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Material3.FloatingActionButton"
                            android:layout_width="@dimen/cardThumbnailEditOverlaySize"
                            android:layout_height="@dimen/cardThumbnailEditOverlaySize"
                            android:layout_gravity="bottom|end"
                            android:layout_margin="4dp"
                            app:contentPadding="4dp"
                            android:alpha="0.8"
                            android:src="@drawable/ic_mode_edit_white_24dp"/>

                    </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"
                            android:inputType="textCapWords" />

                    </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>

                <!-- 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 encoding -->
                <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/barcodeEncodingView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/barcodeEncoding"
                        android:labelFor="@+id/barcodeEncodingField">

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

                <!-- Barcode -->
                <LinearLayout android:orientation="horizontal"
                    android:layout_marginTop="10.0dp"
                    android:layout_marginStart="10.0dp"
                    android:layout_marginEnd="10.0dp"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/barcodeLayout">
                    <ImageView
                        android:background="@drawable/round_outline"
                        android:importantForAccessibility="no"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/barcode_disp_height"
                        android:layout_gravity="center_horizontal"
                        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:layout_weight="1.0"/>
                </LinearLayout>
            </TableLayout>
            <TableLayout
                android:id="@+id/optionsPart"
                android:visibility="gone">

                <!-- 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:contentDescription="@string/groups"
                        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">

                    <!-- 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>

                    <!-- 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>
                </LinearLayout>

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

                    <!-- Valid from -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/validFromView"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.0"
                        android:hint="@string/validFromDate"
                        android:labelFor="@+id/validFromField">

                        <AutoCompleteTextView
                            android:id="@+id/validFromField"
                            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/picturesPart"
                android:visibility="gone"
                tools:visibility="visible">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:baselineAligned="false">

                    <!-- Front image -->
                    <com.google.android.material.card.MaterialCardView
                        android:id="@+id/frontImageHolder"
                        android:layout_weight="1"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_margin="5dp"
                        style="?attr/materialCardViewElevatedStyle">

                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:id="@+id/frontImageConstraint"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <!-- Back image -->
                            <ImageView
                                android:id="@+id/frontImage"
                                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"
                                android:background="?attr/colorPrimary"
                                app:layout_constraintBottom_toTopOf="@id/frontImageDescription"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintStart_toStartOf="parent"
                                app:layout_constraintTop_toTopOf="parent" />

                            <TextView
                                android:id="@+id/frontImageDescription"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="4dp"
                                android:text="@string/frontImageDescription"
                                android:textAppearance="?attr/textAppearanceHeadlineSmall"
                                android:gravity="center"
                                app:layout_constraintTop_toBottomOf="@id/frontImage"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintStart_toStartOf="parent"/>
                        </androidx.constraintlayout.widget.ConstraintLayout>
                    </com.google.android.material.card.MaterialCardView>

                    <!-- Back image -->
                    <com.google.android.material.card.MaterialCardView
                        android:layout_weight="1"
                        android:id="@+id/backImageHolder"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_margin="5dp"
                        style="?attr/materialCardViewElevatedStyle">

                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:id="@+id/backImageConstraint"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <!-- Back image -->
                            <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"
                                android:background="?attr/colorPrimary"
                                app:layout_constraintBottom_toTopOf="@id/backImageDescription"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintStart_toStartOf="parent"
                                app:layout_constraintTop_toTopOf="parent" />

                            <TextView
                                android:id="@+id/backImageDescription"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="8dp"
                                android:layout_marginEnd="8dp"
                                android:layout_marginBottom="4dp"
                                android:text="@string/backImageDescription"
                                android:textAppearance="?attr/textAppearanceHeadlineSmall"
                                android:gravity="center"
                                app:layout_constraintTop_toBottomOf="@id/backImage"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintStart_toStartOf="parent"/>
                        </androidx.constraintlayout.widget.ConstraintLayout>
                    </com.google.android.material.card.MaterialCardView>
                </LinearLayout>
            </TableLayout>
        </TableLayout>
    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
