refactor: enhance theme and error handling across the application

- Updated error handling in EnhancedErrorService to utilize context for color tokens, improving theme consistency.
- Refactored various components to use context-aware shadow and color properties, enhancing visual coherence.
- Replaced hardcoded color values with dynamic tokens in multiple widgets, ensuring better adaptability to theme changes.
- Improved overall code maintainability by centralizing theme-related logic and reducing direct dependencies on static theme values.
This commit is contained in:
cogwheel0
2025-10-03 00:12:25 +05:30
parent ad3834b43e
commit 1ea85d5ed1
21 changed files with 1009 additions and 454 deletions

View File

@@ -116,13 +116,7 @@ class _ConnectionIssuePageState extends ConsumerState<ConnectionIssuePage> {
decoration: BoxDecoration(
color: context.conduitTheme.surfaceContainerHighest,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 18,
offset: const Offset(0, 12),
),
],
boxShadow: ConduitShadows.high(context),
),
child: Icon(
Platform.isIOS

View File

@@ -214,7 +214,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.modal),
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: const OnboardingSheet(),
),
@@ -735,7 +735,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
color: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.messageBubble,
boxShadow: ConduitShadows.messageBubble(context),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -1202,7 +1202,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
drawerEnableOpenDragGesture: true,
drawerDragStartBehavior: DragStartBehavior.start,
drawerEdgeDragWidth: MediaQuery.of(context).size.width * 0.75,
drawerScrimColor: Colors.black.withValues(alpha: 0.32),
drawerScrimColor: context.colorTokens.overlayStrong,
drawer: Drawer(
width: (MediaQuery.of(context).size.width * 0.80).clamp(
280.0,
@@ -1638,7 +1638,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
borderRadius: BorderRadius.circular(
AppBorderRadius.floatingButton,
),
boxShadow: ConduitShadows.button,
boxShadow: ConduitShadows.button(context),
),
child: SizedBox(
width: TouchTarget.button,
@@ -1838,7 +1838,7 @@ class _ModelSelectorSheetState extends ConsumerState<_ModelSelectorSheet> {
color: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: ModalSheetSafeArea(
padding: const EdgeInsets.symmetric(
@@ -2043,7 +2043,7 @@ class _ModelSelectorSheetState extends ConsumerState<_ModelSelectorSheet> {
: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: isSelected ? ConduitShadows.card : null,
boxShadow: isSelected ? ConduitShadows.card(context) : null,
),
child: Padding(
padding: const EdgeInsets.symmetric(
@@ -2327,7 +2327,7 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> {
color: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
padding: const EdgeInsets.all(Spacing.bottomSheetPadding),
child: SafeArea(
@@ -2435,7 +2435,7 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> {
top: Radius.circular(AppBorderRadius.bottomSheet),
),
border: Border.all(color: context.conduitTheme.dividerColor, width: 1),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: SafeArea(
top: false,
@@ -2940,7 +2940,7 @@ class _SelectableMessageWrapper extends StatelessWidget {
decoration: BoxDecoration(
color: context.conduitTheme.buttonPrimary,
shape: BoxShape.circle,
boxShadow: ConduitShadows.medium,
boxShadow: ConduitShadows.medium(context),
),
child: Icon(
Icons.check,

View File

@@ -572,8 +572,12 @@ class FullScreenImageViewer extends ConsumerWidget {
}
}
final tokens = context.colorTokens;
final background = tokens.neutralTone10;
final iconColor = tokens.neutralOnSurface;
return Scaffold(
backgroundColor: Colors.black,
backgroundColor: background,
body: Stack(
children: [
Center(
@@ -595,14 +599,14 @@ class FullScreenImageViewer extends ConsumerWidget {
IconButton(
icon: Icon(
Platform.isIOS ? Icons.ios_share : Icons.share_outlined,
color: Colors.white,
color: iconColor,
size: 26,
),
onPressed: () => _shareImage(context, ref),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.close, color: Colors.white, size: 28),
icon: Icon(Icons.close, color: iconColor, size: 28),
onPressed: () => Navigator.of(context).pop(),
),
],

View File

@@ -1281,7 +1281,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
alpha: Alpha.buttonPressed,
),
borderRadius: BorderRadius.circular(radius),
boxShadow: ConduitShadows.button,
boxShadow: ConduitShadows.button(context),
),
child: Center(
child: Icon(
@@ -1696,7 +1696,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
color: theme.dividerColor,
width: BorderWidth.thin,
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: ModalSheetSafeArea(
padding: const EdgeInsets.fromLTRB(
@@ -1810,7 +1810,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
color: background,
borderRadius: BorderRadius.circular(AppBorderRadius.input),
border: Border.all(color: borderColor, width: BorderWidth.thin),
boxShadow: value ? ConduitShadows.low : const [],
boxShadow: value ? ConduitShadows.low(context) : const [],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -1897,7 +1897,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
color: background,
borderRadius: BorderRadius.circular(AppBorderRadius.input),
border: Border.all(color: borderColor, width: BorderWidth.thin),
boxShadow: selected ? ConduitShadows.low : const [],
boxShadow: selected ? ConduitShadows.low(context) : const [],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,

View File

@@ -563,13 +563,7 @@ class _UserMessageBubbleState extends ConsumerState<UserMessageBubble>
context.conduitTheme.chatBubbleUserBorder,
width: BorderWidth.regular,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
boxShadow: ConduitShadows.small(context),
),
child: _isEditing
? Focus(

View File

@@ -1362,7 +1362,7 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
color: theme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.card,
boxShadow: ConduitShadows.card(context),
),
child: Row(
children: [
@@ -1631,7 +1631,9 @@ class _ConversationTile extends StatelessWidget {
final Color borderColor = selected
? theme.buttonPrimary.withValues(alpha: 0.7)
: theme.surfaceContainerHighest.withValues(alpha: 0.40);
final List<BoxShadow> shadow = selected ? ConduitShadows.low : const [];
final List<BoxShadow> shadow = selected
? ConduitShadows.low(context)
: const [];
Color? overlayForStates(Set<WidgetState> states) {
if (states.contains(WidgetState.pressed)) {

View File

@@ -85,7 +85,7 @@ class _OnboardingSheetState extends ConsumerState<OnboardingSheet> {
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.modal),
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: SafeArea(
child: Padding(
@@ -228,7 +228,7 @@ class _IllustratedPage extends StatelessWidget {
decoration: BoxDecoration(
color: context.conduitTheme.buttonPrimary,
borderRadius: BorderRadius.circular(AppBorderRadius.avatar),
boxShadow: ConduitShadows.glow,
boxShadow: ConduitShadows.glow(context),
),
child: Icon(page.icon, color: context.conduitTheme.textInverse),
).animate().scale(duration: AnimationDuration.fast),
@@ -304,7 +304,7 @@ class _IllustratedPage extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
color: context.conduitTheme.buttonPrimary.withValues(alpha: alpha),
boxShadow: ConduitShadows.glow,
boxShadow: ConduitShadows.glow(context),
),
);
}

View File

@@ -562,7 +562,7 @@ class AppCustomizationPage extends ConsumerWidget {
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.modal),
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: SafeArea(
top: false,

View File

@@ -336,7 +336,7 @@ class ProfilePage extends ConsumerWidget {
color: accent.withValues(alpha: 0.18),
width: BorderWidth.thin,
),
boxShadow: ConduitShadows.medium,
boxShadow: ConduitShadows.medium(context),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -347,7 +347,7 @@ class ProfilePage extends ConsumerWidget {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppBorderRadius.avatar),
boxShadow: ConduitShadows.high,
boxShadow: ConduitShadows.high(context),
),
child: UserAvatar(
size: IconSize.avatar,
@@ -973,7 +973,7 @@ class _DefaultModelBottomSheetState
color: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.modal,
boxShadow: ConduitShadows.modal(context),
),
child: ModalSheetSafeArea(
padding: const EdgeInsets.symmetric(
@@ -1234,7 +1234,7 @@ class _DefaultModelBottomSheetState
: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: isSelected ? ConduitShadows.card : null,
boxShadow: isSelected ? ConduitShadows.card(context) : null,
),
child: Padding(
padding: const EdgeInsets.symmetric(