Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
16
lib/screens/registrasi/components/get_user_data.dart
Normal file
16
lib/screens/registrasi/components/get_user_data.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:initial_folder/helper/user_info.dart';
|
||||
import 'package:initial_folder/providers/carts_provider.dart';
|
||||
import 'package:initial_folder/providers/my_course_provider.dart';
|
||||
import 'package:initial_folder/providers/user_info_provider.dart';
|
||||
import 'package:initial_folder/providers/whislist_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
getUserData(BuildContext context) async {
|
||||
var email = await UsersInfo().getEmail();
|
||||
await Provider.of<UserInfoProvider>(context, listen: false)
|
||||
.getUserInfo(email);
|
||||
await Provider.of<CartsProvider>(context, listen: false).getCarts();
|
||||
await Provider.of<WishlistProvider>(context, listen: false).getWishlist();
|
||||
await Provider.of<MyCourseProvider>(context, listen: false).getMyCourse();
|
||||
}
|
159
lib/screens/registrasi/registrasi_screen.dart
Normal file
159
lib/screens/registrasi/registrasi_screen.dart
Normal file
@ -0,0 +1,159 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:initial_folder/providers/registrasi_google_provider.dart';
|
||||
import 'package:initial_folder/screens/login/login_with_email/login_email_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_with_facebook/registrasi_facebook_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_with_google/registrasi_google_screen.dart';
|
||||
import 'package:initial_folder/screens/home/home_screen.dart';
|
||||
import 'package:initial_folder/screens/login/login_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_with_email/registrasi_email_screen.dart';
|
||||
import 'package:initial_folder/size_config.dart';
|
||||
import 'package:initial_folder/theme.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/default_button.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/default_icon_button.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/footer.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/header.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/loading_button.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class RegistrationScreen extends StatefulWidget {
|
||||
const RegistrationScreen({Key? key}) : super(key: key);
|
||||
static String routeName = "/registration";
|
||||
|
||||
@override
|
||||
State<RegistrationScreen> createState() => _RegistrationScreenState();
|
||||
}
|
||||
|
||||
class _RegistrationScreenState extends State<RegistrationScreen> {
|
||||
bool isLoadingGoogle = false;
|
||||
bool isLoadingFacebook = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Column(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: getProportionateScreenWidth(12),
|
||||
top: getProportionateScreenHeight(8)),
|
||||
alignment: Alignment.topLeft,
|
||||
child: TextButton(
|
||||
child: Text('Daftar nanti',
|
||||
style: primaryTextStyle.copyWith(
|
||||
color: primaryColor,
|
||||
fontWeight: reguler,
|
||||
fontSize: getProportionateScreenWidth(14))),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeScreen.routeName, (Route<dynamic> route) => false);
|
||||
})),
|
||||
SizedBox(height: getProportionateScreenHeight(35)),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Header(
|
||||
jarak: 16,
|
||||
text:
|
||||
'Yuk Siapkan Dirimu, Mulai Upgrade Skill Bersama Vocasia',
|
||||
style: secondaryTextStyle.copyWith(
|
||||
color: tenthColor,
|
||||
fontWeight: semiBold,
|
||||
fontSize: getProportionateScreenWidth(14),
|
||||
),
|
||||
),
|
||||
SizedBox(height: getProportionateScreenHeight(32)),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: getProportionateScreenWidth(15.0)),
|
||||
child: isLoadingGoogle
|
||||
? LoadingButton(
|
||||
backgroundButtonColor: tenthColor,
|
||||
textButtonColor: ninthColor)
|
||||
: DefaultIconButton(
|
||||
text: "Lanjutkan dengan Google",
|
||||
press: () async {
|
||||
setState(() {
|
||||
isLoadingGoogle = true;
|
||||
});
|
||||
await RegistrationGoogle()
|
||||
.handleRegistrationGoogle(context);
|
||||
final userData =
|
||||
Provider.of<RegistrasiGoogleProvider>(context,
|
||||
listen: false);
|
||||
print(userData.name);
|
||||
print(userData.email);
|
||||
},
|
||||
icon: 'assets/icons/google.png',
|
||||
iconWidth: 25,
|
||||
iconHeight: 25,
|
||||
),
|
||||
),
|
||||
// SizedBox(height: getProportionateScreenWidth(16)),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: getProportionateScreenWidth(15.0)),
|
||||
// child: isLoadingFacebook
|
||||
// ? LoadingButton(
|
||||
// backgroundButtonColor: tenthColor,
|
||||
// textButtonColor: ninthColor)
|
||||
// : DefaultIconButton(
|
||||
// text: "Lanjutkan dengan Facebook",
|
||||
// press: () {
|
||||
// setState(() {
|
||||
// isLoadingFacebook = true;
|
||||
// });
|
||||
// RegistrationFacebook()
|
||||
// .handleRegistrationFacebook(context);
|
||||
// },
|
||||
// icon: 'assets/icons/facebook.png',
|
||||
// iconWidth: 25,
|
||||
// iconHeight: 25,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(height: getProportionateScreenWidth(16)),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: getProportionateScreenWidth(15.0)),
|
||||
child: DefaultButton(
|
||||
text: "Daftar dengan Email",
|
||||
press: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
RegistrationEmail.routeName,
|
||||
arguments: {
|
||||
'email': '',
|
||||
'nama': '',
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(height: getProportionateScreenHeight(32)),
|
||||
Footer(
|
||||
textOne: 'Sudah punya akun? ',
|
||||
textTwo: 'Masuk',
|
||||
route: LoginEmail.routeName,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 50),
|
||||
// child: Text(
|
||||
// 'Dengan membuat akun, anda menyetujui Kebijakan dan Persyaratan Privasi',
|
||||
// maxLines: 2,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// height: 2,
|
||||
// fontSize: getProportionateScreenWidth(14),
|
||||
// fontWeight: FontWeight.w400,
|
||||
// color: Colors.white)),
|
||||
// ),
|
||||
]),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,326 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:initial_folder/providers/registrasi_google_provider.dart';
|
||||
import 'package:initial_folder/screens/login/login_with_email/login_email_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_with_email/success_regis_screen.dart';
|
||||
import 'package:initial_folder/screens/splash/splash_screen_login.dart';
|
||||
import 'package:initial_folder/helper/validator.dart';
|
||||
import 'package:initial_folder/providers/auth_provider.dart';
|
||||
import 'package:initial_folder/screens/login/login_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_screen.dart';
|
||||
import 'package:initial_folder/size_config.dart';
|
||||
import 'package:initial_folder/theme.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/custom_text_form_field.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/default_button.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/footer.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/header.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/loading_button.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:initial_folder/helper/user_info.dart';
|
||||
import 'package:initial_folder/size_config.dart';
|
||||
|
||||
import '../../../widgets/login_regist/failed_login.dart';
|
||||
import '../../login/components/get_user_data.dart';
|
||||
|
||||
class RegistrationEmail extends StatefulWidget {
|
||||
static String routeName = "/registration_email";
|
||||
RegistrationEmail({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_RegistrationEmailState createState() => _RegistrationEmailState();
|
||||
}
|
||||
|
||||
class _RegistrationEmailState extends State<RegistrationEmail> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController nameController = TextEditingController(text: '');
|
||||
|
||||
final TextEditingController emailController = TextEditingController(text: '');
|
||||
final TextEditingController reEmailController =
|
||||
TextEditingController(text: '');
|
||||
|
||||
final TextEditingController phoneNumberController =
|
||||
TextEditingController(text: '');
|
||||
|
||||
final TextEditingController passwordController =
|
||||
TextEditingController(text: '');
|
||||
final TextEditingController rePasswordController =
|
||||
TextEditingController(text: '');
|
||||
bool isLoading = false;
|
||||
bool failed = false;
|
||||
bool _isObscure = true;
|
||||
bool _isObscure1 = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SizeConfig().init(context);
|
||||
AuthProvider authProvider = Provider.of<AuthProvider>(context);
|
||||
|
||||
final userProvider = Provider.of<RegistrasiGoogleProvider>(context);
|
||||
final Map<String, dynamic>? args =
|
||||
ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>?;
|
||||
nameController.text = nameController.text.isNotEmpty
|
||||
? nameController.text
|
||||
: (args?['nama'] ?? userProvider.name ?? '');
|
||||
emailController.text = emailController.text.isNotEmpty
|
||||
? emailController.text
|
||||
: (args?['email'] ?? userProvider.email ?? '');
|
||||
|
||||
handleSignUp() async {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
if (phoneNumberController.text.length > 16) {
|
||||
throw ('Failed\n\nNomor HP maksimal hanya 15 angka');
|
||||
}
|
||||
if (await authProvider.register(
|
||||
name: nameController.text,
|
||||
email: emailController.text,
|
||||
password: passwordController.text,
|
||||
phoneNumber: phoneNumberController.text,
|
||||
)) {
|
||||
await UsersInfo().setEmail(emailController.text);
|
||||
await authProvider
|
||||
.login(
|
||||
email: emailController.text,
|
||||
password: passwordController.text,
|
||||
)
|
||||
.then((value) async {
|
||||
Condition.loginEmail = true;
|
||||
await getUserData(context);
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
RegisSuccess.routeName, (Route<dynamic> route) => false);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Container(
|
||||
height: 90,
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: getProportionateScreenHeight(15),
|
||||
right: getProportionateScreenHeight(10)),
|
||||
child: Text(
|
||||
e.toString(),
|
||||
style: primaryTextStyle.copyWith(
|
||||
fontSize: getProportionateScreenWidth(11),
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: getProportionateScreenHeight(15),
|
||||
bottom: getProportionateScreenHeight(2)),
|
||||
child: Text(
|
||||
'Ok',
|
||||
style: primaryTextStyle.copyWith(
|
||||
fontSize: getProportionateScreenWidth(12),
|
||||
letterSpacing: 1,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _validateInputs() {
|
||||
if (this._formKey.currentState!.validate()) {
|
||||
handleSignUp();
|
||||
}
|
||||
}
|
||||
|
||||
Widget form() {
|
||||
Widget nameInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: nameController,
|
||||
hinttext: 'Masukan nama lengkap',
|
||||
title: 'Nama Lengkap',
|
||||
validate: validateName,
|
||||
);
|
||||
}
|
||||
|
||||
Widget emailInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: emailController,
|
||||
hinttext: 'Masukan email',
|
||||
title: 'Email',
|
||||
validate: validateEmail,
|
||||
);
|
||||
}
|
||||
|
||||
Widget reEmailInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: reEmailController,
|
||||
hinttext: 'Masukan konfirmasi email',
|
||||
title: 'Konfirmasi Email',
|
||||
validate: (String? value) {
|
||||
return validateReEmail(value, emailController.text);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget phoneNumberInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: phoneNumberController,
|
||||
hinttext: 'Masukan no hp',
|
||||
title: 'No Telepon',
|
||||
validate: validatePhone,
|
||||
);
|
||||
}
|
||||
|
||||
Widget passwordInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: passwordController,
|
||||
hinttext: 'Masukan password',
|
||||
title: 'Password',
|
||||
obscuretext: _isObscure,
|
||||
validate: validatePassword,
|
||||
suffix: GestureDetector(
|
||||
onTap: () => setState(() {
|
||||
_isObscure = !_isObscure;
|
||||
}),
|
||||
child: _isObscure
|
||||
? Icon(
|
||||
FeatherIcons.eyeOff,
|
||||
color: secondaryColor,
|
||||
size: 18,
|
||||
)
|
||||
: Icon(
|
||||
FeatherIcons.eye,
|
||||
color: secondaryColor,
|
||||
size: 18,
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget rePasswordInput() {
|
||||
return CustomTextField(
|
||||
pad: getProportionateScreenWidth(16),
|
||||
controler: rePasswordController,
|
||||
hinttext: 'Masukan password',
|
||||
title: 'Konfirmasi Password',
|
||||
obscuretext: _isObscure1,
|
||||
suffix: GestureDetector(
|
||||
onTap: () => setState(() {
|
||||
_isObscure1 = !_isObscure1;
|
||||
}),
|
||||
child: _isObscure1
|
||||
? Icon(
|
||||
FeatherIcons.eyeOff,
|
||||
color: secondaryColor,
|
||||
size: 18,
|
||||
)
|
||||
: Icon(
|
||||
FeatherIcons.eye,
|
||||
color: secondaryColor,
|
||||
size: 18,
|
||||
)),
|
||||
validate: (String? value) {
|
||||
return validateRePassword(value, passwordController.text);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget button() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: getProportionateScreenWidth(15),
|
||||
right: getProportionateScreenWidth(15),
|
||||
top: getProportionateScreenHeight(3)),
|
||||
child: isLoading
|
||||
? LoadingButton(
|
||||
backgroundButtonColor: primaryColor,
|
||||
textButtonColor: baruTextutih,
|
||||
)
|
||||
: DefaultButton(
|
||||
text: 'Register',
|
||||
press: _validateInputs,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
nameInput(),
|
||||
emailInput(),
|
||||
reEmailInput(),
|
||||
phoneNumberInput(),
|
||||
passwordInput(),
|
||||
rePasswordInput(),
|
||||
SizedBox(
|
||||
height: getProportionateScreenHeight(8),
|
||||
),
|
||||
button(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: getProportionateScreenHeight(25),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
right: getProportionateScreenWidth(25),
|
||||
left: getProportionateScreenWidth(25)),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text('Register',
|
||||
style: thirdTextStyle.copyWith(
|
||||
// color: baruTexthitam,
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: getProportionateScreenWidth(20),
|
||||
letterSpacing: 0.5))),
|
||||
),
|
||||
SizedBox(
|
||||
height: getProportionateScreenHeight(32),
|
||||
),
|
||||
form(),
|
||||
SizedBox(height: getProportionateScreenHeight(32)),
|
||||
Footer(
|
||||
textOne: 'Sudah punya akun? ',
|
||||
textTwo: 'Log in',
|
||||
route: LoginEmail.routeName,
|
||||
height: 14,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:initial_folder/screens/home/home_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/components/get_user_data.dart';
|
||||
import 'package:initial_folder/size_config.dart';
|
||||
import 'package:initial_folder/theme.dart';
|
||||
import 'package:initial_folder/widgets/login_regist/header.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
class RegisSuccess extends StatelessWidget {
|
||||
static String routeName = "/regis_success";
|
||||
RegisSuccess({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SizeConfig().init(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Icon(
|
||||
Icons.check_rounded,
|
||||
color: Colors.greenAccent[700],
|
||||
size: getProportionateScreenWidth(60),
|
||||
),
|
||||
SizedBox(height: getProportionateScreenHeight(24)),
|
||||
Header(
|
||||
title: false,
|
||||
text2: "Registrasi Akun Sukses",
|
||||
text:
|
||||
'Kami telah mengirimkan notifikasi registrasi akun ke email anda',
|
||||
style: primaryTextStyle.copyWith(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
fontWeight: reguler,
|
||||
fontSize: getProportionateScreenWidth(14),
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
SizedBox(height: getProportionateScreenHeight(44)),
|
||||
Container(
|
||||
// padding: EdgeInsets.only(
|
||||
// left: getProportionateScreenWidth(5),
|
||||
// top: getProportionateScreenWidth(5)),
|
||||
alignment: Alignment.center,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: 'Lanjut ke Halaman Beranda',
|
||||
style: primaryTextStyle.copyWith(
|
||||
color: primaryColor,
|
||||
fontWeight: reguler,
|
||||
fontSize: getProportionateScreenWidth(18),
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
await getUserData(context);
|
||||
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeScreen.routeName,
|
||||
(Route<dynamic> route) => false);
|
||||
print('masuk');
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:initial_folder/providers/firebase_authentication_provider.dart';
|
||||
// import 'package:initial_folder/providers/incomplete_profile_provider.dart';
|
||||
// import 'package:initial_folder/providers/login_provider.dart';
|
||||
// import 'package:initial_folder/screens/home/home_screen.dart';
|
||||
// import 'package:initial_folder/screens/login/components/get_user_data.dart';
|
||||
// import 'package:initial_folder/screens/login/login_with_email/login_email_screen.dart';
|
||||
// import 'package:initial_folder/screens/profile/account_sign_in/incomplete_profile_screen.dart';
|
||||
// import 'package:initial_folder/screens/splash/splash_screen_login.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
|
||||
// import '../../../size_config.dart';
|
||||
// import '../../../theme.dart';
|
||||
|
||||
// class RegistrationFacebook {
|
||||
// Future handleRegistrationFacebook(BuildContext context) async {
|
||||
// final provider =
|
||||
// Provider.of<FirebaseAuthenticationProvider>(context, listen: false);
|
||||
// if (await provider.facebookLogin()) {
|
||||
// await getUserData(context);
|
||||
|
||||
// Condition.loginFirebase = true;
|
||||
|
||||
// IncompleteProfileProvider userInfoIncomplete =
|
||||
// Provider.of<IncompleteProfileProvider>(context, listen: false);
|
||||
// await userInfoIncomplete.getUserInfoIncomplete();
|
||||
// if (userInfoIncomplete.isUserInfoComplete == null) {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// LoginEmail.routeName, (Route<dynamic> route) => false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (userInfoIncomplete.isUserInfoComplete!) {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// HomeScreen.routeName, (Route<dynamic> route) => false);
|
||||
// } else {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// IncompleteProfile.routeName, (Route<dynamic> route) => false);
|
||||
// }
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => AlertDialog(
|
||||
// insetPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
|
||||
// content: Container(
|
||||
// alignment: AlignmentDirectional.bottomCenter,
|
||||
// height: 50,
|
||||
// child: Text(
|
||||
// 'Ada kendala dalam login, coba lagi atau periksa akun anda',
|
||||
// style: primaryTextStyle.copyWith(
|
||||
// fontSize: getProportionateScreenWidth(12), letterSpacing: 1),
|
||||
// ),
|
||||
// ),
|
||||
// actions: [
|
||||
// Container(
|
||||
// height: 30,
|
||||
// alignment: AlignmentDirectional.topEnd,
|
||||
// child: GestureDetector(
|
||||
// onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: Text('Tutup',
|
||||
// style: primaryTextStyle.copyWith(
|
||||
// fontSize: getProportionateScreenWidth(12),
|
||||
// letterSpacing: 1,
|
||||
// color: primaryColor)),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// Provider.of<LoginProvider>(context, listen: false)
|
||||
// .loadFacebookActive(false);
|
||||
// }
|
||||
// }
|
@ -0,0 +1,145 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:initial_folder/providers/firebase_authentication_provider.dart';
|
||||
import 'package:initial_folder/providers/incomplete_profile_provider.dart';
|
||||
import 'package:initial_folder/providers/registrasi_google_provider.dart';
|
||||
import 'package:initial_folder/screens/home/home_screen.dart';
|
||||
import 'package:initial_folder/screens/login/components/get_user_data.dart';
|
||||
import 'package:initial_folder/screens/login/login_with_email/login_email_screen.dart';
|
||||
import 'package:initial_folder/screens/profile/account_sign_in/incomplete_profile_screen.dart';
|
||||
import 'package:initial_folder/screens/registrasi/registrasi_with_email/registrasi_email_screen.dart';
|
||||
import 'package:initial_folder/screens/splash/splash_screen_login.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../size_config.dart';
|
||||
import '../../../theme.dart';
|
||||
|
||||
class RegistrationGoogle {
|
||||
Future handleRegistrationGoogle(BuildContext context) async {
|
||||
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
||||
final googleAuth = await googleUser?.authentication;
|
||||
final name = googleUser?.displayName;
|
||||
final email = googleUser?.email;
|
||||
final provider =
|
||||
Provider.of<FirebaseAuthenticationProvider>(context, listen: false);
|
||||
if (await provider.googleLogin()) {
|
||||
await getUserData(context);
|
||||
|
||||
Condition.loginFirebase = true;
|
||||
|
||||
IncompleteProfileProvider userInfoIncomplete =
|
||||
Provider.of<IncompleteProfileProvider>(context, listen: false);
|
||||
|
||||
// [!CHECKPOINT!]:
|
||||
await userInfoIncomplete.getUserInfoIncomplete();
|
||||
if (userInfoIncomplete.isUserInfoComplete == null) {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
LoginEmail.routeName, (Route<dynamic> route) => false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (userInfoIncomplete.isUserInfoComplete!) {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
HomeScreen.routeName, (Route<dynamic> route) => false);
|
||||
} else {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
IncompleteProfile.routeName, (Route<dynamic> route) => false);
|
||||
}
|
||||
} else if (googleAuth != null && name != null && email != null) {
|
||||
// data ditemukan, gunakan di sini
|
||||
Provider.of<RegistrasiGoogleProvider>(context, listen: false)
|
||||
.setNameAndEmail(name, email);
|
||||
|
||||
Navigator.pushReplacementNamed(context, RegistrationEmail.routeName);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
insetPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
|
||||
content: Container(
|
||||
alignment: AlignmentDirectional.bottomCenter,
|
||||
height: 50,
|
||||
child: Text(
|
||||
'Ada kendala dalam mendaftar, coba lagi atau periksa akun anda',
|
||||
style: primaryTextStyle.copyWith(
|
||||
fontSize: getProportionateScreenWidth(12), letterSpacing: 1),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Container(
|
||||
height: 30,
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('Tutup',
|
||||
style: primaryTextStyle.copyWith(
|
||||
fontSize: getProportionateScreenWidth(12),
|
||||
letterSpacing: 1,
|
||||
color: primaryColor)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Future handleRegistrationGoogle(BuildContext context) async {
|
||||
// final provider =
|
||||
// Provider.of<FirebaseAuthenticationProvider>(context, listen: false);
|
||||
// if (await provider.googleLogin()) {
|
||||
// await getUserData(context);
|
||||
|
||||
// Condition.loginFirebase = true;
|
||||
|
||||
// IncompleteProfileProvider userInfoIncomplete = Provider.of<IncompleteProfileProvider>(context, listen: false);
|
||||
// await userInfoIncomplete.getUserInfoIncomplete();
|
||||
// if (userInfoIncomplete.isUserInfoComplete) {
|
||||
// Navigator.of(context)
|
||||
// .pushNamedAndRemoveUntil(
|
||||
// HomeScreen.routeName,
|
||||
// (Route<dynamic> route) => false);
|
||||
// } else {
|
||||
// Navigator.of(context)
|
||||
// .pushNamedAndRemoveUntil(
|
||||
// IncompleteProfile.routeName,
|
||||
// (Route<dynamic> route) => false);
|
||||
// }
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => AlertDialog(
|
||||
// insetPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
|
||||
// content: Container(
|
||||
// alignment: AlignmentDirectional.bottomCenter,
|
||||
// height: 50,
|
||||
// child: Text(
|
||||
// 'Ada kendala dalam mendaftar, coba lagi atau periksa akun anda',
|
||||
// style: primaryTextStyle.copyWith(
|
||||
// fontSize: getProportionateScreenWidth(12), letterSpacing: 1),
|
||||
// ),
|
||||
// ),
|
||||
// actions: [
|
||||
// Container(
|
||||
// height: 30,
|
||||
// alignment: AlignmentDirectional.topEnd,
|
||||
// child: GestureDetector(
|
||||
// onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: Text('Tutup',
|
||||
// style: primaryTextStyle.copyWith(
|
||||
// fontSize: getProportionateScreenWidth(12),
|
||||
// letterSpacing: 1,
|
||||
// color: primaryColor)),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user