Skip to content

Commit 10b3116

Browse files
authored
Merge pull request #66 from pythonhubdev/refactor/codebase
feat: update authentication logic and improve UI components
2 parents 6f81b3d + ffbc59d commit 10b3116

File tree

18 files changed

+826
-737
lines changed

18 files changed

+826
-737
lines changed

.taskmaster/tasks/task_001.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Task ID: 1
2+
# Title: Migrate to Riverpod 3.0
3+
# Status: done
4+
# Dependencies: None
5+
# Priority: high
6+
# Description: Update the application to use the latest stable version of Riverpod 3.0. This includes updating the `hooks_riverpod` dependency, refactoring providers and widgets, and ensuring the state management is robust.
7+
# Details:
8+
9+
10+
# Test Strategy:
11+

.taskmaster/tasks/task_002.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Task ID: 2
2+
# Title: Modernize the User Interface
3+
# Status: done
4+
# Dependencies: 1
5+
# Priority: high
6+
# Description: Redesign the login, registration, and home pages to be more modern and visually appealing. Adopt a clean design language like Material You, create a consistent theme, and add animations to enhance the user experience.
7+
# Details:
8+
9+
10+
# Test Strategy:
11+

.taskmaster/tasks/task_003.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Task ID: 3
2+
# Title: Refactor and Clean Up Codebase
3+
# Status: pending
4+
# Dependencies: 1
5+
# Priority: medium
6+
# Description: Improve the quality, readability, and maintainability of the codebase. This includes updating all dependencies to their latest stable versions, improving error handling, enhancing input validation, and ensuring the code is well-organized.
7+
# Details:
8+
9+
10+
# Test Strategy:
11+

