app_theme.dart 2.83 KB
import 'package:flutter/material.dart';
import 'app_colors_extension.dart';

/// Class managing the Application ThemeData for both Light and Dark themes.
/// Automatically hooks up our custom Figma colors system as a ThemeExtension.
class AppTheme {
  AppTheme._();

  /// The standard light theme configuration.
  static ThemeData get lightTheme {
    final colors = AppColorsExtension.light();
    return ThemeData(
      useMaterial3: true,
      brightness: Brightness.light,
      primaryColor: colors.primary,
      scaffoldBackgroundColor: colors.backgroundLight,
      
      // Clean modern AppBar theme using Figma colors
      appBarTheme: AppBarTheme(
        backgroundColor: colors.backgroundLight,
        elevation: 0,
        centerTitle: true,
        iconTheme: IconThemeData(color: colors.textPrimary),
        actionsIconTheme: IconThemeData(color: colors.textPrimary),
        titleTextStyle: TextStyle(
          color: colors.textPrimary,
          fontSize: 18,
          fontWeight: FontWeight.w600,
        ),
      ),

      // Configure default ColorScheme using Figma specs
      colorScheme: ColorScheme.light(
        primary: colors.primary,
        secondary: colors.primary,
        surface: colors.backgroundLight,
        onPrimary: Colors.white,
        onSecondary: Colors.white,
        onSurface: colors.textPrimary,
        outline: colors.border,
      ),

      // Register the custom theme extension
      extensions: [
        colors,
      ],
    );
  }

  /// Initial dark theme configuration.
  static ThemeData get darkTheme {
    final colors = AppColorsExtension.dark();
    return ThemeData(
      useMaterial3: true,
      brightness: Brightness.dark,
      primaryColor: colors.primary,
      scaffoldBackgroundColor: colors.backgroundLight,
      
      appBarTheme: AppBarTheme(
        backgroundColor: colors.backgroundLight,
        elevation: 0,
        centerTitle: true,
        iconTheme: IconThemeData(color: colors.textPrimary),
        actionsIconTheme: IconThemeData(color: colors.textPrimary),
        titleTextStyle: TextStyle(
          color: colors.textPrimary,
          fontSize: 18,
          fontWeight: FontWeight.w600,
        ),
      ),

      colorScheme: ColorScheme.dark(
        primary: colors.primary,
        secondary: colors.primary,
        surface: colors.backgroundLight,
        onPrimary: Colors.white,
        onSecondary: Colors.white,
        onSurface: colors.textPrimary,
        outline: colors.border,
      ),

      extensions: [
        colors,
      ],
    );
  }
}

/// Helper extension to easily access custom Figma colors inside widgets
/// by using `context.colors.<semanticName>` instead of verbose lookups.
extension AppThemeContextExtension on BuildContext {
  AppColorsExtension get colors => Theme.of(this).extension<AppColorsExtension>()!;
  ThemeData get theme => Theme.of(this);
}