Skip to content

Commit 914ce75

Browse files
committed
update
1 parent f3c133f commit 914ce75

File tree

29 files changed

+531
-292
lines changed

29 files changed

+531
-292
lines changed

android/app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply plugin: 'com.google.gms.google-services'
2727
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2828

2929
android {
30-
compileSdkVersion 29
30+
compileSdkVersion 30
3131

3232
sourceSets {
3333
main.java.srcDirs += 'src/main/kotlin'
@@ -67,7 +67,6 @@ dependencies {
6767
// Add the dependency for the Firebase SDK for Google Analytics
6868
// When using the BoM, don't specify versions in Firebase dependencies
6969
implementation 'com.google.firebase:firebase-analytics'
70-
7170
// Add the dependencies for any other desired Firebase products
7271
// https://firebase.google.com/docs/android/setup#available-libraries
7372
}

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
additional functionality it is fine to subclass or reimplement
77
FlutterApplication and put your custom class here. -->
88
<application
9-
android:name="io.flutter.app.FlutterApplication"
109
android:label="e_commerce_app"
1110
android:icon="@mipmap/ic_launcher">
1211
<activity
@@ -43,5 +42,7 @@
4342
<meta-data
4443
android:name="flutterEmbedding"
4544
android:value="2" />
45+
<meta-data android:name="com.google.android.geo.API_KEY"
46+
android:value="AIzaSyCujk4bJgwEECcDYwX9e0CRiYQFlWzhFU4"/>
4647
</application>
4748
</manifest>

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
dependencies {
99
classpath 'com.android.tools.build:gradle:3.5.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
classpath 'com.google.gms:google-services:4.3.4'
11+
classpath 'com.google.gms:google-services:4.3.5'
1212
}
1313
}
1414

lib/business_logic/blocs/profile/profile_bloc.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
3232
}
3333
}
3434

35+
/// Load Profile event => states
3536
Stream<ProfileState> _mapLoadProfileToState(LoadProfile event) async* {
3637
try {
3738
_profileStreamSub?.cancel();
@@ -43,6 +44,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
4344
}
4445
}
4546

47+
/// Upload Avatar event => states
4648
Stream<ProfileState> _mapUploadAvatarToState(UploadAvatar event) async* {
4749
try {
4850
// Get image url from firebase storage
@@ -57,7 +59,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
5759
} catch (e) {}
5860
}
5961

