From 32f907716b1e46740a7a6f46320bae001895750a Mon Sep 17 00:00:00 2001
From: 62160052 <62160052@go.buu.ac.th>
Date: Wed, 21 Sep 2022 03:27:41 +0700
Subject: [PATCH] Add Cancel button to layout

---
 app/src/main/res/layout/fragment_flavor.xml  | 13 ++++++++++++-
 app/src/main/res/layout/fragment_pickup.xml  | 13 ++++++++++++-
 app/src/main/res/layout/fragment_summary.xml |  8 ++++++++
 app/src/main/res/navigation/nav_graph.xml    | 12 +++++++++++-
 4 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/app/src/main/res/layout/fragment_flavor.xml b/app/src/main/res/layout/fragment_flavor.xml
index 1f5abdd..e3816eb 100644
--- a/app/src/main/res/layout/fragment_flavor.xml
+++ b/app/src/main/res/layout/fragment_flavor.xml
@@ -110,6 +110,17 @@
                 app:layout_constraintTop_toBottomOf="@id/divider"
                 tools:text="Subtotal $5.00" />
 
+            <Button
+                android:id="@+id/cancel_button"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:text="@string/cancel"
+                android:layout_marginEnd="@dimen/side_margin"
+                style="?attr/materialButtonOutlinedStyle"
+                app:layout_constraintEnd_toStartOf="@id/next_button"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="@id/next_button" />
+
             <Button
                 android:id="@+id/next_button"
                 android:onClick="@{() -> flavorFragment.goToNextScreen()}"
@@ -119,7 +130,7 @@
                 android:text="@string/next"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintStart_toEndOf="@id/cancel_button"
                 app:layout_constraintTop_toBottomOf="@id/subtotal" />
 
         </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/fragment_pickup.xml b/app/src/main/res/layout/fragment_pickup.xml
index 20459e9..fbba9ba 100644
--- a/app/src/main/res/layout/fragment_pickup.xml
+++ b/app/src/main/res/layout/fragment_pickup.xml
@@ -106,6 +106,17 @@
                 app:layout_constraintTop_toBottomOf="@id/divider"
                 tools:text="Subtotal $5.00" />
 
+            <Button
+                android:id="@+id/cancel_button"
+                style="?attr/materialButtonOutlinedStyle"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_marginEnd="@dimen/side_margin"
+                android:text="@string/cancel"
+                app:layout_constraintEnd_toStartOf="@id/next_button"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="@id/next_button" />
+
             <Button
                 android:id="@+id/next_button"
                 android:onClick="@{() -> pickupFragment.goToNextScreen()}"
@@ -115,7 +126,7 @@
                 android:text="@string/next"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintStart_toEndOf="@id/cancel_button"
                 app:layout_constraintTop_toBottomOf="@id/subtotal" />
 
         </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/fragment_summary.xml b/app/src/main/res/layout/fragment_summary.xml
index 720a3d0..b7ad9e4 100644
--- a/app/src/main/res/layout/fragment_summary.xml
+++ b/app/src/main/res/layout/fragment_summary.xml
@@ -141,6 +141,14 @@
                 android:layout_marginTop="@dimen/side_margin"
                 android:text="@string/send" />
 
+            <Button
+                android:id="@+id/cancel_button"
+                style="?attr/materialButtonOutlinedStyle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/margin_between_elements"
+                android:text="@string/cancel" />
+
         </LinearLayout>
     </ScrollView>
 </layout>
\ No newline at end of file
diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml
index 32218fc..99c61b1 100644
--- a/app/src/main/res/navigation/nav_graph.xml
+++ b/app/src/main/res/navigation/nav_graph.xml
@@ -35,6 +35,9 @@
         <action
             android:id="@+id/action_flavorFragment_to_pickupFragment"
             app:destination="@id/pickupFragment" />
+        <action
+            android:id="@+id/action_flavorFragment_to_startFragment"
+            app:destination="@id/startFragment" />
     </fragment>
     <fragment
         android:id="@+id/pickupFragment"
@@ -44,10 +47,17 @@
         <action
             android:id="@+id/action_pickupFragment_to_summaryFragment"
             app:destination="@id/summaryFragment" />
+        <action
+            android:id="@+id/action_pickupFragment_to_startFragment"
+            app:destination="@id/startFragment" />
     </fragment>
     <fragment
         android:id="@+id/summaryFragment"
         android:name="com.example.cupcake.SummaryFragment"
         android:label="@string/order_summary"
-        tools:layout="@layout/fragment_summary" />
+        tools:layout="@layout/fragment_summary" >
+        <action
+            android:id="@+id/action_summaryFragment_to_startFragment"
+            app:destination="@id/startFragment" />
+    </fragment>
 </navigation>
\ No newline at end of file
-- 
GitLab