Skip to content

Commit

Permalink
field widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
this-kin committed Aug 29, 2022
1 parent 3ea1ad1 commit f1cb696
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
78 changes: 39 additions & 39 deletions lib/data/controllers/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,45 +40,45 @@ class AuthController extends GetxController {
}
}

// login with google
void login(context) async {
final GoogleSignInAccount _googleSignAccount = await _googleSignIn.signIn();
final GoogleSignInAuthentication _googleAuth =
await _googleSignAccount.authentication;
final GoogleAuthCredential _authCredential = GoogleAuthProvider.credential(
accessToken: _googleAuth.accessToken,
idToken: _googleAuth.idToken,
);
try {
UserCredential _credential =
await _auth.signInWithCredential(_authCredential);
if (_credential.user != null) {
user.value = _credential.user;
// // login with google
// void login(context) async {
// final GoogleSignInAccount _googleSignAccount = await _googleSignIn.signIn();
// final GoogleSignInAuthentication _googleAuth =
// await _googleSignAccount.authentication;
// final GoogleAuthCredential _authCredential = GoogleAuthProvider.credential(
// accessToken: _googleAuth.accessToken,
// idToken: _googleAuth.idToken,
// );
// try {
// UserCredential _credential =
// await _auth.signInWithCredential(_authCredential);
// if (_credential.user != null) {
// user.value = _credential.user;

final UserData userData = UserData(
id: _credential.user.uid,
username: _credential.user.displayName,
email: _credential.user.email,
imageUrl: _credential.user.photoURL,
);
setUserStateToHive(userData);
successToast("Google Authentication Successful", context);
} else {
failureToast(ConstanceData.error, context);
}
} catch (e) {
failureToast(e.toString(), context);
}
}
// final UserData userData = UserData(
// id: _credential.user.uid,
// username: _credential.user.displayName,
// email: _credential.user.email,
// imageUrl: _credential.user.photoURL,
// );
// setUserStateToHive(userData);
// successToast("Google Authentication Successful", context);
// } else {
// failureToast(ConstanceData.error, context);
// }
// } catch (e) {
// failureToast(e.toString(), context);
// }
// }

// logout
void logout(context) async {
await _auth.signOut().then((value) async {
final box = await Hive.openBox(userDataString);
box.delete(userDataKey);
successToast("User logged out", context);
}, onError: (err) {
failureToast(err.toString(), context);
});
}
// // logout
// void logout(context) async {
// await _auth.signOut().then((value) async {
// final box = await Hive.openBox(userDataString);
// box.delete(userDataKey);
// successToast("User logged out", context);
// }, onError: (err) {
// failureToast(err.toString(), context);
// });
// }
}
3 changes: 2 additions & 1 deletion lib/modules/onboard/onboard.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:todey/data/models/welcome_model.dart';
import 'package:todey/core/exports.dart';
import 'package:todey/modules/home/home.dart';

class Onboard extends StatefulWidget {
const Onboard({Key key}) : super(key: key);
Expand Down Expand Up @@ -78,7 +79,7 @@ class _OnboardState extends State<Onboard> {
? _pageController.nextPage(
duration: const Duration(milliseconds: 600),
curve: Curves.bounceInOut)
: authController.login(context);
: Get.offAll(Home());
},
label: Text(
_selectedIndex < 2 ? "Next" : "Continue",
Expand Down

0 comments on commit f1cb696

Please sign in to comment.