mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Add order history screen
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
android:theme="@style/Theme.Foodify"
|
||||
tools:replace="android:theme"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".Activity.OrderActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.AddressManagerActivity"
|
||||
android:exported="false" />
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.capstone.foodify.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.capstone.foodify.Fragment.Order.ViewPagerAdapter;
|
||||
import com.capstone.foodify.R;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
public class OrderActivity extends AppCompatActivity {
|
||||
|
||||
TabLayout tabLayout;
|
||||
ViewPager2 viewPager2;
|
||||
ViewPagerAdapter viewPagerAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order);
|
||||
|
||||
tabLayout = findViewById(R.id.tab_layout);
|
||||
viewPager2 = findViewById(R.id.view_pager);
|
||||
viewPagerAdapter = new ViewPagerAdapter(this);
|
||||
viewPager2.setAdapter(viewPagerAdapter);
|
||||
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
viewPager2.setCurrentItem(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
tabLayout.getTabAt(position).select();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.capstone.foodify.Fragment.Order;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class CompleteOrderFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_complete_order, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.capstone.foodify.Fragment.Order;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class ProgressOderFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_progress_order, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.capstone.foodify.Fragment.Order;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
public class ShipOrderFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_ship_order, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.capstone.foodify.Fragment.Order;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch(position){
|
||||
case 1:
|
||||
return new ShipOrderFragment();
|
||||
case 2:
|
||||
return new CompleteOrderFragment();
|
||||
default:
|
||||
return new ProgressOderFragment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.capstone.foodify.Activity.AccountAndProfileActivity;
|
||||
import com.capstone.foodify.Activity.AddressManagerActivity;
|
||||
import com.capstone.foodify.Activity.OrderActivity;
|
||||
import com.capstone.foodify.Activity.SignUpActivity;
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
@@ -19,15 +20,16 @@ public class ProfileFragment extends Fragment {
|
||||
|
||||
Button btnSignUp;
|
||||
|
||||
LinearLayout account_and_profile, manage_address;
|
||||
LinearLayout account_and_profile, manage_address, order_history;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View rootView = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
btnSignUp = (Button) rootView.findViewById(R.id.sign_up_button);
|
||||
account_and_profile = (LinearLayout) rootView.findViewById(R.id.account_and_profile);
|
||||
manage_address = (LinearLayout) rootView.findViewById(R.id.manage_address);
|
||||
btnSignUp = rootView.findViewById(R.id.sign_up_button);
|
||||
account_and_profile = rootView.findViewById(R.id.account_and_profile);
|
||||
manage_address = rootView.findViewById(R.id.manage_address);
|
||||
order_history = rootView.findViewById(R.id.order_history);
|
||||
|
||||
btnSignUp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -49,6 +51,13 @@ public class ProfileFragment extends Fragment {
|
||||
startActivity(new Intent(getActivity(), AddressManagerActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
order_history.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(getActivity(), OrderActivity.class));
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Activity.OrderActivity">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tab_layout"
|
||||
style="@style/MyCustomTabLayout"
|
||||
app:tabIndicatorColor="@color/primaryColor"
|
||||
>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:text="Đang xử lý"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:text="Đang giao"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:text="Giao thành công"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_below="@id/tab_layout"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Fragment.Order.CompleteOrderFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="List order have completed!" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -156,17 +156,16 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:text="Order"
|
||||
android:textSize="18sp"
|
||||
android:fontFamily="@font/opensans"
|
||||
android:textColor="@color/black"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp"
|
||||
tools:ignore="HardcodedText"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
android:fontFamily="@font/opensans"
|
||||
android:text="Order"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Fragment.Order.ProgressOderFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="List order in progress status!" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Fragment.Order.ShipOrderFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="List order need to ship!" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -30,4 +30,13 @@
|
||||
<item name="android:color">@color/primaryColor</item>
|
||||
</style>
|
||||
|
||||
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
|
||||
<item name="tabTextAppearance">@style/MyCustomTextAppearance</item>
|
||||
</style>
|
||||
|
||||
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
|
||||
<item name="textAllCaps">false</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user