Skip to content

Commit 37f0d1a

Browse files
committed
update
1 parent 0bbc7d6 commit 37f0d1a

File tree

75 files changed

+1506
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1506
-1112
lines changed

android/app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
FlutterApplication and put your custom class here. -->
88
<application
99
android:label="Peachy"
10-
android:icon="@mipmap/ic_launcher">
10+
android:icon="@mipmap/ic_launcher"
11+
android:requestLegacyExternalStorage="true">
1112
<activity
1213
android:name=".MainActivity"
1314
android:launchMode="singleTop"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:layout_gravity="center_horizontal"
7+
android:layout_marginStart="10dp"
8+
android:background="@drawable/corner"
9+
android:layout_marginEnd="10dp">
10+
11+
<TextView
12+
android:id="@+id/text"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:background="#CC000000"
16+
android:paddingStart="20dp"
17+
android:paddingTop="20dp"
18+
android:paddingEnd="20dp"
19+
android:paddingBottom="20dp"
20+
android:textStyle="bold"
21+
android:textColor="#FFFFFF"
22+
tools:text="Toast should be short." />
23+
</FrameLayout>

assets/icons/location.svg

+50
Loading

assets/icons/order.svg

+1
Loading
File renamed without changes.

assets/icons/speech-bubble.svg

+44-1
Loading

assets/locale/en.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"products": "products",
144144
"your_feedback": "Your feeback",
145145
"support": "Support",
146-
"created": "Created",
146+
"created_at": "Created at",
147147
"check_out": "Check out",
148148
"continue": "Continue",
149149
"don't_match_password": "Don't match password",
@@ -155,5 +155,14 @@
155155
"ship_to": "Ship to",
156156
"payment_success": "Payment Success",
157157
"detail_order": "Detail order",
158-
"my_orders": "My orders"
158+
"my_orders": "My orders",
159+
"be_delivering": "Be delivering ...",
160+
"delivered": "Delivered",
161+
"cancel": "Cancel",
162+
"quantity": "Quantity",
163+
"item": "items",
164+
"order_successfully": "Order successfully",
165+
"cancel_successfully": "Cancel successfully",
166+
"add_successfully": "Add successfully",
167+
"save": "Save"
159168
}

assets/locale/vi.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"products": "sản phẩm",
119119
"your_feedback": "Phản hồi của bạn",
120120
"support": "Support",
121-
"created": "Được tạo",
121+
"created_at": "Được tạo lúc",
122122
"check_out": "Thanh toán",
123123
"continue": "Tiếp tục",
124124
"don't_match_password": "Mật khẩu không khớp",
@@ -130,5 +130,14 @@
130130
"ship_to": "Chuyển tới",
131131
"payment_success": "Thanh toán thành công",
132132
"detail_order": "Chi tiết đơn hàng",
133-
"my_orders": "Đơn hàng của tôi"
133+
"my_orders": "Đơn hàng của tôi",
134+
"be_delivering": "Đang giao hàng ...",
135+
"delivered": "Đã giao",
136+
"cancel": "Hủy",
137+
"quantity": "Số lượng",
138+
"item": "mặt hàng",
139+
"order_successfully": "Đặt hàng thành công",
140+
"cancel_successfully": "Hủy đơn hàng thành công",
141+
"add_successfully": "Thêm thành công",
142+
"save": "Lưu"
134143
}

lib/app_view.dart

+33-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import 'package:e_commerce_app/bottom_navigation.dart';
12
import 'package:e_commerce_app/configs/application.dart';
3+
import 'package:e_commerce_app/presentation/screens/login/login_screen.dart';
4+
import 'package:e_commerce_app/presentation/screens/splash/splash_screen.dart';
25
import 'package:flutter_localizations/flutter_localizations.dart';
36
import 'package:flutter/material.dart';
47
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -17,10 +20,6 @@ class AppView extends StatefulWidget {
1720
}
1821

