feat(design-system): dark mode adaptatif sur widgets partagés
Pattern AppColors pair (isDark ? AppColors.surfaceDark : AppColors.surface) appliqué sur : - UnionStatWidget, UnionBalanceCard, UnionActionButton, UFSectionHeader - DashboardEventRow, DashboardActivityRow, UnionExportButton - MiniAvatar (border adaptatif) - ConfirmationDialog (cancel colors adaptés) - FileUploadWidget (textSecondary adaptatif) Les couleurs surface/border/textPrimary/textSecondary hardcodées (light-only) sont remplacées par les paires *Dark conditionnelles. Les couleurs sémantiques (error, success, warning, primary) restent inchangées.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
library confirmation_dialog;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../design_system/tokens/app_colors.dart';
|
||||
|
||||
/// Type d'action pour personnaliser l'apparence du dialogue
|
||||
enum ConfirmationAction {
|
||||
@@ -70,7 +71,7 @@ class ConfirmationDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = _getColors();
|
||||
final colors = _getColors(context);
|
||||
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -159,43 +160,44 @@ class ConfirmationDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Color> _getColors() {
|
||||
Map<String, Color> _getColors(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
switch (action) {
|
||||
case ConfirmationAction.delete:
|
||||
return {
|
||||
'icon': Colors.red,
|
||||
'title': Colors.red[700]!,
|
||||
'button': Colors.red,
|
||||
'icon': AppColors.error,
|
||||
'title': AppColors.error,
|
||||
'button': AppColors.error,
|
||||
};
|
||||
case ConfirmationAction.deactivate:
|
||||
return {
|
||||
'icon': Colors.orange,
|
||||
'title': Colors.orange[700]!,
|
||||
'button': Colors.orange,
|
||||
'icon': AppColors.warning,
|
||||
'title': AppColors.warning,
|
||||
'button': AppColors.warning,
|
||||
};
|
||||
case ConfirmationAction.activate:
|
||||
return {
|
||||
'icon': Colors.green,
|
||||
'title': Colors.green[700]!,
|
||||
'button': Colors.green,
|
||||
'icon': AppColors.success,
|
||||
'title': AppColors.success,
|
||||
'button': AppColors.success,
|
||||
};
|
||||
case ConfirmationAction.cancel:
|
||||
return {
|
||||
'icon': Colors.grey,
|
||||
'title': Colors.grey[700]!,
|
||||
'button': Colors.grey,
|
||||
'icon': isDark ? AppColors.textSecondaryDark : AppColors.textTertiary,
|
||||
'title': isDark ? AppColors.textSecondaryDark : AppColors.textSecondary,
|
||||
'button': isDark ? AppColors.textSecondaryDark : AppColors.textTertiary,
|
||||
};
|
||||
case ConfirmationAction.warning:
|
||||
return {
|
||||
'icon': Colors.amber,
|
||||
'title': Colors.amber[700]!,
|
||||
'button': Colors.amber,
|
||||
'icon': AppColors.warningUI,
|
||||
'title': AppColors.warning,
|
||||
'button': AppColors.warningUI,
|
||||
};
|
||||
case ConfirmationAction.info:
|
||||
return {
|
||||
'icon': Colors.blue,
|
||||
'title': Colors.blue[700]!,
|
||||
'button': Colors.blue,
|
||||
'icon': AppColors.info,
|
||||
'title': AppColors.primary,
|
||||
'button': AppColors.info,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import '../design_system/tokens/app_colors.dart';
|
||||
|
||||
/// Widget réutilisable pour uploader un fichier (image ou PDF)
|
||||
/// avec prévisualisation et validation
|
||||
@@ -105,7 +106,7 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
backgroundColor: AppColors.error,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -179,7 +180,7 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
),
|
||||
if (_selectedFile != null)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.red),
|
||||
icon: const Icon(Icons.delete, color: AppColors.error),
|
||||
onPressed: _removeFile,
|
||||
),
|
||||
],
|
||||
@@ -202,7 +203,7 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
border: Border.all(color: AppColors.borderStrong),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -218,13 +219,13 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
border: Border.all(color: AppColors.borderStrong),
|
||||
),
|
||||
child: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.picture_as_pdf, size: 48, color: Colors.red),
|
||||
Icon(Icons.picture_as_pdf, size: 48, color: AppColors.error),
|
||||
SizedBox(height: 8),
|
||||
Text('Document PDF'),
|
||||
],
|
||||
@@ -234,7 +235,11 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_selectedFile!.path.split('/').last,
|
||||
style: TextStyle(color: Colors.grey.shade700),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? AppColors.textSecondaryDark
|
||||
: AppColors.textSecondary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -244,7 +249,7 @@ class _FileUploadWidgetState extends State<FileUploadWidget> {
|
||||
'Formats acceptés: JPEG, PNG, PDF (max 5 MB)',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
color: AppColors.textTertiary,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import '../design_system/tokens/app_colors.dart';
|
||||
import '../design_system/tokens/app_typography.dart';
|
||||
import '../design_system/tokens/color_tokens.dart';
|
||||
|
||||
/// UnionFlow Mobile - Composant DRY : MiniAvatar
|
||||
/// Évite toute répétition de configuration d'image de profil.
|
||||
@@ -28,6 +29,9 @@ class MiniAvatar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final borderColor = isDark ? AppColors.borderDark : AppColors.border;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
@@ -35,11 +39,8 @@ class MiniAvatar extends StatelessWidget {
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: backgroundColor ?? AppColors.primaryGreen.withOpacity(0.1),
|
||||
border: Border.all(
|
||||
color: AppColors.lightBorder,
|
||||
width: 0.5,
|
||||
),
|
||||
color: backgroundColor ?? AppColors.primary.withOpacity(isDark ? 0.2 : 0.1),
|
||||
border: Border.all(color: borderColor, width: 0.5),
|
||||
),
|
||||
child: ClipOval(
|
||||
child: isIcon
|
||||
@@ -80,7 +81,7 @@ class MiniAvatar extends StatelessWidget {
|
||||
child: Text(
|
||||
fallbackText.toUpperCase(),
|
||||
style: AppTypography.actionText.copyWith(
|
||||
color: iconColor ?? AppColors.primaryGreen,
|
||||
color: iconColor ?? AppColors.primary,
|
||||
fontSize: size * 0.4,
|
||||
),
|
||||
),
|
||||
@@ -99,7 +100,7 @@ class MiniAvatar extends StatelessWidget {
|
||||
return Center(
|
||||
child: Icon(
|
||||
iconData,
|
||||
color: iconColor ?? AppColors.primaryGreen,
|
||||
color: iconColor ?? AppColors.primary,
|
||||
size: size * 0.6,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user