Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .taskmaster/tasks/task_001.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Task ID: 1
# Title: Migrate to Riverpod 3.0
# Status: done
# Dependencies: None
# Priority: high
# 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.
# Details:


# Test Strategy:

11 changes: 11 additions & 0 deletions .taskmaster/tasks/task_002.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Task ID: 2
# Title: Modernize the User Interface
# Status: done
# Dependencies: 1
# Priority: high
# 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.
# Details:


# Test Strategy:

11 changes: 11 additions & 0 deletions .taskmaster/tasks/task_003.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Task ID: 3
# Title: Refactor and Clean Up Codebase
# Status: pending
# Dependencies: 1
# Priority: medium
# 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.
# Details:


# Test Strategy:

60 changes: 59 additions & 1 deletion .taskmaster/tasks/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,67 @@
"title": "Refactor and Clean Up Codebase",
"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.",
"status": "pending",
"priority": "medium",
"dependencies": [
1
],
"priority": "medium",
"details": "",
"testStrategy": "",
"subtasks": [
{
"id": 1,
"title": "Refactor Domain Layer",
"description": "Fix typos, enhance email validation with industry-standard regex, strengthen password security (8+ chars)",
"status": "done",
"dependencies": [],
"details": "",
"testStrategy": ""
},
{
"id": 2,
"title": "Refactor Application Layer",
"description": "Streamline AuthStateController, improve error handling, cleaner code structure",
"status": "done",
"dependencies": [],
"details": "",
"testStrategy": ""
},
{
"id": 3,
"title": "Refactor Services Layer",
"description": "Enhance Firebase Auth Facade with centralized error mapping and better null safety",
"status": "done",
"dependencies": [],
"details": "",
"testStrategy": ""
},
{
"id": 4,
"title": "Refactor UI Components",
"description": "Refactor Login/Registration pages with modular structure, extract helper methods, enhance validation",
"status": "done",
"dependencies": [],
"details": "",
"testStrategy": ""
},
{
"id": 5,
"title": "App Level Improvements",
"description": "Simplify routing, add global page transitions, performance improvements",
"status": "done",
"dependencies": [],
"details": "",
"testStrategy": ""
},
{
"id": 6,
"title": "Update Dependencies",
"description": "Update all dependencies to their latest stable versions",
"status": "pending",
"dependencies": [],
"details": "",
"testStrategy": ""
}
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ PODS:
- FirebaseAuth (~> 11.15.0)
- Firebase/CoreOnly (11.15.0):
- FirebaseCore (~> 11.15.0)
- firebase_auth (5.6.2):
- firebase_auth (5.7.0):
- Firebase/Auth (= 11.15.0)
- firebase_core
- Flutter
- firebase_core (3.15.1):
- firebase_core (3.15.2):
- Firebase/CoreOnly (= 11.15.0)
- Flutter
- FirebaseAppCheckInterop (11.15.0)
Expand Down Expand Up @@ -83,8 +83,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Firebase: d99ac19b909cd2c548339c2241ecd0d1599ab02e
firebase_auth: b8ed959bf77eca5cf0312b5e29708fe8311a0ddf
firebase_core: cf4d42a8ac915e51c0c2dc103442f3036d941a2d
firebase_auth: 5342db41af2ba5ed32a6177d9e326eecbebda912
firebase_core: 99a37263b3c27536063a7b601d9e2a49400a433c
FirebaseAppCheckInterop: 06fe5a3799278ae4667e6c432edd86b1030fa3df
FirebaseAuth: a6575e5fbf46b046c58dc211a28a5fbdd8d4c83b
FirebaseAuthInterop: 7087d7a4ee4bc4de019b2d0c240974ed5d89e2fd
Expand Down
41 changes: 1 addition & 40 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class FirebaseAuthenticationDDD extends StatelessWidget {

@override
Widget build(BuildContext context) {
// Set system UI overlay style
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
Expand All @@ -26,49 +25,11 @@ class FirebaseAuthenticationDDD extends StatelessWidget {
title: "Firebase Auth DDD",
debugShowCheckedModeBanner: kDebugMode,

// Apply our modern Material You theme system
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
themeMode: ThemeMode.system,

// Improved route transitions
onGenerateRoute: (settings) {
switch (settings.name) {
case "/":
return _createRoute(LoginPage());
default:
return _createRoute(LoginPage());
}
},

home: LoginPage(),
);
}

// Custom page route with smooth transitions
PageRoute _createRoute(Widget page) {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => page,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 0.1);
const end = Offset.zero;
const curve = Curves.easeOutCubic;

var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));

