refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -5,15 +5,15 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:social_app/core/chat/agent_stage.dart';
|
||||
import '../../../../core/network/api_exception.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/router/app_route_observer.dart';
|
||||
import '../../../../app/router/app_routes.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../chat/presentation/bloc/agent_stage.dart';
|
||||
import '../../../../data/repositories/inbox_repository.dart';
|
||||
import '../../../chat/presentation/bloc/chat_bloc.dart';
|
||||
import '../../../messages/data/inbox_api.dart';
|
||||
import '../../data/voice_recorder.dart';
|
||||
import '../controllers/home_keyboard_inset_calculator.dart';
|
||||
import '../controllers/home_message_viewport_controller.dart';
|
||||
@@ -47,9 +47,6 @@ const homeConversationStageKey = ValueKey('home_conversation_stage');
|
||||
const homeBottomInputStackKey = ValueKey('home_bottom_input_stack');
|
||||
const homeEmptyStateAmbientKey = ValueKey('home_empty_state_ambient');
|
||||
|
||||
/// Color constants.
|
||||
const _chatBgColor = AppColors.slate50;
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
final VoiceRecorder? voiceRecorder;
|
||||
final Future<String> Function(String filePath)? onTranscribeAudio;
|
||||
@@ -76,7 +73,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
late final ChatBloc _chatBloc;
|
||||
late final VoiceRecorder _voiceRecorder;
|
||||
late final InboxApi _inboxApi;
|
||||
late final InboxRepository _inboxRepository;
|
||||
late final Future<String> Function(String filePath) _transcribeAudio;
|
||||
late final AnimationController _listeningAnimationController;
|
||||
bool _isRecording = false;
|
||||
@@ -113,7 +110,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
_chatBloc = context.read<ChatBloc>();
|
||||
}
|
||||
_voiceRecorder = widget.voiceRecorder ?? RecordVoiceRecorder();
|
||||
_inboxApi = sl<InboxApi>();
|
||||
_inboxRepository = sl<InboxRepository>();
|
||||
_transcribeAudio =
|
||||
widget.onTranscribeAudio ?? _chatBloc.transcribeAudioFile;
|
||||
_listeningAnimationController = AnimationController(
|
||||
@@ -132,7 +129,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
|
||||
Future<void> _loadUnreadCount() async {
|
||||
try {
|
||||
final messages = await _inboxApi.getMessages(isRead: false);
|
||||
final messages = await _inboxRepository.getMessages(isRead: false);
|
||||
if (mounted) {
|
||||
setState(() => _unreadCount = messages.length);
|
||||
}
|
||||
@@ -220,8 +217,10 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
_previousIsLoadingHistory = state.isLoadingHistory;
|
||||
},
|
||||
builder: (context, state) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: _chatBgColor,
|
||||
backgroundColor: colorScheme.surface,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: SafeArea(
|
||||
maintainBottomViewPadding: true,
|
||||
@@ -688,6 +687,8 @@ class _HomeEmptyStateAmbient extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Center(
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
@@ -701,9 +702,9 @@ class _HomeEmptyStateAmbient extends StatelessWidget {
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
AppColors.homeBackgroundGlowSoft.withValues(alpha: 0.12),
|
||||
AppColors.homeBackgroundGlow.withValues(alpha: 0.08),
|
||||
AppColors.homeBackgroundGlowSoft.withValues(alpha: 0.12),
|
||||
colorScheme.primaryContainer.withValues(alpha: 0.12),
|
||||
colorScheme.primary.withValues(alpha: 0.08),
|
||||
colorScheme.primaryContainer.withValues(alpha: 0.12),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user