refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
abstract class SessionController {
|
||||
Future<void> logoutAndWaitUnauthenticated();
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
class CacheEntry<T> {
|
||||
final T value;
|
||||
final DateTime fetchedAt;
|
||||
|
||||
const CacheEntry({required this.value, required this.fetchedAt});
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'hybrid_cache_store.dart';
|
||||
|
||||
class CacheInvalidator {
|
||||
final HybridCacheStore? _store;
|
||||
final Set<String> _invalidated = <String>{};
|
||||
|
||||
CacheInvalidator({HybridCacheStore? store}) : _store = store;
|
||||
|
||||
void invalidate(String key) {
|
||||
_invalidated.add(key);
|
||||
final store = _store;
|
||||
if (store != null) {
|
||||
unawaited(store.remove(key));
|
||||
}
|
||||
}
|
||||
|
||||
void invalidateCalendarDay(DateTime date) {
|
||||
final month = '${date.year}-${date.month.toString().padLeft(2, '0')}';
|
||||
final day = '$month-${date.day.toString().padLeft(2, '0')}';
|
||||
invalidate('calendar:day:$day');
|
||||
invalidate('calendar:month:$month');
|
||||
}
|
||||
|
||||
bool wasInvalidated(String key) => _invalidated.contains(key);
|
||||
}
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
class CacheKey {
|
||||
final String value;
|
||||
|
||||
const CacheKey(this.value);
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other is CacheKey && other.value == value);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => value.hashCode;
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
class CacheDecision {
|
||||
final bool canUseCached;
|
||||
final bool shouldRefreshInBackground;
|
||||
final bool mustBlockForNetwork;
|
||||
|
||||
const CacheDecision({
|
||||
required this.canUseCached,
|
||||
required this.shouldRefreshInBackground,
|
||||
required this.mustBlockForNetwork,
|
||||
});
|
||||
}
|
||||
|
||||
class CachePolicy {
|
||||
final Duration softTtl;
|
||||
final Duration hardTtl;
|
||||
final Duration minRefreshInterval;
|
||||
|
||||
const CachePolicy({
|
||||
required this.softTtl,
|
||||
required this.hardTtl,
|
||||
this.minRefreshInterval = Duration.zero,
|
||||
});
|
||||
|
||||
CacheDecision evaluate({required DateTime now, required DateTime fetchedAt}) {
|
||||
final age = now.difference(fetchedAt);
|
||||
if (age >= hardTtl) {
|
||||
return const CacheDecision(
|
||||
canUseCached: false,
|
||||
shouldRefreshInBackground: false,
|
||||
mustBlockForNetwork: true,
|
||||
);
|
||||
}
|
||||
|
||||
if (age >= softTtl) {
|
||||
final shouldRefresh = age >= minRefreshInterval;
|
||||
return CacheDecision(
|
||||
canUseCached: true,
|
||||
shouldRefreshInBackground: shouldRefresh,
|
||||
mustBlockForNetwork: false,
|
||||
);
|
||||
}
|
||||
|
||||
return const CacheDecision(
|
||||
canUseCached: true,
|
||||
shouldRefreshInBackground: false,
|
||||
mustBlockForNetwork: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class CacheRefreshCoordinator with WidgetsBindingObserver {
|
||||
final Duration minInterval;
|
||||
final void Function() onRefresh;
|
||||
final DateTime Function() now;
|
||||
|
||||
DateTime? _lastRefreshedAt;
|
||||
|
||||
CacheRefreshCoordinator({
|
||||
required this.minInterval,
|
||||
required this.onRefresh,
|
||||
DateTime Function()? now,
|
||||
}) : now = now ?? DateTime.now;
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state != AppLifecycleState.resumed) {
|
||||
return;
|
||||
}
|
||||
final current = now();
|
||||
final last = _lastRefreshedAt;
|
||||
if (last != null && current.difference(last) < minInterval) {
|
||||
return;
|
||||
}
|
||||
_lastRefreshedAt = current;
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
abstract class CacheStore {
|
||||
Future<T?> read<T>(String key);
|
||||
Future<void> write<T>(String key, T value);
|
||||
Future<void> remove(String key);
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
import 'memory_cache_store.dart';
|
||||
import 'persistent_cache_store.dart';
|
||||
|
||||
class HybridCacheStore {
|
||||
final MemoryCacheStore memory;
|
||||
final PersistentCacheStore persistent;
|
||||
final Map<String, Future<dynamic>> _inflight = <String, Future<dynamic>>{};
|
||||
|
||||
HybridCacheStore({required this.memory, required this.persistent});
|
||||
|
||||
Future<T?> read<T>(String key) async {
|
||||
final memoryValue = await memory.read<T>(key);
|
||||
if (memoryValue != null) {
|
||||
return memoryValue;
|
||||
}
|
||||
final persistentValue = await persistent.read<T>(key);
|
||||
if (persistentValue != null) {
|
||||
await memory.write(key, persistentValue);
|
||||
}
|
||||
return persistentValue;
|
||||
}
|
||||
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
await memory.write<T>(key, value);
|
||||
await persistent.write<T>(key, value);
|
||||
}
|
||||
|
||||
Future<void> remove(String key) async {
|
||||
await memory.remove(key);
|
||||
await persistent.remove(key);
|
||||
}
|
||||
|
||||
Future<T> getOrLoad<T>(String key, {required Future<T> Function() loader}) {
|
||||
final running = _inflight[key];
|
||||
if (running != null) {
|
||||
return running.then((value) => value as T);
|
||||
}
|
||||
|
||||
final future = () async {
|
||||
final cached = await read<T>(key);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
final loaded = await loader();
|
||||
await write<T>(key, loaded);
|
||||
return loaded;
|
||||
}();
|
||||
|
||||
_inflight[key] = future;
|
||||
return future.whenComplete(() {
|
||||
_inflight.remove(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import 'cache_store.dart';
|
||||
|
||||
class MemoryCacheStore implements CacheStore {
|
||||
final Map<String, Object?> _values = <String, Object?>{};
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final value = _values[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
_values[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
_values.remove(key);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import 'cache_store.dart';
|
||||
|
||||
class PersistentCacheStore implements CacheStore {
|
||||
final Map<String, Object?> _values = <String, Object?>{};
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final value = _values[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
_values[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
_values.remove(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import '../l10n/l10n.dart';
|
||||
|
||||
enum AgentStage { routing, execution, memory }
|
||||
|
||||
AgentStage? stageFromStepName(String value) {
|
||||
switch (value) {
|
||||
case 'router':
|
||||
return AgentStage.routing;
|
||||
case 'worker':
|
||||
return AgentStage.execution;
|
||||
case 'memory':
|
||||
return AgentStage.memory;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String stageLabel(AgentStage? stage) {
|
||||
return switch (stage) {
|
||||
AgentStage.routing => L10n.current.agentStageRouting,
|
||||
AgentStage.execution => L10n.current.agentStageExecution,
|
||||
AgentStage.memory => L10n.current.agentStageMemory,
|
||||
null => L10n.current.agentStageProcessing,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
enum ChatItemType { message, toolCall, toolResult }
|
||||
|
||||
enum MessageSender { user, ai }
|
||||
|
||||
enum ToolCallStatus { pending, executing, completed, error }
|
||||
|
||||
abstract class ChatListItem {
|
||||
String get id;
|
||||
DateTime get timestamp;
|
||||
ChatItemType get type;
|
||||
MessageSender get sender;
|
||||
}
|
||||
|
||||
class TextMessageItem extends ChatListItem {
|
||||
@override
|
||||
final String id;
|
||||
final String content;
|
||||
@override
|
||||
final DateTime timestamp;
|
||||
@override
|
||||
final MessageSender sender;
|
||||
final bool isStreaming;
|
||||
final List<Map<String, dynamic>> attachments;
|
||||
|
||||
TextMessageItem({
|
||||
required this.id,
|
||||
required this.content,
|
||||
required this.timestamp,
|
||||
required this.sender,
|
||||
this.isStreaming = false,
|
||||
this.attachments = const [],
|
||||
});
|
||||
|
||||
@override
|
||||
ChatItemType get type => ChatItemType.message;
|
||||
|
||||
TextMessageItem copyWith({
|
||||
String? id,
|
||||
String? content,
|
||||
DateTime? timestamp,
|
||||
MessageSender? sender,
|
||||
bool? isStreaming,
|
||||
List<Map<String, dynamic>>? attachments,
|
||||
}) => TextMessageItem(
|
||||
id: id ?? this.id,
|
||||
content: content ?? this.content,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
sender: sender ?? this.sender,
|
||||
isStreaming: isStreaming ?? this.isStreaming,
|
||||
attachments: attachments ?? this.attachments,
|
||||
);
|
||||
}
|
||||
|
||||
class ToolCallItem extends ChatListItem {
|
||||
@override
|
||||
final String id;
|
||||
final String callId;
|
||||
final String toolName;
|
||||
final Map<String, dynamic> args;
|
||||
final ToolCallStatus status;
|
||||
final String? errorMessage;
|
||||
@override
|
||||
final DateTime timestamp;
|
||||
@override
|
||||
final MessageSender sender;
|
||||
|
||||
ToolCallItem({
|
||||
required this.id,
|
||||
required this.callId,
|
||||
required this.toolName,
|
||||
required this.args,
|
||||
required this.status,
|
||||
this.errorMessage,
|
||||
required this.timestamp,
|
||||
required this.sender,
|
||||
});
|
||||
|
||||
@override
|
||||
ChatItemType get type => ChatItemType.toolCall;
|
||||
|
||||
ToolCallItem copyWith({
|
||||
String? id,
|
||||
String? callId,
|
||||
String? toolName,
|
||||
Map<String, dynamic>? args,
|
||||
ToolCallStatus? status,
|
||||
String? errorMessage,
|
||||
DateTime? timestamp,
|
||||
MessageSender? sender,
|
||||
}) => ToolCallItem(
|
||||
id: id ?? this.id,
|
||||
callId: callId ?? this.callId,
|
||||
toolName: toolName ?? this.toolName,
|
||||
args: args ?? this.args,
|
||||
status: status ?? this.status,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
sender: sender ?? this.sender,
|
||||
);
|
||||
}
|
||||
|
||||
class ToolResultItem extends ChatListItem {
|
||||
@override
|
||||
final String id;
|
||||
final String callId;
|
||||
final Map<String, dynamic> uiSchema;
|
||||
@override
|
||||
final DateTime timestamp;
|
||||
@override
|
||||
final MessageSender sender;
|
||||
|
||||
ToolResultItem({
|
||||
required this.id,
|
||||
required this.callId,
|
||||
required this.uiSchema,
|
||||
required this.timestamp,
|
||||
required this.sender,
|
||||
});
|
||||
|
||||
@override
|
||||
ChatItemType get type => ChatItemType.toolResult;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import 'agent_stage.dart';
|
||||
import 'chat_list_item.dart';
|
||||
|
||||
abstract class ChatOrchestratorState {
|
||||
List<ChatListItem> get items;
|
||||
bool get isSending;
|
||||
bool get isWaitingFirstToken;
|
||||
bool get isStreaming;
|
||||
bool get isCancelling;
|
||||
bool get isLoadingHistory;
|
||||
String? get currentMessageId;
|
||||
String? get error;
|
||||
DateTime? get oldestLoadedDate;
|
||||
bool get hasEarlierHistory;
|
||||
AgentStage? get currentStage;
|
||||
bool get isLoading;
|
||||
}
|
||||
|
||||
abstract class ChatOrchestrator {
|
||||
ChatOrchestratorState get state;
|
||||
Stream<ChatOrchestratorState> get stream;
|
||||
|
||||
Future<void> sendMessage(String content, {List<XFile>? images});
|
||||
Future<void> loadHistory();
|
||||
Future<void> loadMoreHistory();
|
||||
Future<String> transcribeAudioFile(String filePath);
|
||||
Future<bool> cancelCurrentRun();
|
||||
void clearError();
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class Env {
|
||||
static String get apiUrl {
|
||||
final backendUrl = const String.fromEnvironment('BACKEND_URL');
|
||||
@@ -11,4 +13,14 @@ class Env {
|
||||
}
|
||||
return 'http://localhost:5775';
|
||||
}
|
||||
|
||||
static String version = '0.1.0';
|
||||
static int build = 1;
|
||||
|
||||
static Future<void> init() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
version = info.version;
|
||||
final buildStr = info.buildNumber.isEmpty ? '1' : info.buildNumber;
|
||||
build = int.tryParse(buildStr) ?? 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class AppConstants {
|
||||
static String version = '0.1.0';
|
||||
static int build = 1;
|
||||
|
||||
static Future<void> init() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
version = info.version;
|
||||
final buildStr = info.buildNumber.isEmpty ? '1' : info.buildNumber;
|
||||
build = int.tryParse(buildStr) ?? 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../data/models/reminder_payload.dart';
|
||||
|
||||
class AppPreferences {
|
||||
static const String _pendingNotificationsKey =
|
||||
'calendar_reminder_pending_notification_responses_v1';
|
||||
static const String _pendingNotificationPayloadKey =
|
||||
'pending_notification_payload';
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
AppPreferences(this._prefs);
|
||||
|
||||
List<PendingNotificationResponse> get pendingNotifications {
|
||||
final list = _prefs.getStringList(_pendingNotificationsKey) ?? [];
|
||||
return list
|
||||
.map(_decodePendingNotification)
|
||||
.whereType<PendingNotificationResponse>()
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<void> setPendingNotifications(
|
||||
List<PendingNotificationResponse> value,
|
||||
) {
|
||||
return _prefs.setStringList(
|
||||
_pendingNotificationsKey,
|
||||
value.map(_encodePendingNotification).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> clearPendingNotifications() {
|
||||
return _prefs.remove(_pendingNotificationsKey);
|
||||
}
|
||||
|
||||
ReminderPayload? get pendingNotificationPayload {
|
||||
final raw = _prefs.getString(_pendingNotificationPayloadKey);
|
||||
if (raw == null || raw.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final json = Map<String, dynamic>.from(jsonDecode(raw) as Map);
|
||||
return ReminderPayload.fromJson(json);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setPendingNotificationPayload(ReminderPayload payload) {
|
||||
return _prefs.setString(
|
||||
_pendingNotificationPayloadKey,
|
||||
jsonEncode(payload.toJson()),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> clearPendingNotificationPayload() {
|
||||
return _prefs.remove(_pendingNotificationPayloadKey);
|
||||
}
|
||||
|
||||
static String _encodePendingNotification(
|
||||
PendingNotificationResponse response,
|
||||
) {
|
||||
return jsonEncode({
|
||||
'id': response.id,
|
||||
'actionId': response.actionId,
|
||||
'payload': response.payload,
|
||||
'type': response.notificationResponseType.index,
|
||||
'input': response.input,
|
||||
});
|
||||
}
|
||||
|
||||
static PendingNotificationResponse? _decodePendingNotification(String raw) {
|
||||
try {
|
||||
final parsed = Map<String, dynamic>.from(jsonDecode(raw) as Map);
|
||||
final id = parsed['id'] as int?;
|
||||
final actionId = parsed['actionId'] as String?;
|
||||
final payload = parsed['payload'] as String?;
|
||||
final typeIndex = (parsed['type'] as int?) ?? 0;
|
||||
final input = parsed['input'] as String?;
|
||||
final type = NotificationResponseType.values[typeIndex.clamp(0, 1)];
|
||||
return NotificationResponse(
|
||||
id: id,
|
||||
actionId: actionId,
|
||||
payload: payload,
|
||||
input: input,
|
||||
notificationResponseType: type,
|
||||
);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef PendingNotificationResponse = NotificationResponse;
|
||||
@@ -4,50 +4,130 @@ import 'design_tokens.dart';
|
||||
class AppTheme {
|
||||
AppTheme._();
|
||||
|
||||
static ThemeData get light => ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
scaffoldBackgroundColor: AppColors.background,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: AppColors.primary,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
fontFamily: 'Inter',
|
||||
appBarTheme: const AppBarTheme(
|
||||
backgroundColor: AppColors.background,
|
||||
foregroundColor: AppColors.slate900,
|
||||
elevation: 0,
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: AppColors.primaryForeground,
|
||||
static ThemeData get light => _buildTheme(Brightness.light);
|
||||
static ThemeData get dark => _buildTheme(Brightness.dark);
|
||||
|
||||
static ThemeData _buildTheme(Brightness brightness) {
|
||||
final ColorScheme colorScheme;
|
||||
if (brightness == Brightness.dark) {
|
||||
colorScheme = ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: const Color(0xFF60A5FA),
|
||||
onPrimary: const Color(0xFFFFFFFF),
|
||||
primaryContainer: const Color(0xFF1E3A5F),
|
||||
onPrimaryContainer: const Color(0xFFBFDBFE),
|
||||
secondary: const Color(0xFF93C5FD),
|
||||
onSecondary: const Color(0xFF0F172A),
|
||||
secondaryContainer: const Color(0xFF1E293B),
|
||||
onSecondaryContainer: const Color(0xFFBFDBFE),
|
||||
tertiary: const Color(0xFFC4B5FD),
|
||||
onTertiary: const Color(0xFF0F172A),
|
||||
tertiaryContainer: const Color(0xFF4C1D95),
|
||||
onTertiaryContainer: const Color(0xFFE9D5FF),
|
||||
error: const Color(0xFFD14343),
|
||||
onError: const Color(0xFFFFFFFF),
|
||||
errorContainer: const Color(0xFF7F1D1D),
|
||||
onErrorContainer: const Color(0xFFFEE2E2),
|
||||
surface: const Color(0xFF0F172A),
|
||||
onSurface: const Color(0xFFE2E8F0),
|
||||
surfaceContainerLowest: const Color(0xFF0F172A),
|
||||
surfaceContainerLow: const Color(0xFF1E293B),
|
||||
surfaceContainer: const Color(0xFF334155),
|
||||
surfaceContainerHigh: const Color(0xFF475569),
|
||||
surfaceContainerHighest: const Color(0xFF64748B),
|
||||
onSurfaceVariant: const Color(0xFF94A3B8),
|
||||
outline: const Color(0xFF64748B),
|
||||
outlineVariant: const Color(0xFF475569),
|
||||
shadow: Colors.black,
|
||||
scrim: Colors.black,
|
||||
inverseSurface: const Color(0xFFE2E8F0),
|
||||
onInverseSurface: const Color(0xFF1E293B),
|
||||
inversePrimary: const Color(0xFF2563EB),
|
||||
);
|
||||
} else {
|
||||
colorScheme = ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: const Color(0xFF3B82F6),
|
||||
onPrimary: const Color(0xFFFAFAFA),
|
||||
primaryContainer: const Color(0xFFDBEAFE),
|
||||
onPrimaryContainer: const Color(0xFF0F172A),
|
||||
secondary: const Color(0xFF2563EB),
|
||||
onSecondary: const Color(0xFFFFFFFF),
|
||||
secondaryContainer: const Color(0xFFDBEAFE),
|
||||
onSecondaryContainer: const Color(0xFF1E293B),
|
||||
tertiary: const Color(0xFF8B5CF6),
|
||||
onTertiary: const Color(0xFFFFFFFF),
|
||||
tertiaryContainer: const Color(0xFFF5F3FF),
|
||||
onTertiaryContainer: const Color(0xFF0F172A),
|
||||
error: const Color(0xFFEF4444),
|
||||
onError: const Color(0xFFFFFFFF),
|
||||
errorContainer: const Color(0xFFFEE2E2),
|
||||
onErrorContainer: const Color(0xFF7F1D1D),
|
||||
surface: const Color(0xFFFFFFFF),
|
||||
onSurface: const Color(0xFF0F172A),
|
||||
surfaceContainerLowest: const Color(0xFFFFFFFF),
|
||||
surfaceContainerLow: const Color(0xFFF8FAFC),
|
||||
surfaceContainer: const Color(0xFFF1F5F9),
|
||||
surfaceContainerHigh: const Color(0xFFE2E8F0),
|
||||
surfaceContainerHighest: const Color(0xFFCBD5E1),
|
||||
onSurfaceVariant: const Color(0xFF475569),
|
||||
outline: const Color(0xFF94A3B8),
|
||||
outlineVariant: const Color(0xFFCBD5E1),
|
||||
shadow: const Color(0xFF0F172A),
|
||||
scrim: const Color(0xFF0F172A),
|
||||
inverseSurface: const Color(0xFF1E293B),
|
||||
onInverseSurface: const Color(0xFFF1F5F9),
|
||||
inversePrimary: const Color(0xFF60A5FA),
|
||||
);
|
||||
}
|
||||
|
||||
final themeExtension = brightness == Brightness.dark
|
||||
? AppColorPalette.dark
|
||||
: AppColorPalette.light;
|
||||
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: brightness,
|
||||
colorScheme: colorScheme,
|
||||
scaffoldBackgroundColor: colorScheme.surface,
|
||||
fontFamily: 'Inter',
|
||||
extensions: [themeExtension],
|
||||
appBarTheme: AppBarTheme(
|
||||
backgroundColor: colorScheme.surface,
|
||||
foregroundColor: colorScheme.onSurface,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colorScheme.primary,
|
||||
foregroundColor: colorScheme.onPrimary,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: AppColors.background,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: const BorderSide(color: AppColors.input),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: colorScheme.surface,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 10,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: BorderSide(color: colorScheme.primary),
|
||||
),
|
||||
hintStyle: TextStyle(color: colorScheme.onSurfaceVariant, fontSize: 14),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: const BorderSide(color: AppColors.input),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
borderSide: const BorderSide(color: AppColors.input),
|
||||
),
|
||||
hintStyle: const TextStyle(
|
||||
color: AppColors.mutedForeground,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,170 +1,146 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppColors {
|
||||
AppColors._();
|
||||
class AppColorPalette extends ThemeExtension<AppColorPalette> {
|
||||
final List<Color> eventPresetColors;
|
||||
final List<Color> avatarColors;
|
||||
final Color g1Text, g1Divider, g1Border;
|
||||
final Color g2Text, g2Divider, g2Border;
|
||||
final Color g3Text, g3Divider, g3Border;
|
||||
final Color eventDefault;
|
||||
final Color eventArchived;
|
||||
|
||||
static const primary = Color(0xFF171717);
|
||||
static const primaryForeground = Color(0xFFFAFAFA);
|
||||
static const background = Color(0xFFFAFAFA);
|
||||
static const foreground = Color(0xFF0A0A0A);
|
||||
static const mutedForeground = Color(0xFF737373);
|
||||
static const input = Color(0xFFE5E5E5);
|
||||
static const border = Color(0xFFE5E5E5);
|
||||
static const white = Color(0xFFFFFFFF);
|
||||
static const card = Color(0xFFFAFAFA);
|
||||
const AppColorPalette({
|
||||
required this.eventPresetColors,
|
||||
required this.avatarColors,
|
||||
required this.g1Text,
|
||||
required this.g1Divider,
|
||||
required this.g1Border,
|
||||
required this.g2Text,
|
||||
required this.g2Divider,
|
||||
required this.g2Border,
|
||||
required this.g3Text,
|
||||
required this.g3Divider,
|
||||
required this.g3Border,
|
||||
required this.eventDefault,
|
||||
required this.eventArchived,
|
||||
});
|
||||
|
||||
static const slate900 = Color(0xFF0F172A);
|
||||
static const slate800 = Color(0xFF1E293B);
|
||||
static const slate700 = Color(0xFF334155);
|
||||
static const slate600 = Color(0xFF475569);
|
||||
static const slate500 = Color(0xFF64748B);
|
||||
static const slate400 = Color(0xFF94A3B8);
|
||||
static const slate300 = Color(0xFFCBD5E1);
|
||||
static const slate200 = Color(0xFFE2E8F0);
|
||||
static const slate100 = Color(0xFFF1F5F9);
|
||||
static const slate50 = Color(0xFFF8FAFC);
|
||||
static const light = AppColorPalette(
|
||||
eventPresetColors: [
|
||||
Color(0xFF3B82F6),
|
||||
Color(0xFF8B5CF6),
|
||||
Color(0xFF10B981),
|
||||
Color(0xFFF59E0B),
|
||||
Color(0xFFEF4444),
|
||||
],
|
||||
avatarColors: [
|
||||
Color(0xFF3B82F6),
|
||||
Color(0xFF7C3AED),
|
||||
Color(0xFF2563EB),
|
||||
Color(0xFF2D6CDF),
|
||||
Color(0xFF8B5CF6),
|
||||
],
|
||||
g1Text: Color(0xFFB91C1C),
|
||||
g1Divider: Color(0xFFFEE2E2),
|
||||
g1Border: Color(0xFFF3C6C6),
|
||||
g2Text: Color(0xFFB45309),
|
||||
g2Divider: Color(0xFFFFEDD5),
|
||||
g2Border: Color(0xFFFDE2B8),
|
||||
g3Text: Color(0xFF1D4ED8),
|
||||
g3Divider: Color(0xFFEAF3FF),
|
||||
g3Border: Color(0xFFCFE1FB),
|
||||
eventDefault: Color(0xFF3B82F6),
|
||||
eventArchived: Color(0xFF64748B),
|
||||
);
|
||||
|
||||
static const blue600 = Color(0xFF2563EB);
|
||||
static const blue500 = Color(0xFF3B82F6);
|
||||
static const blue400 = Color(0xFF60A5FA);
|
||||
static const blue300 = Color(0xFF93C5FD);
|
||||
static const blue200 = Color(0xFFBFDBFE);
|
||||
static const blue100 = Color(0xFFDBEAFE);
|
||||
static const blue50 = Color(0xFFEFF6FF);
|
||||
static const dark = AppColorPalette(
|
||||
eventPresetColors: [
|
||||
Color(0xFF60A5FA),
|
||||
Color(0xFFA78BFA),
|
||||
Color(0xFF34D399),
|
||||
Color(0xFFFBBF24),
|
||||
Color(0xFFF87171),
|
||||
],
|
||||
avatarColors: [
|
||||
Color(0xFF60A5FA),
|
||||
Color(0xFFA78BFA),
|
||||
Color(0xFF3B82F6),
|
||||
Color(0xFF60A5FA),
|
||||
Color(0xFF818CF8),
|
||||
],
|
||||
g1Text: Color(0xFFFCA5A5),
|
||||
g1Divider: Color(0xFF7F1D1D),
|
||||
g1Border: Color(0xFFB91C1C),
|
||||
g2Text: Color(0xFFFCD34D),
|
||||
g2Divider: Color(0xFF78350F),
|
||||
g2Border: Color(0xFFD97706),
|
||||
g3Text: Color(0xFF93C5FD),
|
||||
g3Divider: Color(0xFF1E3A8A),
|
||||
g3Border: Color(0xFF2563EB),
|
||||
eventDefault: Color(0xFF60A5FA),
|
||||
eventArchived: Color(0xFF94A3B8),
|
||||
);
|
||||
|
||||
static const red600 = Color(0xFFDC2626);
|
||||
static const red500 = Color(0xFFEF4444);
|
||||
static const red400 = Color(0xFFD14343);
|
||||
@override
|
||||
AppColorPalette copyWith({
|
||||
List<Color>? eventPresetColors,
|
||||
List<Color>? avatarColors,
|
||||
Color? g1Text,
|
||||
Color? g1Divider,
|
||||
Color? g1Border,
|
||||
Color? g2Text,
|
||||
Color? g2Divider,
|
||||
Color? g2Border,
|
||||
Color? g3Text,
|
||||
Color? g3Divider,
|
||||
Color? g3Border,
|
||||
Color? eventDefault,
|
||||
Color? eventArchived,
|
||||
}) {
|
||||
return AppColorPalette(
|
||||
eventPresetColors: eventPresetColors ?? this.eventPresetColors,
|
||||
avatarColors: avatarColors ?? this.avatarColors,
|
||||
g1Text: g1Text ?? this.g1Text,
|
||||
g1Divider: g1Divider ?? this.g1Divider,
|
||||
g1Border: g1Border ?? this.g1Border,
|
||||
g2Text: g2Text ?? this.g2Text,
|
||||
g2Divider: g2Divider ?? this.g2Divider,
|
||||
g2Border: g2Border ?? this.g2Border,
|
||||
g3Text: g3Text ?? this.g3Text,
|
||||
g3Divider: g3Divider ?? this.g3Divider,
|
||||
g3Border: g3Border ?? this.g3Border,
|
||||
eventDefault: eventDefault ?? this.eventDefault,
|
||||
eventArchived: eventArchived ?? this.eventArchived,
|
||||
);
|
||||
}
|
||||
|
||||
static const surfaceSecondary = Color(0xFFF8FAFC);
|
||||
static const surfaceTertiary = Color(0xFFF8FAFF);
|
||||
static const surfaceInfo = Color(0xFFEAF3FF);
|
||||
static const surfaceInfoLight = Color(0xFFF3F7FF);
|
||||
|
||||
static const borderSecondary = Color(0xFFE2E8F0);
|
||||
static const borderTertiary = Color(0xFFDCE5F4);
|
||||
static const borderQuaternary = Color(0xFFCFE1FB);
|
||||
|
||||
static const textSecondary = Color(0xFF475569);
|
||||
|
||||
static const success = Color(0xFF10B981);
|
||||
static const warning = Color(0xFFF59E0B);
|
||||
static const error = Color(0xFFEF4444);
|
||||
|
||||
static const messageBg = Color(0xFFF8FAFC);
|
||||
static const messageCardBg = Color(0xFFFFFFFF);
|
||||
static const messageTagBg = Color(0xFFEAF3FF);
|
||||
static const messageBtnWrap = Color(0xFFF8FAFF);
|
||||
static const messageBtnBorder = Color(0xFFDEE7F6);
|
||||
static const messageCardBorder = Color(0xFFE3EAF6);
|
||||
static const messageCalendarBg = Color(0xFFEEF4FF);
|
||||
static const messageArrowColor = Color(0xFF9CAFC8);
|
||||
static const messageTipBg = Color(0xFFF8FAFF);
|
||||
static const messageTipBorder = Color(0xFFDCE6F4);
|
||||
static const messageRejectBorder = Color(0xFFF1C9CE);
|
||||
static const messageAcceptBorder = Color(0xFFCFE1FB);
|
||||
static const messagePlaceholder = Color(0xFF9AAAC1);
|
||||
static const messageInputBorder = Color(0xFFDCE5F4);
|
||||
static const messageReasonBorder = Color(0xFFE6ECF7);
|
||||
|
||||
static const amber600 = Color(0xFFD97706);
|
||||
static const amber500 = Color(0xFFF59E0B);
|
||||
|
||||
static const emerald600 = Color(0xFF059669);
|
||||
static const emerald500 = Color(0xFF10B981);
|
||||
|
||||
static const violet600 = Color(0xFF7C3AED);
|
||||
static const violet500 = Color(0xFF8B5CF6);
|
||||
|
||||
static const warningBackground = Color(0xFFFEF3C7);
|
||||
static const warningText = Color(0xFF92400E);
|
||||
|
||||
static const appIconRing = Color(0xFFE8F3FF);
|
||||
static const appIconBorder = Color(0xFFC7DDFB);
|
||||
static const appTitle = Color(0xFF1E293B);
|
||||
|
||||
static const authBackgroundTop = Color(0xFFF4F8FF);
|
||||
static const authBackgroundBottom = Color(0xFFF8FAFC);
|
||||
static const authBackgroundOrb = Color(0xFFDCEBFF);
|
||||
static const authCardBackground = Color(0xFFFCFDFE);
|
||||
static const authCardBorder = Color(0xFFE5ECF6);
|
||||
static const authCardHighlight = Color(0xFFFFFFFF);
|
||||
static const authSectionBackground = Color(0xFFF7FAFE);
|
||||
static const authSectionBorder = Color(0xFFE4EBF5);
|
||||
static const authInputBackground = Color(0xFFF6F9FD);
|
||||
static const authInputBorder = Color(0xFFD9E4F1);
|
||||
static const authInputFocus = Color(0xFF8EB8F3);
|
||||
static const authInputIcon = Color(0xFF8A9BB2);
|
||||
static const authPrimaryButton = Color(0xFF2F6FD6);
|
||||
static const authPrimaryButtonPressed = Color(0xFF245FC0);
|
||||
static const authPrimaryButtonDisabled = Color(0xFFD9E3F2);
|
||||
static const authPrimaryButtonText = Color(0xFFF8FBFF);
|
||||
static const authSecondaryButtonBackground = Color(0xFFF4F8FF);
|
||||
static const authSecondaryButtonBorder = Color(0xFFD8E4F6);
|
||||
static const authSecondaryButtonText = Color(0xFF315D9C);
|
||||
static const authLinkText = Color(0xFF356CC8);
|
||||
static const authLinkMuted = Color(0xFF70839E);
|
||||
|
||||
static const homeBackgroundTop = Color(0xFFF5F9FF);
|
||||
static const homeBackgroundBottom = Color(0xFFF7FAFE);
|
||||
static const homeBackgroundGlow = Color(0xFFDCEBFF);
|
||||
static const homeBackgroundGlowSoft = Color(0xFFF1F6FF);
|
||||
static const homeToolbarSurface = Color(0xF2FFFFFF);
|
||||
static const homeToolbarBorder = Color(0xFFD9E6F7);
|
||||
static const homeConversationSurface = Color(0xBFFFFFFF);
|
||||
static const homeConversationBorder = Color(0xFFDDE8F6);
|
||||
static const homeComposerShell = Color(0xFDFCFEFF);
|
||||
static const homeComposerInner = Color(0xFFF7FAFE);
|
||||
static const homeComposerBorder = Color(0xFFD7E3F3);
|
||||
static const homeComposerAccent = Color(0xFFEAF3FF);
|
||||
static const homeAttachmentSurface = Color(0xFFF3F7FD);
|
||||
|
||||
static const feedbackInfoSurface = Color(0xFFF3F8FF);
|
||||
static const feedbackInfoBorder = Color(0xFFD6E5FB);
|
||||
static const feedbackInfoIcon = Color(0xFF2D6CDF);
|
||||
static const feedbackInfoText = Color(0xFF26476F);
|
||||
|
||||
static const feedbackSuccessSurface = Color(0xFFF1FBF6);
|
||||
static const feedbackSuccessBorder = Color(0xFFCDECD9);
|
||||
static const feedbackSuccessIcon = Color(0xFF129268);
|
||||
static const feedbackSuccessText = Color(0xFF1E5A46);
|
||||
|
||||
static const feedbackWarningSurface = Color(0xFFFFF8ED);
|
||||
static const feedbackWarningBorder = Color(0xFFF4DFC0);
|
||||
static const feedbackWarningIcon = Color(0xFFD68A18);
|
||||
static const feedbackWarningText = Color(0xFF7A5821);
|
||||
|
||||
static const feedbackErrorSurface = Color(0xFFFFF4F3);
|
||||
static const feedbackErrorBorder = Color(0xFFF1D2D0);
|
||||
static const feedbackErrorIcon = Color(0xFFD14F4B);
|
||||
static const feedbackErrorText = Color(0xFF7E3735);
|
||||
|
||||
static const todoBg = Color(0xFFF8FAFC);
|
||||
static const todoCardBg = Color(0xFFFFFFFF);
|
||||
|
||||
static const g1Text = Color(0xFFB91C1C);
|
||||
static const g1Divider = Color(0xFFFEE2E2);
|
||||
static const g1Border = Color(0xFFF3C6C6);
|
||||
|
||||
static const g2Text = Color(0xFFB45309);
|
||||
static const g2Divider = Color(0xFFFFEDD5);
|
||||
static const g2Border = Color(0xFFFDE2B8);
|
||||
|
||||
static const g3Text = Color(0xFF1D4ED8);
|
||||
static const g3Divider = Color(0xFFEAF3FF);
|
||||
static const g3Border = Color(0xFFCFE1FB);
|
||||
|
||||
static const todoDetailCardBorder = Color(0xFFDCE5F4);
|
||||
static const todoEventBorder1 = Color(0xFFDCE5F4);
|
||||
static const todoEventBorder2 = Color(0xFFDCC8FF);
|
||||
static const todoEventBorder3 = Color(0xFFCFE1FB);
|
||||
|
||||
static const todoToggleBg = Color(0xFFFDFEFF);
|
||||
static const todoToggleBorder = Color(0xFFDCE6F4);
|
||||
static const todoToggleActiveBg = Color(0xFFD6E6FF);
|
||||
static const todoToggleActiveBorder = Color(0xFFBFD6FB);
|
||||
static const todoHomeBtnBg = Color(0xFFE6EEFB);
|
||||
static const todoHomeBtnBorder = Color(0xFFC9D8EE);
|
||||
@override
|
||||
AppColorPalette lerp(ThemeExtension<AppColorPalette>? other, double t) {
|
||||
if (other is! AppColorPalette) return this;
|
||||
return AppColorPalette(
|
||||
eventPresetColors: eventPresetColors
|
||||
.asMap()
|
||||
.entries
|
||||
.map((e) => Color.lerp(e.value, other.eventPresetColors[e.key], t)!)
|
||||
.toList(),
|
||||
avatarColors: avatarColors
|
||||
.asMap()
|
||||
.entries
|
||||
.map((e) => Color.lerp(e.value, other.avatarColors[e.key], t)!)
|
||||
.toList(),
|
||||
g1Text: Color.lerp(g1Text, other.g1Text, t)!,
|
||||
g1Divider: Color.lerp(g1Divider, other.g1Divider, t)!,
|
||||
g1Border: Color.lerp(g1Border, other.g1Border, t)!,
|
||||
g2Text: Color.lerp(g2Text, other.g2Text, t)!,
|
||||
g2Divider: Color.lerp(g2Divider, other.g2Divider, t)!,
|
||||
g2Border: Color.lerp(g2Border, other.g2Border, t)!,
|
||||
g3Text: Color.lerp(g3Text, other.g3Text, t)!,
|
||||
g3Divider: Color.lerp(g3Divider, other.g3Divider, t)!,
|
||||
g3Border: Color.lerp(g3Border, other.g3Border, t)!,
|
||||
eventDefault: Color.lerp(eventDefault, other.eventDefault, t)!,
|
||||
eventArchived: Color.lerp(eventArchived, other.eventArchived, t)!,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppSpacing {
|
||||
|
||||
Reference in New Issue
Block a user