-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f92f2aa
commit fbd6450
Showing
7 changed files
with
174 additions
and
158 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
lib/src/features/authentication/controller/login_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:courses_app/src/repository/auth_repository.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
class LoginController extends GetxController { | ||
static LoginController get instance => Get.find(); | ||
|
||
final email = TextEditingController(); | ||
final password = TextEditingController(); | ||
|
||
void loginExistingUser(String email, String password) { | ||
AuthRepository.instance.loginUserWithEmailAndPassword(email, password); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 0 additions & 150 deletions
150
lib/src/features/authentication/screen/login/widgets/LoginForm.dart
This file was deleted.
Oops, something went wrong.
144 changes: 144 additions & 0 deletions
144
lib/src/features/authentication/screen/login/widgets/login_form.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import 'package:courses_app/src/constants/images.dart'; | ||
import 'package:courses_app/src/constants/text.dart'; | ||
import 'package:courses_app/src/features/authentication/controller/login_controller.dart'; | ||
import 'package:courses_app/src/features/authentication/screen/signup/signup_screen.dart'; | ||
import 'package:courses_app/src/features/dashboard/screen/dashboard/dashboard_screen.dart'; | ||
import 'package:courses_app/src/widgets/common/outlined_password_text_field.dart'; | ||
import 'package:courses_app/src/widgets/common/outlined_text_field.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import 'forgot_password_bottom_sheet.dart'; | ||
|
||
class LoginForm extends StatelessWidget { | ||
const LoginForm({ | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final controller = Get.put(LoginController()); | ||
|
||
final formKey = GlobalKey<FormState>(); | ||
|
||
void handleLogin() { | ||
LoginController.instance.loginExistingUser( | ||
controller.email.text.trim(), | ||
controller.password.text.trim(), | ||
); | ||
} | ||
|
||
return Form( | ||
key: formKey, | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 30.0), | ||
child: Column( | ||
children: [ | ||
OutlinedTextField( | ||
label: const Text( | ||
'Email', | ||
), | ||
controller: controller.email, | ||
), | ||
const SizedBox( | ||
height: 16.0, | ||
), | ||
OutlinedPasswordTextField( | ||
label: const Text('Password'), | ||
controller: controller.password, | ||
) | ||
], | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 10.0), | ||
child: Column( | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
showModalBottomSheet( | ||
context: context, | ||
// enableDrag: true, | ||
isScrollControlled: true, | ||
useSafeArea: true, | ||
builder: (context) { | ||
return const ForgotPasswordBottomSheet(); | ||
}); | ||
}, | ||
child: const Text( | ||
'Forgot password?', | ||
), | ||
), | ||
SizedBox( | ||
width: double.infinity, | ||
child: FilledButton( | ||
style: FilledButton.styleFrom(), | ||
onPressed: handleLogin, | ||
child: const Text( | ||
'Login', | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
const Text('OR'), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 10.0), | ||
child: OutlinedButton( | ||
onPressed: () {}, | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Container( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(50.0), | ||
image: const DecorationImage( | ||
image: AssetImage(googleLogo), fit: BoxFit.contain), | ||
// shape: BoxShape.rectangle | ||
), | ||
width: 24, | ||
height: 24, | ||
), | ||
const SizedBox( | ||
width: 8.0, | ||
), | ||
const Text('Login with Google') | ||
], | ||
), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 16.0), | ||
child: TextButton( | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) { | ||
return const SignUpScreen(); | ||
}, | ||
), | ||
); | ||
}, | ||
child: Text.rich(TextSpan( | ||
text: "Don't have an account?", | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
children: [ | ||
TextSpan( | ||
text: ' Signup', | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyLarge | ||
?.apply(color: Theme.of(context).colorScheme.primary), | ||
) | ||
])), | ||
), | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
lib/src/features/authentication/screen/signup/widgets/signup_form.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters