ionic-planb-logistic-app-fl.../lib/theme/component_themes.dart
Jean-Philippe Brule 57b81d1e95 Fix linting issues and code quality improvements
Resolve 62 linting issues identified by flutter analyze, reducing
total issues from 79 to 17. All critical warnings addressed.

Changes:
- Replace deprecated withOpacity() with withValues(alpha:) (25 instances)
- Remove unused imports from 9 files
- Remove unused variables and fields (6 instances)
- Fix Riverpod 3.0 state access violations in settings_page
- Remove unnecessary null-aware operators in navigation_page (6 instances)
- Fix unnecessary type casts in providers (4 instances)
- Remove unused methods: _getDarkMapStyle, _showPermissionDialog
- Simplify hover state management by removing unused _isHovered fields

Remaining 17 issues are info-level style suggestions and defensive
programming patterns that don't impact functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 01:39:35 -05:00

263 lines
7.9 KiB
Dart

import 'package:flutter/material.dart';
import 'spacing_system.dart';
import 'border_system.dart';
import 'shadow_system.dart';
import 'size_system.dart';
/// Component Theme Data Builders
/// Centralized component theme definitions for consistent styling
class ComponentThemes {
static CardThemeData cardTheme(ColorScheme colorScheme) {
return CardThemeData(
elevation: AppShadow.cardElevation,
shadowColor: AppShadow.getShadowColor(colorScheme.brightness),
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularMd,
),
clipBehavior: Clip.antiAlias,
color: colorScheme.surface,
);
}
static AppBarTheme appBarTheme(ColorScheme colorScheme) {
return AppBarTheme(
backgroundColor: colorScheme.surface,
foregroundColor: colorScheme.onSurface,
elevation: AppShadow.appBarElevation,
centerTitle: false,
iconTheme: IconThemeData(
color: colorScheme.onSurface,
size: AppSizes.iconMd,
),
titleTextStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w600,
fontSize: 20,
color: colorScheme.onSurface,
),
);
}
static FilledButtonThemeData filledButtonTheme(ColorScheme colorScheme) {
return FilledButtonThemeData(
style: FilledButton.styleFrom(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
elevation: AppShadow.elevationSm,
padding: AppSpacing.paddingButton,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularSm,
),
textStyle: const TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
fontSize: 14,
),
),
);
}
static ElevatedButtonThemeData elevatedButtonTheme(ColorScheme colorScheme) {
return ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
elevation: AppShadow.elevationSm,
padding: AppSpacing.paddingButton,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularSm,
),
textStyle: const TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
fontSize: 14,
),
),
);
}
static OutlinedButtonThemeData outlinedButtonTheme(ColorScheme colorScheme) {
return OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
foregroundColor: colorScheme.primary,
side: BorderSide(color: colorScheme.outline),
padding: AppSpacing.paddingButton,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularSm,
),
textStyle: const TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
fontSize: 14,
),
),
);
}
static InputDecorationTheme inputDecorationTheme(ColorScheme colorScheme) {
return InputDecorationTheme(
filled: true,
fillColor: colorScheme.surfaceContainerHighest.withValues(alpha: 0.5),
contentPadding: EdgeInsets.symmetric(
horizontal: AppSpacing.inputPadding,
vertical: AppSpacing.md,
),
border: OutlineInputBorder(
borderRadius: AppBorders.circularSm,
borderSide: BorderSide(
color: colorScheme.outline.withValues(alpha: 0.3),
),
),
enabledBorder: OutlineInputBorder(
borderRadius: AppBorders.circularSm,
borderSide: BorderSide(
color: colorScheme.outline.withValues(alpha: 0.3),
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: AppBorders.circularSm,
borderSide: BorderSide(
color: colorScheme.primary,
width: 2,
),
),
errorBorder: OutlineInputBorder(
borderRadius: AppBorders.circularSm,
borderSide: BorderSide(
color: colorScheme.error,
width: 1,
),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: AppBorders.circularSm,
borderSide: BorderSide(
color: colorScheme.error,
width: 2,
),
),
labelStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
color: colorScheme.onSurfaceVariant,
),
hintStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w400,
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
),
);
}
static SnackBarThemeData snackBarTheme(ColorScheme colorScheme) {
return SnackBarThemeData(
backgroundColor: colorScheme.inverseSurface,
contentTextStyle: TextStyle(
fontFamily: 'Montserrat',
color: colorScheme.onInverseSurface,
),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularSm,
),
);
}
static DialogThemeData dialogTheme(ColorScheme colorScheme) {
return DialogThemeData(
backgroundColor: colorScheme.surface,
elevation: AppShadow.dialogElevation,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularLg,
),
contentTextStyle: TextStyle(
fontFamily: 'Montserrat',
color: colorScheme.onSurface,
),
);
}
static BottomNavigationBarThemeData bottomNavigationBarTheme(
ColorScheme colorScheme,
) {
return BottomNavigationBarThemeData(
backgroundColor: colorScheme.surface,
selectedItemColor: colorScheme.primary,
unselectedItemColor: colorScheme.onSurfaceVariant,
showSelectedLabels: true,
showUnselectedLabels: true,
type: BottomNavigationBarType.fixed,
selectedLabelStyle: const TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
fontSize: 12,
),
unselectedLabelStyle: const TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w400,
fontSize: 12,
),
);
}
static ChipThemeData chipTheme(ColorScheme colorScheme) {
return ChipThemeData(
backgroundColor: colorScheme.surfaceContainerHighest,
deleteIconColor: colorScheme.onSurfaceVariant,
disabledColor: colorScheme.surfaceContainerHighest.withValues(alpha: 0.38),
padding: EdgeInsets.symmetric(
horizontal: AppSpacing.sm,
vertical: AppSpacing.xs,
),
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularSm,
),
labelStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
color: colorScheme.onSurfaceVariant,
),
secondaryLabelStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
color: colorScheme.onSurfaceVariant,
),
brightness: colorScheme.brightness,
);
}
static ProgressIndicatorThemeData progressIndicatorTheme(
ColorScheme colorScheme,
) {
return ProgressIndicatorThemeData(
color: colorScheme.primary,
linearTrackColor: colorScheme.surfaceContainerHighest,
circularTrackColor: colorScheme.surfaceContainerHighest,
);
}
static FloatingActionButtonThemeData floatingActionButtonTheme(
ColorScheme colorScheme,
) {
return FloatingActionButtonThemeData(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
elevation: AppShadow.fabElevation,
shape: RoundedRectangleBorder(
borderRadius: AppBorders.circularMd,
),
);
}
static SliderThemeData sliderTheme(ColorScheme colorScheme) {
return SliderThemeData(
trackHeight: 4.0,
activeTrackColor: colorScheme.primary,
inactiveTrackColor: colorScheme.surfaceContainerHighest,
thumbColor: colorScheme.primary,
overlayColor: colorScheme.primary.withValues(alpha: 0.12),
valueIndicatorColor: colorScheme.primary,
);
}
}