.taskmaster/tasks/tasks.json

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,67 @@
2424
"title": "Refactor and Clean Up Codebase",
2525
"description": "Improve the quality, readability, and maintainability of the codebase. This includes updating all dependencies to their latest stable versions, improving error handling, enhancing input validation, and ensuring the code is well-organized.",
2626
"status": "pending",
27-
"priority": "medium",
2827
"dependencies": [
2928
1
29+
],
30+
"priority": "medium",
31+
"details": "",
32+
"testStrategy": "",
33+
"subtasks": [
34+
{
35+
"id": 1,
36+
"title": "Refactor Domain Layer",
37+
"description": "Fix typos, enhance email validation with industry-standard regex, strengthen password security (8+ chars)",
38+
"status": "done",
39+
"dependencies": [],
40+
"details": "",
41+
"testStrategy": ""
42+
},
43+
{
44+
"id": 2,
45+
"title": "Refactor Application Layer",
46+
"description": "Streamline AuthStateController, improve error handling, cleaner code structure",
47+
"status": "done",
48+
"dependencies": [],
49+
"details": "",
50+
"testStrategy": ""
51+
},
52+
{
53+
"id": 3,
54+
"title": "Refactor Services Layer",
55+
"description": "Enhance Firebase Auth Facade with centralized error mapping and better null safety",
56+
"status": "done",
57+
"dependencies": [],
58+
"details": "",
59+
"testStrategy": ""
60+
},
61+
{
62+
"id": 4,
63+
"title": "Refactor UI Components",
64+
"description": "Refactor Login/Registration pages with modular structure, extract helper methods, enhance validation",
65+
"status": "done",
66+
"dependencies": [],
67+
"details": "",
68+
"testStrategy": ""
69+
},
70+
{
71+
"id": 5,
72+
"title": "App Level Improvements",
73+
"description": "Simplify routing, add global page transitions, performance improvements",
74+
"status": "done",
75+
"dependencies": [],
76+
"details": "",
77+
"testStrategy": ""
78+
},
79+
{
80+
"id": 6,
81+
"title": "Update Dependencies",
82+
"description": "Update all dependencies to their latest stable versions",
83+
"status": "pending",
84+
"dependencies": [],
85+
"details": "",
86+
"testStrategy": ""
87+
}
3088
]
3189
},
3290
{

ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ PODS:
44
- FirebaseAuth (~> 11.15.0)
55
- Firebase/CoreOnly (11.15.0):
66
- FirebaseCore (~> 11.15.0)
7-
- firebase_auth (5.6.2):
7+
- firebase_auth (5.7.0):
88
- Firebase/Auth (= 11.15.0)
99
- firebase_core
1010
- Flutter
11-
- firebase_core (3.15.1):
11+
- firebase_core (3.15.2):
1212
- Firebase/CoreOnly (= 11.15.0)
1313
- Flutter
1414
- FirebaseAppCheckInterop (11.15.0)
@@ -83,8 +83,8 @@ EXTERNAL SOURCES:
8383

8484
SPEC CHECKSUMS:
8585
Firebase: d99ac19b909cd2c548339c2241ecd0d1599ab02e
86-
firebase_auth: b8ed959bf77eca5cf0312b5e29708fe8311a0ddf
87-
firebase_core: cf4d42a8ac915e51c0c2dc103442f3036d941a2d
86+
firebase_auth: 5342db41af2ba5ed32a6177d9e326eecbebda912
87+
firebase_core: 99a37263b3c27536063a7b601d9e2a49400a433c
8888
FirebaseAppCheckInterop: 06fe5a3799278ae4667e6c432edd86b1030fa3df
8989
FirebaseAuth: a6575e5fbf46b046c58dc211a28a5fbdd8d4c83b
9090
FirebaseAuthInterop: 7087d7a4ee4bc4de019b2d0c240974ed5d89e2fd

lib/app.dart

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class FirebaseAuthenticationDDD extends StatelessWidget {
1010

1111
@override
1212
Widget build(BuildContext context) {
13-
// Set system UI overlay style
1413
SystemChrome.setSystemUIOverlayStyle(
1514
const SystemUiOverlayStyle(
1615
statusBarColor: Colors.transparent,
@@ -26,49 +25,11 @@ class FirebaseAuthenticationDDD extends StatelessWidget {
2625
title: "Firebase Auth DDD",
2726
debugShowCheckedModeBanner: kDebugMode,
2827

29-
// Apply our modern Material You theme system
3028
theme: AppTheme.lightTheme,
3129
darkTheme: AppTheme.darkTheme,
3230
themeMode: ThemeMode.system,
3331

34-
// Improved route transitions
35-
onGenerateRoute: (settings) {
36-
switch (settings.name) {
37-
case "/":
38-
return _createRoute(LoginPage());
39-
default:
40-
return _createRoute(LoginPage());
41-
}
42-
},
43-
44-
home: LoginPage(),
45-
);
46-
}
47-
48-
// Custom page route with smooth transitions
49-
PageRoute _createRoute(Widget page) {
50-
return PageRouteBuilder(
51-
pageBuilder: (context, animation, secondaryAnimation) => page,
52-
transitionsBuilder: (context, animation, secondaryAnimation, child) {
53-
const begin = Offset(0.0, 0.1);
54-
const end = Offset.zero;
55-
const curve = Curves.easeOutCubic;
56-
57-
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
58-
59-
var fadeAnimation = Tween(begin: 0.0, end: 1.0).animate(
60-
CurvedAnimation(parent: animation, curve: curve),
61-
);
62-
63-
return SlideTransition(
64-
position: animation.drive(tween),
65-
child: FadeTransition(
66-
opacity: fadeAnimation,
67-
child: child,
68-
),
69-
);
70-
},
71-
transitionDuration: const Duration(milliseconds: 400),
32+
home: const LoginPage(),
7233
);
7334
}
7435
}

lib/application/authentication/auth_state_controller.dart

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import "../../services/authentication/firebase_auth_facade.dart";
88
import "auth_events.dart";
99
import "auth_states.dart";
1010

11+
final authStateControllerProvider = NotifierProvider<AuthStateController, AuthStates>(
12+
AuthStateController.new,
13+
);
14+
1115
class AuthStateController extends Notifier<AuthStates> {
1216
@override
1317
AuthStates build() {
@@ -19,87 +23,84 @@ class AuthStateController extends Notifier<AuthStates> {
1923
Future<void> mapEventsToStates(AuthEvents events) async {
2024
await events.map(
2125
emailChanged: (value) async {
22-
state = state.copyWith(
23-
emailAddress: EmailAddress(
24-
email: value.email,
25-
),
26-
authFailureOrSuccess: none());
26+
_updateEmail(value.email!);
2727
},
2828
passwordChanged: (value) async {
29-
state = state.copyWith(
30-
password: Password(
31-
password: value.password,
32-
),
33-
authFailureOrSuccess: none(),
34-
);
29+
_updatePassword(value.password!);
3530
},
3631
signUpWithEmailAndPasswordPressed: (value) async {
37-
await _performAuthAction(
38-
_authFacade.registerWithEmailAndPassword,
39-
);
32+
await signUpWithEmailAndPassword();
4033
},
4134
signInWithEmailAndPasswordPressed: (value) async {
42-
await _performAuthAction(
43-
_authFacade.signInWithEmailAndPassword,
44-
);
35+
await signInWithEmailAndPassword();
4536
},
4637
);
4738
}
4839

4940
void emailChanged(String email) {
41+
_updateEmail(email);
42+
}
43+
44+
void passwordChanged(String password) {
45+
_updatePassword(password);
46+
}
47+
48+
void _updateEmail(String email) {
5049
state = state.copyWith(
5150
emailAddress: EmailAddress(email: email),
5251
authFailureOrSuccess: none(),
52+
showError: false,
5353
);
5454
}
5555

56-
void passwordChanged(String password) {
56+
void _updatePassword(String password) {
5757
state = state.copyWith(
5858
password: Password(password: password),
5959
authFailureOrSuccess: none(),
60+
showError: false,
6061
);
6162
}
6263

6364
Future<void> signUpWithEmailAndPassword() async {
64-
await _performAuthAction(
65-
_authFacade.registerWithEmailAndPassword,
66-
);
65+
await _performAuthAction(_authFacade.registerWithEmailAndPassword);
6766
}
6867

6968
Future<void> signInWithEmailAndPassword() async {
70-
await _performAuthAction(
71-
_authFacade.signInWithEmailAndPassword,
72-
);
69+
await _performAuthAction(_authFacade.signInWithEmailAndPassword);
7370
}
7471

7572
Future<void> _performAuthAction(
76-
Future<Either<AuthFailures, Unit>> Function({required EmailAddress emailAddress, required Password password})
77-
forwardCall,
73+
Future<Either<AuthFailures, Unit>> Function({
74+
required EmailAddress emailAddress,
75+
required Password password,
76+
}) forwardCall,
7877
) async {
7978
final isEmailValid = state.emailAddress.isValid();
8079
final isPasswordValid = state.password.isValid();
81-
Either<AuthFailures, Unit>? failureOrSuccess;
8280

83-
if (isEmailValid && isPasswordValid) {
81+
if (!isEmailValid || !isPasswordValid) {
8482
state = state.copyWith(
85-
isSubmitting: true,
83+
showError: true,
8684
authFailureOrSuccess: none(),
8785
);
88-
89-
failureOrSuccess = await forwardCall(
90-
emailAddress: state.emailAddress,
91-
password: state.password,
92-
);
86+
return;
9387
}
9488

89+
state = state.copyWith(
90+
isSubmitting: true,
91+
authFailureOrSuccess: none(),
92+
showError: false,
93+
);
94+
95+
final failureOrSuccess = await forwardCall(
96+
emailAddress: state.emailAddress,
97+
password: state.password,
98+
);
99+
95100
state = state.copyWith(
96101
isSubmitting: false,
97-
showError: true,
102+
showError: failureOrSuccess.isLeft(),
98103
authFailureOrSuccess: optionOf(failureOrSuccess),
99104
);
100105
}
101106
}
102-
103-
final authStateControllerProvider = NotifierProvider<AuthStateController, AuthStates>(() {
104-
return AuthStateController();
105-
});

0 commit comments

Comments
 (0)