basbeu/theSofties

View on GitHub
app/src/main/res/layout/fragment_favor_detail_view.xml

Summary

Maintainability
Test Coverage
<?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" />
        <import type="java.lang.Long"/>
        <variable
            name="elements"
            type="ch.epfl.sweng.favors.favors.FavorDetailView"
            />
    </data>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white">

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

            <TextView
                android:id="@+id/favTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="@{elements.title}"
                android:textSize="30sp"
                tools:text="Title" />

            <android.support.v7.widget.CardView
                android:id="@+id/view2"
                android:layout_width="250dp"
                android:layout_height="250dp"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    android:contentDescription="image"
                    android:src="@drawable/no_image"
                    app:srcCompat="@drawable/no_image" />
            </android.support.v7.widget.CardView>


            <TextView
                android:id="@+id/favDescription"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="35sp"
                android:text="@{elements.description}"
                android:textSize="18sp"
                tools:text="Description" />

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


                <TextView
                    android:id="@+id/favCategory"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="40dp"
                    android:paddingRight="90dp"
                    android:text="@{elements.category}"
                    android:textAlignment="textEnd"
                    tools:text="category" />

                <ImageView
                    android:id="@+id/iconCategory"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_gravity="right"
                    android:contentDescription="image"
                    android:padding="10sp"
                    android:src="@{elements.category}"/>

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/favLocation"
                    android:layout_width="180dp"
                    android:layout_height="wrap_content"
                    android:layout_margin="10sp"
                    android:paddingLeft="30dp"
                    android:text="@{elements.location}"
                    android:textAlignment="viewStart"
                    android:textSize="18sp"
                    tools:text="Location" />

                <TextView
                    android:id="@+id/favDistance"
                    android:layout_width="180dp"
                    android:layout_height="wrap_content"
                    android:layout_margin="10sp"
                    android:layout_weight="1"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp"
                    android:text="@{elements.distance}"
                    android:textAlignment="textEnd"
                    android:textSize="18sp"
                    tools:text="Distance" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center">

                <Button
                    android:id="@+id/interestedButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:backgroundTint="@{elements.isInterested ? @color/interested : @color/not_interested}"
                    android:enabled="@{elements.buttonsEnabled}"
                    android:text="@{elements.isItsOwn ? `Edit`: (elements.isInterested ? `No longer interested` : `Notify my interest`)}"
                    android:textSize="16sp"
                    />

                <Button
                    android:id="@+id/deleteButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:text="Delete"
                    android:enabled="@{elements.buttonsEnabled}"
                    android:visibility="@{elements.isItsOwn ? View.VISIBLE : View.GONE}"
                    android:textSize="16sp"/>

                <TextView
                    android:id="@+id/favTokAmmount"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="15dp"
                    android:text="@{Long.toString(elements.nbPers) + ` * ` + Long.toString(elements.tokenPerPers)}"
                    android:textSize="20sp" />

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="38sp"
                    android:layout_height="38sp"
                    android:layout_marginStart="10sp"
                    android:src="@drawable/favor_token_img" />
            </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:gravity="center"
            android:visibility="@{elements.isItsOwn ? View.VISIBLE : View.GONE}">

            <Button
                android:id="@+id/selectButton"
                android:layout_weight="2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:enabled="@{elements.buttonsEnabled}"
                android:visibility="@{elements.isItsOwn ? View.VISIBLE : View.GONE}"
                android:text="Select people" />

            <Button
                android:id="@+id/payButton"
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:enabled="@{elements.buttonsEnabled}"
                android:text="Pay"
                android:textSize="16sp"
                android:layout_gravity="center_horizontal" />

        </LinearLayout>

            <TextView
                android:id="@+id/favorPosterDetailViewAccess"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="10sp"
                android:enabled="@{elements.buttonsEnabled &amp;&amp; !elements.isItsOwn}"
                android:text="@{elements.posterName}"
                android:textSize="18sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/favReportAbusiveAdd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="40sp"
                android:enabled="@{elements.buttonsEnabled &amp;&amp; !elements.isItsOwn}"
                android:text="Report abusive add"
                android:textStyle="bold" />

        </LinearLayout>
    </ScrollView>

</layout>