<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                 xmlns:app="http://schemas.android.com/apk/res-auto"
                                                 android:layout_width="match_parent"
                                                 android:layout_height="match_parent"
                                                 android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.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" />

    </android.support.design.widget.AppBarLayout>

    <ScrollView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@color/inputContrastBackground"
                app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TableLayout android:layout_width="fill_parent"
                         android:layout_height="wrap_content"
                         android:shrinkColumns="1"
                         android:background="@color/inputContrastBackground">

                <!-- Store Name -->
                <View
                    android:layout_height="@dimen/inputBorderThickness"
                    android:layout_width="match_parent"
                    android:background="@color/inputBorder" />
                <TableRow
                    android:background="@color/inputBackground"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <View
                        android:gravity="start"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />

                    <RelativeLayout
                        android:layout_weight="1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingRight="@dimen/inputPadding"
                        android:paddingEnd="@dimen/inputPadding">

                        <TextView
                            android:id="@+id/storeNameField"
                            android:text="@string/storeName"
                            android:layout_height="match_parent"
                            android:layout_width="wrap_content"
                            android:textSize="@dimen/inputSize"
                            android:padding="@dimen/inputPadding"
                            android:layout_alignParentStart="true"/>

                        <EditText
                            android:id="@+id/storeNameEdit"
                            android:inputType="textCapWords"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:padding="@dimen/inputPadding"
                            android:textSize="@dimen/inputSize"
                            android:layout_toEndOf="@id/storeNameField"/>

                        <TextView
                            android:id="@+id/storeNameView"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:padding="@dimen/inputPadding"
                            android:textSize="@dimen/inputSize"
                            android:textIsSelectable="true"
                            android:layout_toEndOf="@id/storeNameField"/>
                    </RelativeLayout>

                    <View
                        android:gravity="end"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />
                </TableRow>

                <!-- Note -->
                <View
                    android:layout_height="@dimen/inputBorderThickness"
                    android:layout_width="match_parent"
                    android:background="@color/inputBorder" />
                <TableRow
                    android:background="@color/inputBackground"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <View
                        android:gravity="start"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />

                    <RelativeLayout
                        android:layout_weight="1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingRight="@dimen/inputPadding"
                        android:paddingEnd="@dimen/inputPadding">

                        <TextView
                            android:id="@+id/noteField"
                            android:text="@string/note"
                            android:layout_height="match_parent"
                            android:layout_width="wrap_content"
                            android:textSize="@dimen/inputSize"
                            android:padding="@dimen/inputPadding"
                            android:layout_alignParentStart="true"/>

                        <EditText
                            android:id="@+id/noteEdit"
                            android:inputType="textCapSentences"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:padding="@dimen/inputPadding"
                            android:textSize="@dimen/inputSize"
                            android:layout_toEndOf="@id/noteField"/>

                        <TextView
                            android:id="@+id/noteView"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:padding="@dimen/inputPadding"
                            android:textSize="@dimen/inputSize"
                            android:textIsSelectable="true"
                            android:layout_toEndOf="@id/noteField"/>
                    </RelativeLayout>

                    <View
                        android:gravity="end"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />
                </TableRow>

                <!-- Card ID -->
                <View
                    android:id="@+id/cardIdDivider"
                    android:layout_height="@dimen/inputBorderThickness"
                    android:layout_width="match_parent"
                    android:background="@color/inputBorder" />
                <TableRow
                    android:id="@+id/cardIdTableRow"
                    android:background="@color/inputBackground"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <View
                        android:gravity="start"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />

                    <RelativeLayout
                        android:orientation="horizontal"
                        android:layout_weight="1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingRight="@dimen/inputPadding"
                        android:paddingEnd="@dimen/inputPadding">

                        <TextView
                            android:id="@+id/cardIdField"
                            android:text="@string/cardId"
                            android:layout_height="match_parent"
                            android:layout_width="wrap_content"
                            android:textSize="@dimen/inputSize"
                            android:padding="@dimen/inputPadding"
                            android:layout_alignParentStart="true"/>

                        <TextView
                            android:id="@+id/cardIdView"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:padding="@dimen/inputPadding"
                            android:textSize="@dimen/inputSize"
                            android:textIsSelectable="true"
                            android:layout_toEndOf="@id/cardIdField"/>
                    </RelativeLayout>

                    <View
                        android:gravity="end"
                        android:layout_height="match_parent"
                        android:layout_width="@dimen/inputBorderThickness"
                        android:background="@color/inputBorder" />
                </TableRow>

                <View
                    android:layout_height="@dimen/inputBorderThickness"
                    android:layout_width="match_parent"
                    android:background="@color/inputBorder" />

                <TextView android:id="@+id/barcodeType"
                          android:layout_width="fill_parent"
                          android:layout_height="wrap_content"
                          android:visibility="gone"/>

                <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:id="@+id/barcode"
                        android:contentDescription="@string/barcodeImageDescription"
                        android:layout_weight="1.0"/>
                </LinearLayout>

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

                    <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/captureButton"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:text="@string/capture"
                                android:layout_weight="1.0"/>
                        <Button android:id="@+id/enterButton"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:text="@string/enterCard"
                                android:layout_weight="1.0"/>
                    </LinearLayout>
                </LinearLayout>

            </TableLayout>
        </LinearLayout>
    </ScrollView>

</android.support.design.widget.CoordinatorLayout>
