refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -73,6 +73,7 @@ class MessageComposer extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return KeyedSubtree(
|
||||
key: messageComposerContainerKey,
|
||||
child: Container(
|
||||
@@ -82,19 +83,19 @@ class MessageComposer extends StatelessWidget {
|
||||
vertical: AppSpacing.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.homeComposerShell,
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(AppRadius.xxl),
|
||||
border: Border.all(color: AppColors.homeComposerBorder),
|
||||
boxShadow: const [
|
||||
border: Border.all(color: colorScheme.outlineVariant),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.slate200,
|
||||
color: colorScheme.surfaceContainerHighest.withValues(alpha: 1),
|
||||
blurRadius: AppRadius.lg,
|
||||
offset: Offset(AppSpacing.none, AppSpacing.sm),
|
||||
offset: const Offset(AppSpacing.none, AppSpacing.sm),
|
||||
),
|
||||
BoxShadow(
|
||||
color: AppColors.white,
|
||||
color: colorScheme.surface,
|
||||
blurRadius: AppRadius.md,
|
||||
offset: Offset(AppSpacing.none, -AppSpacing.xs),
|
||||
offset: const Offset(AppSpacing.none, -AppSpacing.xs),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -114,30 +115,30 @@ class MessageComposer extends StatelessWidget {
|
||||
icon: Icon(
|
||||
LucideIcons.plus,
|
||||
size: iconSize,
|
||||
color: AppColors.slate500,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Expanded(child: _buildCenterArea()),
|
||||
Expanded(child: _buildCenterArea(colorScheme)),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
IconButton(
|
||||
key: messageComposerRightButtonKey,
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: onTapRightAction,
|
||||
icon: _isTranscribing
|
||||
? const AppLoadingIndicator(
|
||||
? AppLoadingIndicator(
|
||||
variant: AppLoadingVariant.inline,
|
||||
size: AppSpacing.lg,
|
||||
strokeWidth: AppSpacing.xs / 2,
|
||||
color: AppColors.blue600,
|
||||
trackColor: AppColors.blue100,
|
||||
color: colorScheme.primary,
|
||||
trackColor: colorScheme.primaryContainer,
|
||||
)
|
||||
: Icon(
|
||||
_resolveRightIcon(),
|
||||
size: iconSize,
|
||||
color: _resolveRightIconColor(),
|
||||
color: _resolveRightIconColor(colorScheme),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -147,7 +148,7 @@ class MessageComposer extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCenterArea() {
|
||||
Widget _buildCenterArea(ColorScheme colorScheme) {
|
||||
return SizedBox(
|
||||
height: composerMinHeight,
|
||||
child: AnimatedSwitcher(
|
||||
@@ -155,7 +156,10 @@ class MessageComposer extends StatelessWidget {
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.easeOut,
|
||||
child: _isHoldMode
|
||||
? _buildHoldToSpeakArea(key: const ValueKey('hold_mode'))
|
||||
? _buildHoldToSpeakArea(
|
||||
key: const ValueKey('hold_mode'),
|
||||
colorScheme: colorScheme,
|
||||
)
|
||||
: _buildTextInputArea(key: const ValueKey('text_mode')),
|
||||
),
|
||||
);
|
||||
@@ -165,7 +169,10 @@ class MessageComposer extends StatelessWidget {
|
||||
return SizedBox(key: key, height: composerMinHeight, child: textInputChild);
|
||||
}
|
||||
|
||||
Widget _buildHoldToSpeakArea({required Key key}) {
|
||||
Widget _buildHoldToSpeakArea({
|
||||
required Key key,
|
||||
required ColorScheme colorScheme,
|
||||
}) {
|
||||
return RawGestureDetector(
|
||||
key: messageComposerHoldAreaKey,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
@@ -176,8 +183,8 @@ class MessageComposer extends StatelessWidget {
|
||||
duration: const Duration(milliseconds: _holdActivateDurationMs),
|
||||
),
|
||||
(instance) {
|
||||
instance.onLongPressStart = (_) => onHoldToSpeakStart();
|
||||
instance.onLongPressEnd = (_) => onHoldToSpeakEnd();
|
||||
instance.onLongPressStart = (details) => onHoldToSpeakStart();
|
||||
instance.onLongPressEnd = (details) => onHoldToSpeakEnd();
|
||||
instance.onLongPressMoveUpdate = onHoldToSpeakMoveUpdate;
|
||||
instance.onLongPressCancel = onHoldToSpeakCancel;
|
||||
},
|
||||
@@ -188,12 +195,12 @@ class MessageComposer extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
height: composerMinHeight,
|
||||
alignment: Alignment.center,
|
||||
child: _buildHoldToSpeakContent(),
|
||||
child: _buildHoldToSpeakContent(colorScheme),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHoldToSpeakContent() {
|
||||
Widget _buildHoldToSpeakContent(ColorScheme colorScheme) {
|
||||
final l10n = L10n.current;
|
||||
final resolvedRecordingText =
|
||||
recordingText ?? l10n.homeRecordingReleaseSend;
|
||||
@@ -208,7 +215,7 @@ class MessageComposer extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
resolvedRecordingText,
|
||||
style: const TextStyle(color: AppColors.slate700),
|
||||
style: TextStyle(color: colorScheme.onSurface),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -220,13 +227,13 @@ class MessageComposer extends StatelessWidget {
|
||||
const SizedBox(height: AppSpacing.xs),
|
||||
Text(
|
||||
resolvedRecordingText,
|
||||
style: const TextStyle(color: AppColors.slate700),
|
||||
style: TextStyle(color: colorScheme.onSurface),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.xs),
|
||||
Text(
|
||||
resolvedRecordingHintText,
|
||||
key: messageComposerRecordingHintKey,
|
||||
style: const TextStyle(color: AppColors.slate500),
|
||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -237,7 +244,7 @@ class MessageComposer extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
resolvedTranscribingText,
|
||||
style: const TextStyle(color: AppColors.slate500),
|
||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -246,7 +253,7 @@ class MessageComposer extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
resolvedHoldToSpeakText,
|
||||
style: const TextStyle(color: AppColors.slate500),
|
||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -261,10 +268,10 @@ class MessageComposer extends StatelessWidget {
|
||||
return _isHoldMode ? LucideIcons.keyboard : LucideIcons.mic;
|
||||
}
|
||||
|
||||
Color _resolveRightIconColor() {
|
||||
Color _resolveRightIconColor(ColorScheme colorScheme) {
|
||||
if (isWaitingAgent || hasMessage) {
|
||||
return AppColors.blue600;
|
||||
return colorScheme.primary;
|
||||
}
|
||||
return AppColors.slate500;
|
||||
return colorScheme.onSurfaceVariant;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user