ionic-planb-logistic-app-fl.../lib/theme/animation_system.dart
Jean-Philippe Brule 3f31a509e0 Implement premium UI/UX refinements for Apple-like polish
Add three major UI components with animations and dark mode support:

- PremiumRouteCard: Enhanced route cards with left accent bar, delivery count badge, animated hover effects (1.02x scale), and dynamic shadow elevation
- DarkModeMapComponent: Google Maps integration with dark theme styling, custom info panels, navigation buttons, and delivery status indicators
- DeliveryListItem: Animated list items with staggered entrance animations, status badges with icons, contact indicators, and hover states

Updates:
- RoutesPage: Now uses PremiumRouteCard with improved visual hierarchy
- DeliveriesPage: Integrated DarkModeMapComponent and DeliveryListItem with proper theme awareness
- Animation system: Leverages existing AppAnimations constants for 200ms fast interactions and easeOut curves

Design philosophy:
- Element separation through left accent bars (status-coded)
- Elevation and shadow for depth (0.1-0.3 opacity)
- Staggered animations for list items (50ms delays)
- Dark mode optimized for evening use (reduced brightness)
- Responsive hover states with tactile feedback

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 14:41:32 -05:00

273 lines
7.4 KiB
Dart

import 'package:flutter/material.dart';
/// Svrnty Animation System
/// Complete animation configuration with durations, curves, and stagger delays
class AppAnimations {
// Prevent instantiation
AppAnimations._();
// ============================================
// ANIMATION DURATION CONSTANTS
// ============================================
/// Fast animation duration (200ms) - Button press, hover, quick interactions
static const Duration durationFast = Duration(milliseconds: 200);
/// Normal animation duration (300ms) - Default animations, fade, slide
static const Duration durationNormal = Duration(milliseconds: 300);
/// Slow animation duration (500ms) - Prominent animations, entrance, transitions
static const Duration durationSlow = Duration(milliseconds: 500);
/// Extra slow animation duration (800ms) - Slow, attention-grabbing animations
static const Duration durationXSlow = Duration(milliseconds: 800);
// ============================================
// ANIMATION DURATION IN MILLISECONDS
// ============================================
/// Fast animation milliseconds (200ms)
static const int durationFastMs = 200;
/// Normal animation milliseconds (300ms)
static const int durationNormalMs = 300;
/// Slow animation milliseconds (500ms)
static const int durationSlowMs = 500;
/// Extra slow animation milliseconds (800ms)
static const int durationXSlowMs = 800;
// ============================================
// ANIMATION CURVES
// ============================================
/// Ease In - Slow start, fast end (decelerate)
static const Curve curveEaseIn = Curves.easeIn;
/// Ease Out - Fast start, slow end (decelerate)
static const Curve curveEaseOut = Curves.easeOut;
/// Ease In Out - Smooth both ends (decelerate at start and end)
static const Curve curveEaseInOut = Curves.easeInOut;
/// Ease In Back - Back in, bounce effect
static const Curve curveEaseInBack = Curves.easeInBack;
/// Ease Out Back - Back out, bounce effect
static const Curve curveEaseOutBack = Curves.easeOutBack;
/// Elastic/Bouncy effect
static const Curve curveElastic = Curves.elasticOut;
/// Bouncing motion
static const Curve curveBounce = Curves.bounceOut;
/// Fast Out Slow In - Material standard curve
static const Curve curveFastOutSlowIn = Curves.fastOutSlowIn;
/// Deceleration curve (accelerate)
static const Curve curveAccelerate = Curves.decelerate;
/// Linear curve (no acceleration/deceleration)
static const Curve curveLinear = Curves.linear;
// ============================================
// STAGGER DELAYS (FOR LIST ANIMATIONS)
// ============================================
/// Default stagger delay for list items (50ms)
static const Duration staggerDelay = Duration(milliseconds: 50);
/// Quick stagger delay (30ms)
static const Duration staggerDelayFast = Duration(milliseconds: 30);
/// Slow stagger delay (100ms)
static const Duration staggerDelaySlow = Duration(milliseconds: 100);
/// Stagger delay in milliseconds
static const int staggerDelayMs = 50;
// ============================================
// SCALE ANIMATION CONSTANTS
// ============================================
/// Normal scale (1.0)
static const double scaleNormal = 1.0;
/// Hover/Light scale (1.02)
static const double scaleHover = 1.02;
/// Pressed/Active scale (0.98)
static const double scalePressed = 0.98;
/// Animation scale (0.9)
static const double scaleAnimation = 0.9;
// ============================================
// OFFSET ANIMATION CONSTANTS
// ============================================
/// Slide offset - Small (8px)
static const Offset offsetSm = Offset(0, 8);
/// Slide offset - Medium (16px)
static const Offset offsetMd = Offset(0, 16);
/// Slide offset - Large (20px)
static const Offset offsetLg = Offset(0, 20);
/// Slide offset - Extra large (32px)
static const Offset offsetXl = Offset(0, 32);
/// Floating offset - Up (10px)
static const Offset offsetFloating = Offset(0, -10);
// ============================================
// OPACITY ANIMATION CONSTANTS
// ============================================
/// Full opacity
static const double opacityFull = 1.0;
/// Half opacity
static const double opacityHalf = 0.5;
/// Subtle opacity (70%)
static const double opacitySubtle = 0.7;
/// Dim opacity (50%)
static const double opacityDim = 0.5;
/// Fade out opacity (30%)
static const double opacityFadeOut = 0.3;
/// Invisible opacity (0%)
static const double opacityInvisible = 0.0;
// ============================================
// ANIMATION PRESETS
// ============================================
/// Scale animation preset (button press) - note: CurvedAnimation cannot be const
// Use this pattern in your widgets instead:
// CurvedAnimation(parent: controller, curve: Curves.easeInOut)
// ============================================
// ROTATION ANIMATION CONSTANTS
// ============================================
/// Full rotation (360 degrees)
static const double rotationFull = 1.0;
/// Half rotation (180 degrees)
static const double rotationHalf = 0.5;
/// Quarter rotation (90 degrees)
static const double rotationQuarter = 0.25;
// ============================================
// UTILITY METHODS
// ============================================
/// Get duration based on animation intensity
static Duration getDuration(AnimationIntensity intensity) {
switch (intensity) {
case AnimationIntensity.fast:
return durationFast;
case AnimationIntensity.normal:
return durationNormal;
case AnimationIntensity.slow:
return durationSlow;
case AnimationIntensity.xSlow:
return durationXSlow;
}
}
/// Get curve based on animation type
static Curve getCurve(AnimationType type) {
switch (type) {
case AnimationType.easeIn:
return curveEaseIn;
case AnimationType.easeOut:
return curveEaseOut;
case AnimationType.easeInOut:
return curveEaseInOut;
case AnimationType.elastic:
return curveElastic;
case AnimationType.bounce:
return curveBounce;
case AnimationType.linear:
return curveLinear;
}
}
/// Get stagger delay for list index
static Duration getStaggerDelay(int index, {bool fast = false}) {
final baseDelay = fast ? staggerDelayFast : staggerDelay;
return Duration(
milliseconds: baseDelay.inMilliseconds * index,
);
}
/// Get scale value based on interaction state
static double getScale(InteractionState state) {
switch (state) {
case InteractionState.normal:
return scaleNormal;
case InteractionState.hover:
return scaleHover;
case InteractionState.pressed:
return scalePressed;
}
}
}
/// Animation intensity levels
enum AnimationIntensity {
/// 200ms - Quick interactions
fast,
/// 300ms - Standard animations
normal,
/// 500ms - Prominent animations
slow,
/// 800ms - Slow, attention-grabbing animations
xSlow,
}
/// Animation types/curves
enum AnimationType {
/// Ease In curve
easeIn,
/// Ease Out curve
easeOut,
/// Ease In Out curve
easeInOut,
/// Elastic/bouncy curve
elastic,
/// Bounce curve
bounce,
/// Linear curve
linear,
}
/// Interaction states for animation
enum InteractionState {
/// Normal/default state
normal,
/// Hover state
hover,
/// Pressed/active state
pressed,
}