1922
class _AppViewState extends State<AppView> {
20-
final _navigatorKey = GlobalKey<NavigatorState>();
21-
22-
NavigatorState? get _navigator => _navigatorKey.currentState;
23-
2423
@override
2524
void initState() {
2625
CommonBloc.applicationBloc.add(SetupApplication());
@@ -33,11 +32,7 @@ class _AppViewState extends State<AppView> {
3332
super.dispose();
3433
}
3534

36-
void _onNavigate(String route) {
37-
_navigator!.pushNamedAndRemoveUntil(route, (route) => false);
38-
}
39-
40-
void _loadData() {
35+
void loadData() {
4136
// Only load data when authenticated
4237
BlocProvider.of<ProfileBloc>(context).add(LoadProfile());
4338
BlocProvider.of<CartBloc>(context).add(LoadCart());
@@ -47,36 +42,35 @@ class _AppViewState extends State<AppView> {
4742
Widget build(BuildContext context) {
4843
return BlocBuilder<LanguageBloc, LanguageState>(
4944
builder: (context, state) {
50-
return MaterialApp(
51-
navigatorKey: _navigatorKey,
52-
debugShowCheckedModeBanner: Application.debug,
53-
title: Application.title,
54-
theme: AppTheme.currentTheme,
55-
onGenerateRoute: AppRouter.generateRoute,
56-
initialRoute: AppRouter.SPLASH,
57-
locale: AppLanguage.defaultLanguage,
58-
supportedLocales: AppLanguage.supportLanguage,
59-
localizationsDelegates: [
60-
Translate.delegate,
61-
GlobalMaterialLocalizations.delegate,
62-
GlobalWidgetsLocalizations.delegate,
63-
GlobalCupertinoLocalizations.delegate,
64-
],
65-
builder: (context, child) {
66-
return BlocListener<AuthenticationBloc, AuthenticationState>(
67-
listener: (context, state) {
68-
if (state is Uninitialized) {
69-
_onNavigate(AppRouter.SPLASH);
70-
} else if (state is Unauthenticated) {
71-
_onNavigate(AppRouter.LOGIN);
72-
} else if (state is Authenticated) {
73-
_loadData();
74-
_onNavigate(AppRouter.LOGIN_SUCCESS);
75-
} else {
76-
_onNavigate(AppRouter.SPLASH);
77-
}
78-
},
79-
child: child,
45+
return BlocBuilder<AuthenticationBloc, AuthenticationState>(
46+
builder: (context, authState) {
47+
return MaterialApp(
48+
debugShowCheckedModeBanner: Application.debug,
49+
title: Application.title,
50+
theme: AppTheme.currentTheme,
51+
onGenerateRoute: AppRouter.generateRoute,
52+
locale: AppLanguage.defaultLanguage,
53+
supportedLocales: AppLanguage.supportLanguage,
54+
localizationsDelegates: [
55+
Translate.delegate,
56+
GlobalMaterialLocalizations.delegate,
57+
GlobalWidgetsLocalizations.delegate,
58+
GlobalCupertinoLocalizations.delegate,
59+
],
60+
home: BlocBuilder<ApplicationBloc, ApplicationState>(
61+
builder: (context, applicationState) {
62+
if (applicationState is ApplicationCompleted) {
63+
if (authState is Unauthenticated) {
64+
return LoginScreen();
65+
}
66+
if (authState is Authenticated) {
67+
loadData();
68+
return BottomNavigation();
69+
}
70+
}
71+
return SplashScreen();
72+
},
73+
),
8074
);
8175
},
8276
);

lib/bottom_navigation.dart

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import 'package:e_commerce_app/constants/constants.dart';
2+
import 'package:e_commerce_app/presentation/screens/home_page/home_screen.dart';
3+
import 'package:e_commerce_app/presentation/screens/profile/profile_screen.dart';
4+
import 'package:e_commerce_app/utils/utils.dart';
5+
import 'package:flutter/material.dart';
6+
7+
class BottomNavigation extends StatefulWidget {
8+
BottomNavigation({Key? key}) : super(key: key);
9+
10+
@override
11+
_BottomNavigationState createState() {
12+
return _BottomNavigationState();
13+
}
14+
}
15+
16+
class _BottomNavigationState extends State<BottomNavigation>
17+
with WidgetsBindingObserver {
18+
int selectedIndex = 0;
19+
20+
@override
21+
void initState() {
22+
super.initState();
23+
WidgetsBinding.instance!.addObserver(this);
24+
}
25+
26+
@override
27+
void dispose() {
28+
super.dispose();
29+
WidgetsBinding.instance!.removeObserver(this);
30+
}
31+
32+
///On change tab bottom menu
33+
void onItemTapped(index) {
34+
setState(() {
35+
selectedIndex = index;
36+
});
37+
}
38+
39+
@override
40+
Widget build(BuildContext context) {
41+
return Scaffold(
42+
body: IndexedStack(
43+
children: [
44+
HomeScreen(),
45+
ProfileScreen(),
46+
],
47+
index: selectedIndex,
48+
),
49+
bottomNavigationBar: BottomNavigationBar(
50+
items: [
51+
BottomNavigationBarItem(
52+
icon: Icon(Icons.home),
53+
label: Translate.of(context).translate('home'),
54+
),
55+
BottomNavigationBarItem(
56+
icon: Icon(Icons.account_circle_outlined),
57+
label: Translate.of(context).translate('profile'),
58+
),
59+
],
60+
selectedLabelStyle: FONT_CONST.BOLD_DEFAULT,
61+
selectedItemColor: COLOR_CONST.primaryColor,
62+
unselectedFontSize: 12,
63+
currentIndex: selectedIndex,
64+
onTap: onItemTapped,
65+
),
66+
);
67+
}
68+
}

0 commit comments

Comments
 (0)