Skip to content

Commit

Permalink
task: launch refactoring and google auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuoha committed Sep 20, 2022
1 parent 520b612 commit 340398a
Show file tree
Hide file tree
Showing 53 changed files with 120 additions and 16 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<item>
<bitmap
android:gravity="center"
android:src="@drawable/logo_transparent" />
android:src="@drawable/logo1" />
</item>
</layer-list>
Binary file added android/app/src/main/res/drawable-v21/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<item>
<bitmap
android:gravity="center"
android:src="@drawable/logo_transparent" />
android:src="@drawable/logo1" />
</item>
</layer-list>
Binary file added android/app/src/main/res/drawable/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified android/app/src/main/res/mipmap-hdpi/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#C32E34</color>
<color name="ic_launcher_background">#8DC73F</color>
</resources>
Binary file removed assets/images/logo.jpg
Binary file not shown.
Binary file added assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/logo_transparent.png
Binary file not shown.
Binary file added assets/images/sp1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sp2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sp3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sp4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sp5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added google_auth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
9 changes: 6 additions & 3 deletions lib/constants/colors.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';

// A1A240 - Previous color used
const primaryColor = Color(0XFF8DC73F);
var litePrimary = const Color(0XFF8DC73F).withOpacity(0.5);

const primaryColor = Color(0XFFC32E34);
var litePrimary = const Color(0XFFC32E34).withOpacity(0.5);
// import 'package:flutter/material.dart';
//
// const primaryColor = Color(0XFFC32E34);
// var litePrimary = const Color(0XFFC32E34).withOpacity(0.5);
83 changes: 78 additions & 5 deletions lib/views/auth/customer_auth.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:image_picker/image_picker.dart';
import 'package:multivendor_shop/views/auth/forgot_password.dart';
import '../../constants/colors.dart';
Expand Down Expand Up @@ -33,6 +37,7 @@ class _CustomerAuthState extends State<CustomerAuth> {
var isLogin = true;
XFile? profileImage;
final ImagePicker _picker = ImagePicker(); // init imagePicker
var isLoading = false;

// toggle password obscure
_togglePasswordObscure() {
Expand Down Expand Up @@ -168,6 +173,26 @@ class _CustomerAuthState extends State<CustomerAuth> {
);
}

// snackbar for error message
void showSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
message,
style: const TextStyle(
color: Colors.white,
),
),
backgroundColor: primaryColor,
action: SnackBarAction(
onPressed: () => Navigator.of(context).pop(),
label: 'Dismiss',
textColor: Colors.white,
),
),
);
}

// handle sign in and sign up
_handleAuth() {
var valid = _formKey.currentState!.validate();
Expand All @@ -182,9 +207,57 @@ class _CustomerAuthState extends State<CustomerAuth> {
}
}

_googleAuth() {
// // TODO: Implement Google Auth
//
// authenticate using Google
Future<UserCredential> _googleAuth() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;

// Create a new credential
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);

try {
// send username, email, and phone number to firestore
var logCredential =
await FirebaseAuth.instance.signInWithCredential(credential);
await FirebaseFirestore.instance
.collection('users')
.doc(logCredential.user!.uid)
.set(
{
'username': googleUser!.displayName,
'email': googleUser.email,
'image': googleUser.photoUrl,
'auth-type': 'google',
},
).then((value) {
// isLoadingFnc();
// update authtype
// Provider.of<SongData>(context).updateAuthType();
});
} on FirebaseAuthException catch (e) {
var error = 'An error occurred. Check credentials!';
if (e.message != null) {
error = e.message!;
}

showSnackBar(error); // showSnackBar will show error if any
setState(() {
isLoading = false;
});
} catch (e) {
if (kDebugMode) {
print(e);
}
}
// sign in with credential¶
return FirebaseAuth.instance.signInWithCredential(credential);
}

// navigate to forgot password screen
Expand Down Expand Up @@ -365,7 +438,7 @@ class _CustomerAuthState extends State<CustomerAuth> {
'Forgot Password',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
),
),
),
Expand All @@ -377,7 +450,7 @@ class _CustomerAuthState extends State<CustomerAuth> {
: 'Already a user? Sign in',
style: const TextStyle(
color: primaryColor,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
),
),
)
Expand Down
2 changes: 1 addition & 1 deletion lib/views/auth/forgot_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
'Remembered password? Sign in',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
),
),
)
Expand Down
28 changes: 28 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
firebase_auth:
dependency: "direct main"
description:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "3.9.0"
firebase_auth_platform_interface:
dependency: transitive
description:
name: firebase_auth_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "6.8.0"
firebase_auth_web:
dependency: transitive
description:
name: firebase_auth_web
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.1"
firebase_core:
dependency: "direct main"
description:
Expand Down Expand Up @@ -268,6 +289,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
js:
dependency: transitive
description:
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies:
firebase_core: ^1.22.0
google_sign_in: ^5.4.1
flutter_launcher_icons: ^0.10.0
firebase_auth: ^3.9.0

dev_dependencies:
flutter_test:
Expand All @@ -54,10 +55,9 @@ dev_dependencies:
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/images/logo_transparent.png"
background_color: '#C32E34'
adaptive_icon_background: '#C32E34'
adaptive_icon_foreground: 'assets/images/logo_transparent.png'
image_path: "assets/images/logo.png"
adaptive_icon_background: '#8DC73F'
adaptive_icon_foreground: 'assets/images/logo.png'

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down

0 comments on commit 340398a

Please sign in to comment.