Skip to content

Commit

Permalink
Home Fragment Overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
whyfoo committed Dec 3, 2021
1 parent 36c5f1e commit 706f747
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 99 deletions.
60 changes: 24 additions & 36 deletions app/src/main/java/com/trolle/trolleapp/HomeFragment.kt
Original file line number Diff line number Diff line change
@@ -1,59 +1,47 @@
package com.trolle.trolleapp

import android.app.AlertDialog
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.navigation.Navigation
import com.trolle.trolleapp.databinding.FragmentHomeBinding

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [HomeFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class HomeFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!!

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false)
_binding = FragmentHomeBinding.inflate(inflater, container, false)
return binding.root
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment HomeFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
HomeFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.imageViewBarcode.setOnClickListener{

val alertDialog = AlertDialog.Builder(requireContext())
alertDialog.apply {
setTitle("Success!")
setMessage("Your smartphone has successfully connected with Trolley ID = (ID). " +
" Happy Shopping!")
setPositiveButton("OK") { _, _ ->
//Toast.makeText(requireContext(), "yes", Toast.LENGTH_SHORT).show()
Navigation.findNavController(view).navigate(R.id.payFragment)
}.create().show()
}
}
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_edit_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_baseline_qr_code_scanner_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9.5,6.5v3h-3v-3H9.5M11,5H5v6h6V5L11,5zM9.5,14.5v3h-3v-3H9.5M11,13H5v6h6V13L11,13zM17.5,6.5v3h-3v-3H17.5M19,5h-6v6h6V5L19,5zM13,13h1.5v1.5H13V13zM14.5,14.5H16V16h-1.5V14.5zM16,13h1.5v1.5H16V13zM13,16h1.5v1.5H13V16zM14.5,17.5H16V19h-1.5V17.5zM16,16h1.5v1.5H16V16zM17.5,14.5H19V16h-1.5V14.5zM17.5,17.5H19V19h-1.5V17.5zM22,7h-2V4h-3V2h5V7zM22,22v-5h-2v3h-3v2H22zM2,22h5v-2H4v-3H2V22zM2,2v5h2V4h3V2H2z"/>
</vector>
Binary file added app/src/main/res/drawable/qrscan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/roundedshapebtn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
<solid android:color="@color/pink"/> <!-- this one is ths color of the Rounded Button -->
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
45 changes: 0 additions & 45 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,6 @@
android:background="@color/bgc"
tools:context=".ui.home.HomeActivity">

<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center"-->
<!-- android:orientation="vertical"-->
<!-- android:background="@color/bgc">-->

<!-- <TextView-->
<!-- android:id="@+id/text_view_title"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/connect_to_trolley"-->
<!-- android:textSize="36sp"-->
<!-- android:textStyle="bold"-->
<!-- android:textColor="@color/pink"-->
<!-- android:layout_marginBottom="20dp"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- />-->

<!-- <ImageView-->
<!-- android:id="@+id/image_view_barcode"-->
<!-- android:layout_width="250dp"-->
<!-- android:layout_height="250dp"-->
<!-- android:layout_margin="5dp"-->
<!-- android:background="@drawable/rounded_edittext"-->
<!-- android:src="@drawable/barcode"-->
<!-- />-->

<!-- </LinearLayout>-->

<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
Expand All @@ -64,16 +31,4 @@
app:menu="@menu/bottom_bar"
/>

<!-- <fragment-->
<!-- android:id="@+id/nav_host_fragment"-->
<!-- android:name="androidx.navigation.fragment.NavHostFragment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:defaultNavHost="true"-->
<!-- app:layout_constraintBottom_toTopOf="@id/bottom_navigation"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:navGraph="@navigation/mobile_navigation" />-->

</RelativeLayout>
18 changes: 9 additions & 9 deletions app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@

</LinearLayout>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="@drawable/rounded_bottom_bar"
app:menu="@menu/bottom_bar"
/>
<!-- <com.google.android.material.bottomnavigation.BottomNavigationView-->
<!-- android:id="@+id/bottom_bar"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="bottom"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:background="@drawable/rounded_bottom_bar"-->
<!-- app:menu="@menu/bottom_bar"-->
<!-- />-->

</RelativeLayout>
65 changes: 62 additions & 3 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text='ini fragment home' />
android:orientation="vertical"
android:background="@color/bgc">

<TextView
android:id="@+id/text_view_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to Troll-E!"
android:textAlignment="center"
android:textSize="28sp"
android:textStyle="bold"
android:textColor="@color/pink"
android:layout_marginBottom="20dp"
/>

<TextView
android:id="@+id/text_view_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/connect_to_trolley"
android:textAlignment="center"
android:justificationMode="inter_word"
android:textSize="18sp"
android:textColor="@color/pink"
android:padding="20dp"
/>

<com.google.android.material.button.MaterialButton
android:layout_marginTop="20dp"
android:id="@+id/image_view_barcode"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Scan QR Code"
style="@style/Widget.MaterialComponents.Button.TextButton"
app:icon="@drawable/ic_baseline_qr_code_scanner_24"
android:backgroundTint="@color/white"
app:cornerRadius="15dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OR"
android:textAlignment="center"
android:textSize="15sp"
android:textColor="@color/grey"
android:padding="10dp"
/>

<com.google.android.material.button.MaterialButton
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Manually input the ID"
style="@style/Widget.MaterialComponents.Button.TextButton"
app:icon="@drawable/ic_baseline_edit_24"
android:backgroundTint="@color/white"
app:cornerRadius="15dp"
/>

</LinearLayout>

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_pay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<!-- TODO: Update blank fragment layout -->
<TextView
android:textColor="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
Expand Down
46 changes: 42 additions & 4 deletions app/src/main/res/layout/fragment_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,49 @@
android:layout_height="match_parent"
tools:context=".ProfileFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text='ini fragment profile' />
android:orientation="vertical">

<ImageView
android:id="@+id/image_view_profile"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/profile"/>

<TextView
android:id="@+id/text_view_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/purple"
android:textAlignment="center"
android:text="@string/username_dummy"
android:textSize="24sp"
android:layout_marginTop="30dp"/>

<TextView
android:id="@+id/text_view_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/grey"
android:textAlignment="center"
android:text="@string/email_dummy"
android:textSize="20sp"
android:layout_marginTop="5dp"/>

<TextView
android:id="@+id/text_view_history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/purple"
android:textAlignment="center"
android:text="@string/see_shopping_history"
android:textSize="24sp"
android:layout_marginTop="150dp"/>

</LinearLayout>

</FrameLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<string name="email">Email</string>
<string name="or_sign_up_using">or Sign Up using</string>
<string name="already_have_an_account">Already have an account?</string>
<string name="connect_to_trolley">Connect to Trolley?</string>
<string name="connect_to_trolley">Ready to shop? \n\nTo get started, scan the QR Code found on the trolley or manually input the Trolley ID using the button below</string>
<string name="connection_success">Connection Success</string>
<string name="happy_shopping">Happy Shopping</string>
<string name="connection_failed">Connection Failed</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:windowBackground">@color/bgc</item>
<item name="android:textColor">@color/white</item>
<item name="colorAccent">@color/pink</item>
</style>
</resources>

0 comments on commit 706f747

Please sign in to comment.