60-
///
62+
/// Address List Changed event => states
6163
Stream<ProfileState> _mapAddressListChangedToState(
6264
AddressListChanged event) async* {
6365
try {
@@ -72,6 +74,10 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
7274
// Check method
7375
switch (event.method) {
7476
case ListMethod.ADD:
77+
// If current addresses is empty, so the first delivery address is always default
78+
if (addresses.isEmpty) {
79+
deliveryAddress = deliveryAddress.cloneWith(isDefault: true);
80+
}
7581
addresses.add(deliveryAddress);
7682
break;
7783
case ListMethod.DELETE:
@@ -92,6 +98,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
9298
} catch (e) {}
9399
}
94100

101+
/// Profile Updated event => states
95102
Stream<ProfileState> _mapProfileUpdatedToState(ProfileUpdated event) async* {
96103
try {
97104
_loggedUser = event.updatedUser;

lib/business_logic/local/pref.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:shared_preferences/shared_preferences.dart';
2+
3+
abstract class Pref {
4+
Future<bool> saveString(String key, String value);
5+
6+
Future<String> getString(String key);
7+
8+
Future<bool> removeString(String key);
9+
}
10+
11+
class LocalPref extends Pref {
12+
@override
13+
Future<bool> saveString(String key, String value) async {
14+
final prefs = await SharedPreferences.getInstance();
15+
return prefs.setString(key, value);
16+
}
17+
18+
@override
19+
Future<String> getString(String key) async {
20+
final prefs = await SharedPreferences.getInstance();
21+
return prefs.getString(key)!;
22+
}
23+
24+
@override
25+
Future<bool> removeString(String key) async {
26+
final prefs = await SharedPreferences.getInstance();
27+
return prefs.remove(key);
28+
}
29+
}

lib/business_logic/repository/auth_repository/auth_repo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class AuthRepository {
1515

1616
/// Starts the Sign In with Google Flow.
1717
/// Created by NDH
18-
Future<void> logInWithGoogle();
18+
// Future<void> logInWithGoogle();
1919

2020
bool isLoggedIn();
2121

lib/business_logic/repository/auth_repository/firebase_auth_repo.dart

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import 'package:e_commerce_app/business_logic/repository/auth_repository/auth_re
33
import 'package:e_commerce_app/business_logic/repository/repository.dart';
44
import 'package:e_commerce_app/business_logic/repository/user_repository/user_repo.dart';
55
import 'package:firebase_auth/firebase_auth.dart';
6-
import 'package:google_sign_in/google_sign_in.dart';
6+
// import 'package:google_sign_in/google_sign_in.dart';
77

88
class FirebaseAuthRepository implements AuthRepository {
99
FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
10-
GoogleSignIn _googleSignIn = GoogleSignIn();
10+
// GoogleSignIn _googleSignIn = GoogleSignIn();
1111
UserRepository _userRepository = FirebaseUserRepository();
1212
String _authException = "Authentication Failure";
1313
User get loggedFirebaseUser => _firebaseAuth.currentUser!;
@@ -48,30 +48,27 @@ class FirebaseAuthRepository implements AuthRepository {
4848

4949
/// Starts the Sign In with Google Flow.
5050
/// Created by NDH
51-
Future<void> logInWithGoogle() async {
52-
try {
53-
final googleUser =
54-
await (_googleSignIn.signIn() as Future<GoogleSignInAccount>);
55-
final googleAuth = await googleUser.authentication;
56-
final credential = GoogleAuthProvider.credential(
57-
accessToken: googleAuth.accessToken,
58-
idToken: googleAuth.idToken,
59-
);
60-
await _firebaseAuth.signInWithCredential(credential);
61-
} on FirebaseAuthException catch (e) {
62-
_authException = e.message.toString();
63-
}
64-
}
51+
// Future<void> logInWithGoogle() async {
52+
// try {
53+
// final googleUser =
54+
// await (_googleSignIn.signIn() as Future<GoogleSignInAccount>);
55+
// final googleAuth = await googleUser.authentication;
56+
// final credential = GoogleAuthProvider.credential(
57+
// accessToken: googleAuth.accessToken,
58+
// idToken: googleAuth.idToken,
59+
// );
60+
// await _firebaseAuth.signInWithCredential(credential);
61+
// } on FirebaseAuthException catch (e) {
62+
// _authException = e.message.toString();
63+
// }
64+
// }
6565

6666
bool isLoggedIn() => _firebaseAuth.currentUser != null;
6767

6868
/// Signs out the current user
6969
/// Created by NDH
7070
Future<void> logOut() async {
71-
await Future.wait([
72-
_firebaseAuth.signOut(),
73-
_googleSignIn.signOut(),
74-
]).catchError((error) {
71+
await _firebaseAuth.signOut().catchError((error) {
7572
print(error);
7673
});
7774
}

lib/configs/router.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:e_commerce_app/presentation/screens/map/map_screen.dart';
12
import 'package:flutter/material.dart';
23
import 'package:e_commerce_app/business_logic/entities/entites.dart';
34
import 'package:e_commerce_app/presentation/screens/delivery_address/delivery_address_screen.dart';
@@ -28,6 +29,7 @@ class AppRouter {
2829
static const String CART = '/cart';
2930
static const String PAYMENT = '/payment';
3031
static const String DELIVERY_ADDRESS = '/delivery_address';
32+
static const String MAP = '/map';
3133
static const String ALL_PRODUCTS = '/all_products';
3234

3335
static Route<dynamic> generateRoute(RouteSettings settings) {
@@ -68,6 +70,8 @@ class AppRouter {
6870
return MaterialPageRoute(builder: (_) => PaymentScreen());
6971
case DELIVERY_ADDRESS:
7072
return MaterialPageRoute(builder: (_) => DeliveryAddressScreen());
73+
case MAP:
74+
return MaterialPageRoute(builder: (_) => MapScreen());
7175
default:
7276
return MaterialPageRoute(
7377
builder: (_) => Scaffold(

lib/configs/themes/appbar_theme.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ AppBarTheme appBarTheme() {
66
elevation: 0,
77
brightness: Brightness.light,
88
iconTheme: IconThemeData(color: Colors.black),
9+
centerTitle: true,
910
textTheme: TextTheme(
1011
headline6: TextStyle(color: Color(0xFF636e72), fontSize: 20),
1112
),

lib/configs/themes/theme.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:e_commerce_app/configs/themes/text_theme.dart';
2+
import 'package:e_commerce_app/constants/color_constant.dart';
23
import 'package:flutter/material.dart';
34

45
import 'appbar_theme.dart';
@@ -9,6 +10,8 @@ ThemeData theme() {
910
fontFamily: "Poppins",
1011
appBarTheme: appBarTheme(),
1112
textTheme: textTheme(),
13+
floatingActionButtonTheme:
14+
FloatingActionButtonThemeData(backgroundColor: mPrimaryColor),
1215
visualDensity: VisualDensity.adaptivePlatformDensity,
1316
);
1417
}

0 commit comments

Comments
 (0)