app/src/main/res/layout/fragment_new_edit_item.xml
<?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"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="isNewItem"
type="Boolean" />
<variable
name="isAuthenticated"
type="Boolean" />
<variable
name="title"
type="String" />
<variable
name="description"
type="String" />
<variable
name="price"
type="String" />
<variable
name="quantity"
type="String" />
<variable
name="latitude"
type="String" />
<variable
name="longitude"
type="String" />
<variable
name="isLoading"
type="Boolean" />
<variable
name="isDiscount"
type="Boolean" />
<variable
name="priceDiscount"
type="String" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="@{isLoading ? View.VISIBLE : View.INVISIBLE}"
tools:visibility="visible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/userNotLoggedInCreateItem"
android:textAlignment="center"
android:textSize="18sp"
android:visibility="@{isAuthenticated ? View.GONE : View.VISIBLE}"
tools:visibility="gone" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="@{isAuthenticated ? View.VISIBLE : View.GONE}">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="UselessParent">
<TextView
android:id="@+id/itemPrompt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{isNewItem ? @string/new_item : @string/edit_item}"
android:textSize="30sp"
android:textStyle="bold"
tools:text="@string/new_item" />
</LinearLayout>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_is_request"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
android:paddingTop="12dp"
android:text="@string/is_request"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight="2">
<ImageButton
android:id="@+id/item_take_picture"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_weight="2"
android:contentDescription="@string/item_image_description"
android:src="@android:drawable/ic_menu_camera"
android:translationZ="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/item_open_gallery"
android:layout_width="64dp"
android:layout_height="64dp"
android:contentDescription="@string/open_gallery"
android:translationZ="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_image"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_menu_gallery" />
<ImageView
android:id="@+id/item_image"
android:layout_width="115dp"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:backgroundTint="#FFFFFF"
android:contentDescription="@string/item_image_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_baseline_image_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/itemTitleContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@={title}" />
</com.google.android.material.textfield.TextInputLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/description">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:minLines="3"
android:text="@={description}" />
</com.google.android.material.textfield.TextInputLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/price"
app:suffixText="CHF">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/itemPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="@={price}" />
</com.google.android.material.textfield.TextInputLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="start">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_is_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/is_discount"
android:textSize="17sp"
android:visibility="@{isNewItem ? View.GONE : View.VISIBLE}" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/itemDiscountContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/price"
android:visibility="@{isDiscount ? View.VISIBLE : View.GONE}"
app:suffixText="CHF">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/discountPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="@={priceDiscount}" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView_category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="@string/category"
android:textSize="20sp" />
<Space
android:layout_width="30dp"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/category_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/themeColor"
android:entries="@array/categories" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/quantity">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/itemQuantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0123456789"
android:inputType="number"
android:text="@={quantity}" />
</com.google.android.material.textfield.TextInputLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/autocomplete_fragment"
android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</androidx.fragment.app.FragmentContainerView>
<ImageButton
android:id="@+id/item_get_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:contentDescription="@string/get_location"
app:srcCompat="@android:drawable/ic_menu_mylocation" />
</LinearLayout>
<TextView
android:id="@+id/postal_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="vertical">
<Button
android:id="@+id/saveItemButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{isNewItem ? @string/create_item : @string/edit}"
tools:text="@string/create_item" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</layout>