var fadeAnimation = Tween(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: animation, curve: curve),
);

return SlideTransition(
position: animation.drive(tween),
child: FadeTransition(
opacity: fadeAnimation,
child: child,
),
);
},
transitionDuration: const Duration(milliseconds: 400),
home: const LoginPage(),
);
}
}
79 changes: 40 additions & 39 deletions lib/application/authentication/auth_state_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import "../../services/authentication/firebase_auth_facade.dart";
import "auth_events.dart";
import "auth_states.dart";

final authStateControllerProvider = NotifierProvider<AuthStateController, AuthStates>(
AuthStateController.new,
);

class AuthStateController extends Notifier<AuthStates> {
@override
AuthStates build() {
Expand All @@ -19,87 +23,84 @@ class AuthStateController extends Notifier<AuthStates> {
Future<void> mapEventsToStates(AuthEvents events) async {
await events.map(
emailChanged: (value) async {
state = state.copyWith(
emailAddress: EmailAddress(
email: value.email,
),
authFailureOrSuccess: none());
_updateEmail(value.email!);
},
passwordChanged: (value) async {
state = state.copyWith(
password: Password(
password: value.password,
),
authFailureOrSuccess: none(),
);
_updatePassword(value.password!);
},
signUpWithEmailAndPasswordPressed: (value) async {
await _performAuthAction(
_authFacade.registerWithEmailAndPassword,
);
await signUpWithEmailAndPassword();
},
signInWithEmailAndPasswordPressed: (value) async {
await _performAuthAction(
_authFacade.signInWithEmailAndPassword,
);
await signInWithEmailAndPassword();
},
);
}

void emailChanged(String email) {
_updateEmail(email);
}

void passwordChanged(String password) {
_updatePassword(password);
}

void _updateEmail(String email) {
state = state.copyWith(
emailAddress: EmailAddress(email: email),
authFailureOrSuccess: none(),
showError: false,
);
}

void passwordChanged(String password) {
void _updatePassword(String password) {
state = state.copyWith(
password: Password(password: password),
authFailureOrSuccess: none(),
showError: false,
);
}

Future<void> signUpWithEmailAndPassword() async {
await _performAuthAction(
_authFacade.registerWithEmailAndPassword,
);
await _performAuthAction(_authFacade.registerWithEmailAndPassword);
}

Future<void> signInWithEmailAndPassword() async {
await _performAuthAction(
_authFacade.signInWithEmailAndPassword,
);
await _performAuthAction(_authFacade.signInWithEmailAndPassword);
}

Future<void> _performAuthAction(
Future<Either<AuthFailures, Unit>> Function({required EmailAddress emailAddress, required Password password})
forwardCall,
Future<Either<AuthFailures, Unit>> Function({
required EmailAddress emailAddress,
required Password password,
}) forwardCall,
) async {
final isEmailValid = state.emailAddress.isValid();
final isPasswordValid = state.password.isValid();
Either<AuthFailures, Unit>? failureOrSuccess;

if (isEmailValid && isPasswordValid) {
if (!isEmailValid || !isPasswordValid) {
state = state.copyWith(
isSubmitting: true,
showError: true,
authFailureOrSuccess: none(),
);

failureOrSuccess = await forwardCall(
emailAddress: state.emailAddress,
password: state.password,
);
return;
}

state = state.copyWith(
isSubmitting: true,
authFailureOrSuccess: none(),
showError: false,
);

final failureOrSuccess = await forwardCall(
emailAddress: state.emailAddress,
password: state.password,
);

state = state.copyWith(
isSubmitting: false,
showError: true,
showError: failureOrSuccess.isLeft(),
authFailureOrSuccess: optionOf(failureOrSuccess),
);
}
}

final authStateControllerProvider = NotifierProvider<AuthStateController, AuthStates>(() {
return AuthStateController();
});
Loading