feat: Phase 1 foundation - core infrastructure and navigation
Clean Architecture structure: - core/config - Environment configuration - core/theme - Material 3 theming with FlexColorScheme - core/error - Typed exception hierarchy - core/api - Dio HTTP clients with interceptors - core/auth - Authentication state management - routing - go_router with shell navigation - shared/layouts - Adaptive scaffold Dependencies added: - flutter_riverpod, riverpod_annotation, riverpod_generator - freezed, freezed_annotation, json_serializable - dio, go_router, shared_preferences - flex_color_scheme, flutter_adaptive_scaffold Features: - Responsive navigation (rail on desktop, bottom on mobile) - Dashboard placeholder with welcome card - Theme switching infrastructure - API client ready for Core API and Tatlock API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import 'package:flex_color_scheme/flex_color_scheme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Application theme configuration using Material 3 and FlexColorScheme.
|
||||
class AppTheme {
|
||||
AppTheme._();
|
||||
|
||||
/// Light theme
|
||||
static ThemeData get light => FlexThemeData.light(
|
||||
scheme: FlexScheme.aquaBlue,
|
||||
surfaceMode: FlexSurfaceMode.levelSurfacesLowScaffold,
|
||||
blendLevel: 9,
|
||||
subThemesData: const FlexSubThemesData(
|
||||
blendOnLevel: 10,
|
||||
blendOnColors: false,
|
||||
useM2StyleDividerInM3: true,
|
||||
inputDecoratorBorderType: FlexInputBorderType.outline,
|
||||
inputDecoratorRadius: 8.0,
|
||||
chipRadius: 8.0,
|
||||
dialogRadius: 16.0,
|
||||
cardRadius: 12.0,
|
||||
),
|
||||
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
||||
useMaterial3: true,
|
||||
fontFamily: null, // Use system font
|
||||
);
|
||||
|
||||
/// Dark theme
|
||||
static ThemeData get dark => FlexThemeData.dark(
|
||||
scheme: FlexScheme.aquaBlue,
|
||||
surfaceMode: FlexSurfaceMode.levelSurfacesLowScaffold,
|
||||
blendLevel: 15,
|
||||
subThemesData: const FlexSubThemesData(
|
||||
blendOnLevel: 20,
|
||||
useM2StyleDividerInM3: true,
|
||||
inputDecoratorBorderType: FlexInputBorderType.outline,
|
||||
inputDecoratorRadius: 8.0,
|
||||
chipRadius: 8.0,
|
||||
dialogRadius: 16.0,
|
||||
cardRadius: 12.0,
|
||||
),
|
||||
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
||||
useMaterial3: true,
|
||||
fontFamily: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// Semantic color extensions for domain-specific colors.
|
||||
extension SemanticColors on ColorScheme {
|
||||
/// Success state color (green)
|
||||
Color get success => brightness == Brightness.light
|
||||
? const Color(0xFF2E7D32)
|
||||
: const Color(0xFF81C784);
|
||||
|
||||
/// Warning state color (orange)
|
||||
Color get warning => brightness == Brightness.light
|
||||
? const Color(0xFFF57C00)
|
||||
: const Color(0xFFFFB74D);
|
||||
|
||||
/// Info state color (blue)
|
||||
Color get info => brightness == Brightness.light
|
||||
? const Color(0xFF1976D2)
|
||||
: const Color(0xFF64B5F6);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
part 'theme_provider.g.dart';
|
||||
|
||||
/// User's theme preference setting.
|
||||
enum ThemeSetting {
|
||||
/// Follow system preference
|
||||
system,
|
||||
|
||||
/// Always light mode
|
||||
light,
|
||||
|
||||
/// Always dark mode
|
||||
dark,
|
||||
}
|
||||
|
||||
/// Provider for theme setting state.
|
||||
@riverpod
|
||||
class ThemeNotifier extends _$ThemeNotifier {
|
||||
static const _prefsKey = 'theme_setting';
|
||||
|
||||
@override
|
||||
ThemeSetting build() {
|
||||
_loadSavedSetting();
|
||||
return ThemeSetting.system;
|
||||
}
|
||||
|
||||
Future<void> _loadSavedSetting() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final value = prefs.getString(_prefsKey);
|
||||
if (value != null) {
|
||||
try {
|
||||
state = ThemeSetting.values.byName(value);
|
||||
} catch (_) {
|
||||
// Invalid value, keep default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Update theme setting and persist to storage.
|
||||
Future<void> setSetting(ThemeSetting setting) async {
|
||||
state = setting;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_prefsKey, setting.name);
|
||||
}
|
||||
|
||||
/// Get the ThemeMode for MaterialApp.
|
||||
ThemeMode get themeMode => switch (state) {
|
||||
ThemeSetting.system => ThemeMode.system,
|
||||
ThemeSetting.light => ThemeMode.light,
|
||||
ThemeSetting.dark => ThemeMode.dark,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user