refactoring and checkpoint
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Classe utilitaire pour gérer les couleurs de l'application en mode clair et sombre.
|
||||
class AppColors {
|
||||
// Thème clair
|
||||
static const Color lightPrimary = Color(0xFF0057D9);
|
||||
static const Color lightSecondary = Color(0xFFFFC107);
|
||||
static const Color lightOnPrimary = Colors.white;
|
||||
static const Color lightOnSecondary = Color(0xFF212121);
|
||||
static const Color lightBackground = Colors.white;
|
||||
static const Color lightSurface = Color(0xFFFFFFFF);
|
||||
static const Color lightTextPrimary = Color(0xFF212121);
|
||||
static const Color lightTextSecondary = Color(0xFF616161);
|
||||
static const Color lightCardColor = Color(0xFFFFFFFF);
|
||||
static const Color lightAccentColor = Color(0xFF4CAF50);
|
||||
static const Color lightError = Color(0xFFB00020);
|
||||
static const Color lightIconPrimary = Color(0xFF212121); // Icône primaire sombre
|
||||
static const Color lightIconSecondary = Color(0xFF757575); // Icône secondaire gris clair
|
||||
// Thème sombre
|
||||
static const Color darkPrimary = Color(0xFF121212);
|
||||
static const Color darkSecondary = Color(0xFFFF5722);
|
||||
static const Color darkOnPrimary = Colors.white;
|
||||
static const Color darkOnSecondary = Colors.white;
|
||||
static const Color darkBackground = Color(0xFF121212);
|
||||
static const Color darkSurface = Color(0xFF1F1F1F);
|
||||
static const Color darkTextPrimary = Color(0xFFE0E0E0);
|
||||
static const Color darkTextSecondary = Color(0xFFBDBDBD);
|
||||
static const Color darkCardColor = Color(0xFF2C2C2C);
|
||||
static const Color darkAccentColor = Color(0xFF81C784);
|
||||
static const Color darkError = Color(0xFFCF6679);
|
||||
static const Color darkIconPrimary = Colors.white; // Icône primaire blanche
|
||||
static const Color darkIconSecondary = Color(0xFFBDBDBD); // Icône secondaire gris clair
|
||||
|
||||
// Sélection automatique des couleurs en fonction du mode de thème
|
||||
static Color get primary => isDarkMode() ? darkPrimary : lightPrimary;
|
||||
static Color get secondary => isDarkMode() ? darkSecondary : lightSecondary;
|
||||
static Color get onPrimary => isDarkMode() ? darkOnPrimary : lightOnPrimary;
|
||||
static Color get onSecondary => isDarkMode() ? darkOnSecondary : lightOnSecondary;
|
||||
static Color get backgroundColor => isDarkMode() ? darkBackground : lightBackground;
|
||||
static Color get surface => isDarkMode() ? darkSurface : lightSurface;
|
||||
static Color get textPrimary => isDarkMode() ? darkTextPrimary : lightTextPrimary;
|
||||
static Color get textSecondary => isDarkMode() ? darkTextSecondary : lightTextSecondary;
|
||||
static Color get cardColor => isDarkMode() ? darkCardColor : lightCardColor;
|
||||
static Color get accentColor => isDarkMode() ? darkAccentColor : lightAccentColor;
|
||||
static Color get errorColor => isDarkMode() ? darkError : lightError;
|
||||
static Color get iconPrimary => isDarkMode() ? darkIconPrimary : lightIconPrimary;
|
||||
static Color get iconSecondary => isDarkMode() ? darkIconSecondary : lightIconSecondary;
|
||||
|
||||
/// Méthode utilitaire pour vérifier si le mode sombre est activé.
|
||||
static bool isDarkMode() {
|
||||
final brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
|
||||
return brightness == Brightness.dark;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
class Urls {
|
||||
static const String baseUrl = 'http://192.168.1.145:8085';
|
||||
// static const String login = baseUrl + 'auth/login';
|
||||
static const String eventsUrl = '$baseUrl/events';
|
||||
// Ajoute d'autres URLs ici
|
||||
|
||||
// Authentication and Users Endpoints
|
||||
static const String authenticateUser = '$baseUrl/users/authenticate';
|
||||
static const String createUser = '$baseUrl/users';
|
||||
static const String getUserById = '$baseUrl/users'; // Append '/{id}' dynamically
|
||||
static const String deleteUser = '$baseUrl/users'; // Append '/{id}' dynamically
|
||||
static const String updateUserProfileImage = '$baseUrl/users'; // Append '/{id}/profile-image' dynamically
|
||||
|
||||
// Events Endpoints
|
||||
static const String createEvent = '$baseUrl/events';
|
||||
static const String getEventById = '$baseUrl/events'; // Append '/{id}' dynamically
|
||||
static const String deleteEvent = '$baseUrl/events'; // Append '/{id}' dynamically
|
||||
static const String getEventsAfterDate = '$baseUrl/events/after-date';
|
||||
static const String addParticipant = '$baseUrl/events'; // Append '/{id}/participants' dynamically
|
||||
static const String removeParticipant = '$baseUrl/events'; // Append '/{id}/participants/{userId}' dynamically
|
||||
static const String getNumberOfParticipants = '$baseUrl/events'; // Append '/{id}/participants/count' dynamically
|
||||
static const String closeEvent = '$baseUrl/events'; // Append '/{id}/close' dynamically
|
||||
static const String updateEvent = '$baseUrl/events'; // Append '/{id}' dynamically
|
||||
static const String updateEventImage = '$baseUrl/events'; // Append '/{id}/image' dynamically
|
||||
static const String getAllEvents = '$baseUrl/events';
|
||||
static const String getEventsByCategory = '$baseUrl/events/category'; // Append '/{category}' dynamically
|
||||
static const String updateEventStatus = '$baseUrl/events'; // Append '/{id}/status' dynamically
|
||||
static const String searchEvents = '$baseUrl/events/search'; // Use query parameter for 'keyword'
|
||||
static const String getEventsByUser = '$baseUrl/events/user'; // Append '/{userId}' dynamically
|
||||
static const String getEventsByStatus = '$baseUrl/events/status'; // Append '/{status}' dynamically
|
||||
static const String getEventsBetweenDates = '$baseUrl/events/between-dates'; // Use query parameters for startDate and endDate
|
||||
|
||||
// Other URLs can be added here as the project expands
|
||||
}
|
||||
|
||||
@@ -27,3 +27,26 @@ class ServerExceptionWithMessage implements Exception {
|
||||
String toString() => 'ServerException: $message';
|
||||
}
|
||||
|
||||
class UserNotFoundException implements Exception {
|
||||
final String message;
|
||||
UserNotFoundException([this.message = "User not found"]);
|
||||
|
||||
@override
|
||||
String toString() => "UserNotFoundException: $message";
|
||||
}
|
||||
|
||||
class ConflictException implements Exception {
|
||||
final String message;
|
||||
ConflictException([this.message = "Conflict"]);
|
||||
|
||||
@override
|
||||
String toString() => "ConflictException: $message";
|
||||
}
|
||||
|
||||
class UnauthorizedException implements Exception {
|
||||
final String message;
|
||||
UnauthorizedException([this.message = "Unauthorized"]);
|
||||
|
||||
@override
|
||||
String toString() => "UnauthorizedException: $message";
|
||||
}
|
||||
@@ -1,20 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:afterwork/core/constants/colors.dart';
|
||||
|
||||
/// Classe qui définit les thèmes de l'application AfterWork.
|
||||
/// Elle gère à la fois le thème clair et le thème sombre, avec des personnalisations
|
||||
/// pour les couleurs, les boutons, les textes et d'autres éléments visuels.
|
||||
class AppTheme {
|
||||
/// Thème clair
|
||||
static final ThemeData lightTheme = ThemeData(
|
||||
primaryColor: Colors.blue,
|
||||
colorScheme: const ColorScheme.light(
|
||||
secondary: Colors.orange,
|
||||
),
|
||||
brightness: Brightness.light,
|
||||
buttonTheme: const ButtonThemeData(buttonColor: Colors.blue),
|
||||
primaryColor: AppColors.lightPrimary,
|
||||
scaffoldBackgroundColor: AppColors.lightBackground,
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: AppColors.lightPrimary,
|
||||
iconTheme: IconThemeData(color: AppColors.lightOnPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.lightTextPrimary),
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColors.lightPrimary,
|
||||
secondary: AppColors.lightSecondary,
|
||||
onPrimary: AppColors.lightOnPrimary,
|
||||
onSecondary: AppColors.lightOnSecondary,
|
||||
surface: AppColors.lightSurface,
|
||||
),
|
||||
buttonTheme: const ButtonThemeData(
|
||||
buttonColor: AppColors.lightPrimary,
|
||||
textTheme: ButtonTextTheme.primary,
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
bodyLarge: TextStyle(color: AppColors.lightTextPrimary),
|
||||
bodyMedium: TextStyle(color: AppColors.lightTextSecondary),
|
||||
titleLarge: TextStyle(color: AppColors.lightTextPrimary),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: AppColors.lightSurface,
|
||||
labelStyle: const TextStyle(color: AppColors.lightTextPrimary),
|
||||
hintStyle: const TextStyle(color: AppColors.lightTextSecondary),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: AppColors.lightPrimary),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
),
|
||||
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||
backgroundColor: AppColors.lightPrimary,
|
||||
foregroundColor: AppColors.lightOnPrimary,
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.lightPrimary,
|
||||
foregroundColor: AppColors.lightOnPrimary,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
|
||||
textStyle: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/// Thème sombre
|
||||
static final ThemeData darkTheme = ThemeData(
|
||||
primaryColor: Colors.black,
|
||||
colorScheme: const ColorScheme.dark(
|
||||
secondary: Colors.red,
|
||||
),
|
||||
brightness: Brightness.dark,
|
||||
primaryColor: AppColors.darkPrimary,
|
||||
scaffoldBackgroundColor: AppColors.darkBackground,
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: AppColors.darkPrimary,
|
||||
iconTheme: IconThemeData(color: AppColors.darkOnPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.darkTextPrimary),
|
||||
colorScheme: const ColorScheme.dark(
|
||||
primary: AppColors.darkPrimary,
|
||||
secondary: AppColors.darkSecondary,
|
||||
onPrimary: AppColors.darkOnPrimary,
|
||||
onSecondary: AppColors.darkOnSecondary,
|
||||
surface: AppColors.darkSurface,
|
||||
),
|
||||
buttonTheme: const ButtonThemeData(
|
||||
buttonColor: AppColors.darkSecondary,
|
||||
textTheme: ButtonTextTheme.primary,
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
bodyLarge: TextStyle(color: AppColors.darkTextPrimary),
|
||||
bodyMedium: TextStyle(color: AppColors.darkTextSecondary),
|
||||
titleLarge: TextStyle(color: AppColors.darkTextPrimary),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: AppColors.darkSurface,
|
||||
labelStyle: const TextStyle(color: AppColors.darkTextPrimary),
|
||||
hintStyle: const TextStyle(color: AppColors.darkTextSecondary),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: AppColors.darkSecondary),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: AppColors.darkTextSecondary),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
),
|
||||
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||
backgroundColor: AppColors.darkSecondary,
|
||||
foregroundColor: AppColors.darkOnPrimary,
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.darkSecondary,
|
||||
foregroundColor: AppColors.darkOnPrimary,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
|
||||
textStyle: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
18
lib/core/theme/theme_provider.dart
Normal file
18
lib/core/theme/theme_provider.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'app_theme.dart'; // Importe tes définitions de thème
|
||||
|
||||
class ThemeProvider with ChangeNotifier {
|
||||
bool _isDarkMode = false; // Mode sombre par défaut désactivé
|
||||
|
||||
bool get isDarkMode => _isDarkMode;
|
||||
|
||||
void toggleTheme() {
|
||||
_isDarkMode = !_isDarkMode;
|
||||
notifyListeners(); // Notifie les widgets dépendants
|
||||
}
|
||||
|
||||
// Utilise AppTheme pour obtenir le thème courant
|
||||
ThemeData get currentTheme {
|
||||
return _isDarkMode ? AppTheme.darkTheme : AppTheme.lightTheme;
|
||||
}
|
||||
}
|
||||
15
lib/core/utils/calculate_time_ago.dart
Normal file
15
lib/core/utils/calculate_time_ago.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fichier utilitaire pour le calcul du temps écoulé
|
||||
String calculateTimeAgo(DateTime publicationDate) {
|
||||
final now = DateTime.now();
|
||||
final difference = now.difference(publicationDate);
|
||||
|
||||
if (difference.inDays > 0) {
|
||||
return '${difference.inDays} jour${difference.inDays > 1 ? 's' : ''}';
|
||||
} else if (difference.inHours > 0) {
|
||||
return '${difference.inHours} heure${difference.inHours > 1 ? 's' : ''}';
|
||||
} else if (difference.inMinutes > 0) {
|
||||
return '${difference.inMinutes} minute${difference.inMinutes > 1 ? 's' : ''}';
|
||||
} else {
|
||||
return 'À l\'instant';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:intl/intl.dart';
|
||||
|
||||
class DateFormatter {
|
||||
static String formatDate(DateTime date) {
|
||||
return DateFormat('EEEE dd MMMM yyyy', 'fr_FR').format(date);
|
||||
// Formater la date avec l'heure incluse
|
||||
return DateFormat('EEEE dd MMMM yyyy, à HH:mm', 'fr_FR').format(date);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user