refactor: navigation rehaul

This commit is contained in:
cogwheel0
2025-08-21 23:56:47 +05:30
parent b10051f687
commit 9f80b1e727
7 changed files with 1503 additions and 2284 deletions

View File

@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import '../../features/auth/views/connect_signin_page.dart'; import '../../features/auth/views/connect_signin_page.dart';
import '../../features/chat/views/chat_page.dart'; import '../../features/chat/views/chat_page.dart';
import '../../features/files/views/files_page.dart'; import '../../features/files/views/files_page.dart';
import '../../features/navigation/views/chats_list_page.dart';
import '../../features/profile/views/profile_page.dart'; import '../../features/profile/views/profile_page.dart';
import '../../shared/widgets/themed_dialogs.dart'; import '../../shared/widgets/themed_dialogs.dart';
@@ -92,10 +91,7 @@ class NavigationService {
return navigateTo(Routes.serverConnection); return navigateTo(Routes.serverConnection);
} }
/// Navigate to chats list // Chats list is now provided as a left drawer in ChatPage
static Future<void> navigateToChatsList() {
return navigateTo(Routes.chatsList);
}
/// Clear navigation stack (useful for logout) /// Clear navigation stack (useful for logout)
static void clearNavigationStack() { static void clearNavigationStack() {
@@ -138,9 +134,7 @@ class NavigationService {
page = const FilesPage(); page = const FilesPage();
break; break;
case Routes.chatsList: // chats list route removed (replaced by drawer)
page = const ChatsListPage();
break;
// Removed navigation drawer route // Removed navigation drawer route
@@ -161,5 +155,4 @@ class Routes {
static const String profile = '/profile'; static const String profile = '/profile';
static const String serverConnection = '/server-connection'; static const String serverConnection = '/server-connection';
static const String files = '/files'; static const String files = '/files';
static const String chatsList = '/chats-list';
} }

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../core/services/navigation_service.dart';
import '../../../core/widgets/error_boundary.dart'; import '../../../core/widgets/error_boundary.dart';
import '../../../shared/widgets/optimized_list.dart'; import '../../../shared/widgets/optimized_list.dart';
import '../../../shared/theme/theme_extensions.dart'; import '../../../shared/theme/theme_extensions.dart';
@@ -19,10 +18,10 @@ import '../widgets/assistant_message_widget.dart' as assistant;
import '../widgets/file_attachment_widget.dart'; import '../widgets/file_attachment_widget.dart';
import '../services/voice_input_service.dart'; import '../services/voice_input_service.dart';
import '../services/file_attachment_service.dart'; import '../services/file_attachment_service.dart';
import '../../navigation/views/chats_list_page.dart';
import '../../files/views/files_page.dart'; import '../../files/views/files_page.dart';
import '../../profile/views/profile_page.dart'; import '../../profile/views/profile_page.dart';
import '../../tools/providers/tools_providers.dart'; import '../../tools/providers/tools_providers.dart';
import '../../navigation/widgets/chats_drawer.dart';
import '../../../shared/widgets/offline_indicator.dart'; import '../../../shared/widgets/offline_indicator.dart';
import '../../../core/services/connectivity_service.dart'; import '../../../core/services/connectivity_service.dart';
import '../../../core/models/chat_message.dart'; import '../../../core/models/chat_message.dart';
@@ -463,47 +462,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
} }
} }
void _showChatsListOverlay() { // Replaced bottom-sheet chat list with left drawer (see ChatsDrawer)
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => Container(
height: MediaQuery.of(context).size.height * 0.9,
decoration: BoxDecoration(
color: context.conduitTheme.surfaceBackground,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.bottomSheet),
),
border: Border.all(
color: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.modal,
),
child: SafeArea(
top: false,
bottom: true,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Handle bar
Container(
width: 40,
height: 4,
margin: const EdgeInsets.symmetric(vertical: Spacing.sm),
decoration: BoxDecoration(
color: context.conduitTheme.dividerColor,
borderRadius: BorderRadius.circular(AppBorderRadius.xs),
),
),
Expanded(child: const ChatsListPage(isOverlay: true)),
],
),
),
),
);
}
void _showQuickAccessMenu() { void _showQuickAccessMenu() {
showModalBottomSheet( showModalBottomSheet(
@@ -1117,27 +1076,13 @@ class _ChatPageState extends ConsumerState<ChatPage> {
onPopInvokedWithResult: (bool didPop, Object? result) async { onPopInvokedWithResult: (bool didPop, Object? result) async {
if (didPop) return; if (didPop) return;
// Check if there's unsaved content // Auto-handle leaving without confirmation
final messages = ref.read(chatMessagesProvider); final messages = ref.read(chatMessagesProvider);
if (messages.isNotEmpty) {
// Check if currently streaming
final isStreaming = messages.any((msg) => msg.isStreaming); final isStreaming = messages.any((msg) => msg.isStreaming);
final shouldPop = await NavigationService.confirmNavigation(
title: 'Leave Chat?',
message: isStreaming
? 'The AI is still responding. Leave anyway?'
: 'Your conversation will be saved.',
confirmText: 'Leave',
cancelText: 'Stay',
);
if (shouldPop && context.mounted) {
// If streaming, stop it first
if (isStreaming) { if (isStreaming) {
ref.read(chatMessagesProvider.notifier).finishStreaming(); ref.read(chatMessagesProvider.notifier).finishStreaming();
} }
// Save the conversation before leaving
await _saveConversationBeforeLeaving(ref); await _saveConversationBeforeLeaving(ref);
if (context.mounted) { if (context.mounted) {
@@ -1148,18 +1093,17 @@ class _ChatPageState extends ConsumerState<ChatPage> {
SystemNavigator.pop(); SystemNavigator.pop();
} }
} }
}
} else if (context.mounted) {
final canPopNavigator = Navigator.of(context).canPop();
if (canPopNavigator) {
Navigator.of(context).pop();
} else {
SystemNavigator.pop();
}
}
}, },
child: Scaffold( child: Scaffold(
backgroundColor: context.conduitTheme.surfaceBackground, backgroundColor: context.conduitTheme.surfaceBackground,
// Left navigation drawer with draggable edge open
drawerEnableOpenDragGesture: true,
drawerEdgeDragWidth: 32,
drawer: Drawer(
width: (MediaQuery.of(context).size.width * 0.88).clamp(280.0, 420.0),
backgroundColor: context.conduitTheme.surfaceBackground,
child: const SafeArea(child: ChatsDrawer()),
),
appBar: AppBar( appBar: AppBar(
backgroundColor: context.conduitTheme.surfaceBackground, backgroundColor: context.conduitTheme.surfaceBackground,
elevation: Elevation.none, elevation: Elevation.none,
@@ -1176,9 +1120,11 @@ class _ChatPageState extends ConsumerState<ChatPage> {
), ),
onPressed: _clearSelection, onPressed: _clearSelection,
) )
: GestureDetector( : Builder(
builder: (ctx) => GestureDetector(
onTap: () { onTap: () {
_showChatsListOverlay(); // Open left drawer instead of bottom sheet
Scaffold.of(ctx).openDrawer();
}, },
onLongPress: () { onLongPress: () {
HapticFeedback.mediumImpact(); HapticFeedback.mediumImpact();
@@ -1195,6 +1141,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
), ),
), ),
), ),
),
title: _isSelectionMode title: _isSelectionMode
? Text( ? Text(
'${_selectedMessageIds.length} selected', '${_selectedMessageIds.length} selected',

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import '../../../shared/theme/theme_extensions.dart'; import '../../../shared/theme/theme_extensions.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -220,18 +221,17 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
), ),
border: Border( border: Border(
top: BorderSide( top: BorderSide(
color: context.conduitTheme.inputBorder, color: context.conduitTheme.dividerColor,
width: BorderWidth.regular, width: BorderWidth.regular,
), ),
left: BorderSide( left: BorderSide(
color: context.conduitTheme.inputBorder, color: context.conduitTheme.dividerColor,
width: BorderWidth.regular, width: BorderWidth.regular,
), ),
right: BorderSide( right: BorderSide(
color: context.conduitTheme.inputBorder, color: context.conduitTheme.dividerColor,
width: BorderWidth.regular, width: BorderWidth.regular,
), ),
// Removed bottom border to eliminate divider
), ),
boxShadow: ConduitShadows.input, boxShadow: ConduitShadows.input,
), ),
@@ -431,8 +431,18 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
if (isGenerating) { if (isGenerating) {
return Tooltip( return Tooltip(
message: 'Stop generating', message: 'Stop generating',
child: GestureDetector( child: Material(
onTap: stopGeneration, color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: BorderSide(color: context.conduitTheme.error, width: BorderWidth.regular),
),
child: InkWell(
borderRadius: BorderRadius.circular(radius),
onTap: () {
HapticFeedback.lightImpact();
stopGeneration();
},
child: Container( child: Container(
width: buttonSize, width: buttonSize,
height: buttonSize, height: buttonSize,
@@ -441,10 +451,6 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
alpha: Alpha.buttonPressed, alpha: Alpha.buttonPressed,
), ),
borderRadius: BorderRadius.circular(radius), borderRadius: BorderRadius.circular(radius),
border: Border.all(
color: context.conduitTheme.error,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.button, boxShadow: ConduitShadows.button,
), ),
child: Stack( child: Stack(
@@ -469,32 +475,42 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
), ),
), ),
), ),
),
); );
} }
// Default SEND variant // Default SEND variant
return Tooltip( return Tooltip(
message: enabled ? 'Send message' : 'Send', message: enabled ? 'Send message' : 'Send',
child: GestureDetector(
onTap: enabled ? _sendMessage : null,
child: Opacity( child: Opacity(
opacity: enabled ? Alpha.primary : Alpha.disabled, opacity: enabled ? Alpha.primary : Alpha.disabled,
child: IgnorePointer( child: IgnorePointer(
ignoring: !enabled, ignoring: !enabled,
child: Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: BorderSide(
color: enabled
? context.conduitTheme.cardBorder
: context.conduitTheme.cardBorder.withValues(alpha: Alpha.medium),
width: BorderWidth.regular,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(radius),
onTap: enabled
? () {
PlatformUtils.lightHaptic();
_sendMessage();
}
: null,
child: Container( child: Container(
width: buttonSize, width: buttonSize,
height: buttonSize, height: buttonSize,
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.conduitTheme.cardBackground, color: context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(radius), borderRadius: BorderRadius.circular(radius),
border: Border.all(
color: enabled
? context.conduitTheme.cardBorder
: context.conduitTheme.cardBorder.withValues(
alpha: Alpha.medium,
),
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.button, boxShadow: ConduitShadows.button,
), ),
child: Icon( child: Icon(
@@ -502,8 +518,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
size: IconSize.medium, size: IconSize.medium,
color: enabled color: enabled
? context.conduitTheme.textPrimary ? context.conduitTheme.textPrimary
: context.conduitTheme.textPrimary.withValues( : context.conduitTheme.textPrimary.withValues(alpha: Alpha.disabled),
alpha: Alpha.disabled,
), ),
), ),
), ),
@@ -522,8 +537,29 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
}) { }) {
return Tooltip( return Tooltip(
message: tooltip ?? '', message: tooltip ?? '',
child: GestureDetector( child: Material(
onTap: onTap, color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppBorderRadius.xl),
side: BorderSide(
color: isActive
? context.conduitTheme.textPrimary.withValues(
alpha: Alpha.buttonHover + Alpha.subtle,
)
: showBackground
? context.conduitTheme.cardBorder
: Colors.transparent,
width: BorderWidth.regular,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(AppBorderRadius.xl),
onTap: onTap == null
? null
: () {
HapticFeedback.selectionClick();
onTap();
},
child: Container( child: Container(
width: TouchTarget.comfortable, width: TouchTarget.comfortable,
height: TouchTarget.comfortable, height: TouchTarget.comfortable,
@@ -536,16 +572,6 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
? context.conduitTheme.cardBackground ? context.conduitTheme.cardBackground
: Colors.transparent, : Colors.transparent,
borderRadius: BorderRadius.circular(AppBorderRadius.xl), borderRadius: BorderRadius.circular(AppBorderRadius.xl),
border: Border.all(
color: isActive
? context.conduitTheme.textPrimary.withValues(
alpha: Alpha.buttonHover + Alpha.subtle,
)
: showBackground
? context.conduitTheme.cardBorder
: Colors.transparent,
width: BorderWidth.regular,
),
boxShadow: (isActive || showBackground) boxShadow: (isActive || showBackground)
? ConduitShadows.button ? ConduitShadows.button
: null, : null,
@@ -565,10 +591,11 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
), ),
), ),
), ),
); ));
} }
void _showAttachmentOptions() { void _showAttachmentOptions() {
HapticFeedback.selectionClick();
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@@ -578,6 +605,10 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
borderRadius: const BorderRadius.vertical( borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.bottomSheet), top: Radius.circular(AppBorderRadius.bottomSheet),
), ),
border: Border.all(
color: context.conduitTheme.dividerColor,
width: BorderWidth.regular,
),
boxShadow: ConduitShadows.modal, boxShadow: ConduitShadows.modal,
), ),
padding: const EdgeInsets.all(Spacing.bottomSheetPadding), padding: const EdgeInsets.all(Spacing.bottomSheetPadding),
@@ -599,34 +630,41 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
// Options grid // Options grid
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
_buildAttachmentOption( Expanded(
child: _buildAttachmentOption(
icon: Platform.isIOS ? CupertinoIcons.doc : Icons.attach_file, icon: Platform.isIOS ? CupertinoIcons.doc : Icons.attach_file,
label: 'File', label: 'File',
onTap: () { onTap: () {
HapticFeedback.lightImpact();
Navigator.pop(context); // Close modal Navigator.pop(context); // Close modal
widget.onFileAttachment?.call(); widget.onFileAttachment?.call();
}, },
), )),
_buildAttachmentOption( const SizedBox(width: Spacing.md),
Expanded(
child: _buildAttachmentOption(
icon: Platform.isIOS ? CupertinoIcons.photo : Icons.image, icon: Platform.isIOS ? CupertinoIcons.photo : Icons.image,
label: 'Photo', label: 'Photo',
onTap: () { onTap: () {
HapticFeedback.lightImpact();
Navigator.pop(context); // Close modal Navigator.pop(context); // Close modal
widget.onImageAttachment?.call(); widget.onImageAttachment?.call();
}, },
), )),
_buildAttachmentOption( const SizedBox(width: Spacing.md),
Expanded(
child: _buildAttachmentOption(
icon: Platform.isIOS icon: Platform.isIOS
? CupertinoIcons.camera ? CupertinoIcons.camera
: Icons.camera_alt, : Icons.camera_alt,
label: 'Camera', label: 'Camera',
onTap: () { onTap: () {
HapticFeedback.lightImpact();
Navigator.pop(context); // Close modal Navigator.pop(context); // Close modal
widget.onCameraCapture?.call(); widget.onCameraCapture?.call();
}, },
), )),
], ],
), ),
const SizedBox(height: Spacing.lg), const SizedBox(height: Spacing.lg),
@@ -637,6 +675,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
} }
void _showUnifiedToolsModal() { void _showUnifiedToolsModal() {
HapticFeedback.selectionClick();
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@@ -649,8 +688,16 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
required String label, required String label,
VoidCallback? onTap, VoidCallback? onTap,
}) { }) {
return GestureDetector( return Material(
onTap: onTap, color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppBorderRadius.lg),
onTap: onTap == null
? null
: () {
HapticFeedback.selectionClick();
onTap();
},
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@@ -658,20 +705,16 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
width: 64, width: 64,
height: 64, height: 64,
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.conduitTheme.textPrimary.withValues( color: context.conduitTheme.cardBackground,
alpha: Alpha.subtle,
),
borderRadius: BorderRadius.circular(AppBorderRadius.lg), borderRadius: BorderRadius.circular(AppBorderRadius.lg),
border: Border.all( border: Border.all(
color: context.conduitTheme.textPrimary.withValues( color: context.conduitTheme.cardBorder,
alpha: Alpha.subtle,
),
width: BorderWidth.regular, width: BorderWidth.regular,
), ),
), ),
child: Icon( child: Icon(
icon, icon,
color: context.conduitTheme.textPrimary, color: context.conduitTheme.iconPrimary,
size: IconSize.xl, size: IconSize.xl,
), ),
), ),
@@ -684,6 +727,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
), ),
], ],
), ),
),
); );
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../shared/theme/theme_extensions.dart'; import '../../../shared/theme/theme_extensions.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -797,7 +798,7 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
width: Spacing.xxl, width: Spacing.xxl,
height: Spacing.xs, height: Spacing.xs,
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.conduitTheme.dividerColor, color: context.conduitTheme.textPrimary.withValues(alpha: Alpha.medium),
borderRadius: BorderRadius.circular(AppBorderRadius.xs), borderRadius: BorderRadius.circular(AppBorderRadius.xs),
), ),
), ),
@@ -807,6 +808,11 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
padding: const EdgeInsets.only(bottom: Spacing.md), padding: const EdgeInsets.only(bottom: Spacing.md),
child: Row( child: Row(
children: [ children: [
Icon(
Platform.isIOS ? CupertinoIcons.cube : Icons.psychology,
color: context.conduitTheme.iconPrimary,
),
const SizedBox(width: Spacing.sm),
Expanded( Expanded(
child: Text( child: Text(
'Default Model', 'Default Model',
@@ -817,7 +823,10 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
), ),
), ),
TextButton( TextButton(
onPressed: () => Navigator.pop(context, _selectedModelId), onPressed: () {
HapticFeedback.lightImpact();
Navigator.pop(context, _selectedModelId);
},
child: Text( child: Text(
'Save', 'Save',
style: context.conduitTheme.bodyMedium?.copyWith( style: context.conduitTheme.bodyMedium?.copyWith(
@@ -837,7 +846,7 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
controller: _searchController, controller: _searchController,
style: TextStyle(color: context.conduitTheme.textPrimary), style: TextStyle(color: context.conduitTheme.textPrimary),
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search...', hintText: 'Search models...',
hintStyle: TextStyle( hintStyle: TextStyle(
color: context.conduitTheme.inputPlaceholder, color: context.conduitTheme.inputPlaceholder,
), ),
@@ -874,6 +883,41 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
), ),
), ),
// Section header (cohesive with Chats Drawer)
Padding(
padding: const EdgeInsets.only(bottom: Spacing.sm),
child: Row(
children: [
Text(
'Available Models',
style: AppTypography.bodySmallStyle.copyWith(
fontWeight: FontWeight.w600,
color: context.conduitTheme.textSecondary,
letterSpacing: 0.2,
),
),
const SizedBox(width: Spacing.xs),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: context.conduitTheme.surfaceBackground.withValues(alpha: 0.6),
borderRadius: BorderRadius.circular(AppBorderRadius.xs),
border: Border.all(
color: context.conduitTheme.dividerColor,
width: BorderWidth.thin,
),
),
child: Text(
'${_filteredModels.length}',
style: AppTypography.bodySmallStyle.copyWith(
color: context.conduitTheme.textSecondary,
),
),
),
],
),
),
const SizedBox(height: Spacing.sm), const SizedBox(height: Spacing.sm),
// Models list // Models list
@@ -919,6 +963,7 @@ class _DefaultModelBottomSheetState extends ConsumerState<_DefaultModelBottomShe
isSelected: isSelected, isSelected: isSelected,
isAutoSelect: isAutoSelect, isAutoSelect: isAutoSelect,
onTap: () { onTap: () {
HapticFeedback.selectionClick();
setState(() { setState(() {
_selectedModelId = isAutoSelect ? 'auto-select' : model.id; _selectedModelId = isAutoSelect ? 'auto-select' : model.id;
}); });

View File

@@ -25,39 +25,42 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
final selectedToolIds = ref.watch(selectedToolIdsProvider); final selectedToolIds = ref.watch(selectedToolIdsProvider);
final toolsAsync = ref.watch(toolsListProvider); final toolsAsync = ref.watch(toolsListProvider);
final theme = context.conduitTheme;
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.conduitTheme.surfaceBackground, color: theme.surfaceBackground,
borderRadius: const BorderRadius.vertical( borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.bottomSheet), top: Radius.circular(AppBorderRadius.bottomSheet),
), ),
border: Border.all(color: theme.dividerColor, width: BorderWidth.regular),
boxShadow: ConduitShadows.modal, boxShadow: ConduitShadows.modal,
), ),
child: SafeArea(
top: false,
bottom: true,
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.8,
),
child: SingleChildScrollView(
padding: const EdgeInsets.all(Spacing.bottomSheetPadding), padding: const EdgeInsets.all(Spacing.bottomSheetPadding),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
// Handle bar // Handle bar
Container( Center(
child: Container(
width: 40, width: 40,
height: 4, height: 4,
decoration: BoxDecoration( decoration: BoxDecoration(
color: context.conduitTheme.textPrimary.withValues( color: theme.textPrimary.withValues(alpha: Alpha.medium),
alpha: Alpha.medium,
),
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
), ),
), ),
const SizedBox(height: Spacing.lg), ),
const SizedBox(height: Spacing.md),
// Title // Removed header for minimal, focused layout
Text(
'Tools & Search',
style: AppTypography.headlineSmallStyle.copyWith(
color: context.conduitTheme.textPrimary,
),
),
const SizedBox(height: Spacing.lg),
// Web Search Toggle // Web Search Toggle
_buildWebSearchToggle(webSearchEnabled), _buildWebSearchToggle(webSearchEnabled),
@@ -73,21 +76,11 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
toolsAsync.when( toolsAsync.when(
data: (tools) { data: (tools) {
if (tools.isEmpty) { if (tools.isEmpty) {
return Container( return _buildNeutralCard(
width: double.infinity,
padding: const EdgeInsets.all(Spacing.md),
decoration: BoxDecoration(
color: context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(AppBorderRadius.md),
border: Border.all(
color: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
),
child: Text( child: Text(
'No tools available', 'No tools available',
style: AppTypography.bodySmallStyle.copyWith( style: AppTypography.bodySmallStyle.copyWith(
color: context.conduitTheme.textSecondary, color: theme.textSecondary,
), ),
), ),
); );
@@ -96,13 +89,7 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( _buildSectionHeader('Available Tools', tools.length),
'Available Tools',
style: AppTypography.labelStyle.copyWith(
color: context.conduitTheme.textPrimary,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: Spacing.sm), const SizedBox(height: Spacing.sm),
...tools.map( ...tools.map(
(tool) => Padding( (tool) => Padding(
@@ -116,17 +103,7 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
], ],
); );
}, },
loading: () => Container( loading: () => _buildNeutralCard(
width: double.infinity,
padding: const EdgeInsets.all(Spacing.md),
decoration: BoxDecoration(
color: context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(AppBorderRadius.md),
border: Border.all(
color: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
),
child: const Center( child: const Center(
child: SizedBox( child: SizedBox(
width: 24, width: 24,
@@ -135,7 +112,25 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
), ),
), ),
), ),
error: (error, stack) => Container( error: (error, stack) => _buildNeutralCard(
child: Text(
'Failed to load tools',
style: AppTypography.bodySmallStyle.copyWith(
color: theme.error,
),
),
),
),
],
),
),
),
),
);
}
Widget _buildNeutralCard({required Widget child}) {
return Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.all(Spacing.md), padding: const EdgeInsets.all(Spacing.md),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -146,21 +141,55 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
width: BorderWidth.regular, width: BorderWidth.regular,
), ),
), ),
child: Text( child: child,
'Failed to load tools', );
}
Widget _buildSectionHeader(String title, int count) {
final theme = context.conduitTheme;
return Row(
children: [
Text(
title,
style: AppTypography.bodySmallStyle.copyWith( style: AppTypography.bodySmallStyle.copyWith(
color: context.conduitTheme.error, fontWeight: FontWeight.w600,
color: theme.textSecondary,
letterSpacing: 0.2,
), ),
), ),
const SizedBox(width: Spacing.xs),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: theme.surfaceBackground.withValues(alpha: 0.6),
borderRadius: BorderRadius.circular(AppBorderRadius.xs),
border: Border.all(color: theme.dividerColor, width: BorderWidth.thin),
),
child: Text(
'$count',
style: AppTypography.bodySmallStyle.copyWith(
color: theme.textSecondary,
),
), ),
), ),
], ],
),
); );
} }
Widget _buildWebSearchToggle(bool webSearchEnabled) { Widget _buildWebSearchToggle(bool webSearchEnabled) {
return GestureDetector( return Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
side: BorderSide(
color: webSearchEnabled
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
onTap: () { onTap: () {
HapticFeedback.lightImpact(); HapticFeedback.lightImpact();
ref.read(webSearchEnabledProvider.notifier).state = !webSearchEnabled; ref.read(webSearchEnabledProvider.notifier).state = !webSearchEnabled;
@@ -173,12 +202,6 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
? context.conduitTheme.buttonPrimary ? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBackground, : context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(AppBorderRadius.md), borderRadius: BorderRadius.circular(AppBorderRadius.md),
border: Border.all(
color: webSearchEnabled
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
), ),
child: Row( child: Row(
children: [ children: [
@@ -232,11 +255,24 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
], ],
), ),
), ),
),
); );
} }
Widget _buildImageGenerationToggle(bool imageGenEnabled) { Widget _buildImageGenerationToggle(bool imageGenEnabled) {
return GestureDetector( return Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
side: BorderSide(
color: imageGenEnabled
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
onTap: () { onTap: () {
HapticFeedback.lightImpact(); HapticFeedback.lightImpact();
ref.read(imageGenerationEnabledProvider.notifier).state = ref.read(imageGenerationEnabledProvider.notifier).state =
@@ -250,12 +286,6 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
? context.conduitTheme.buttonPrimary ? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBackground, : context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(AppBorderRadius.md), borderRadius: BorderRadius.circular(AppBorderRadius.md),
border: Border.all(
color: imageGenEnabled
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
), ),
child: Row( child: Row(
children: [ children: [
@@ -307,11 +337,24 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
], ],
), ),
), ),
),
); );
} }
Widget _buildToolCard(Tool tool, bool isSelected) { Widget _buildToolCard(Tool tool, bool isSelected) {
return GestureDetector( return Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
side: BorderSide(
color: isSelected
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(AppBorderRadius.md),
onTap: () { onTap: () {
HapticFeedback.lightImpact(); HapticFeedback.lightImpact();
final currentIds = ref.read(selectedToolIdsProvider); final currentIds = ref.read(selectedToolIdsProvider);
@@ -334,12 +377,6 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
? context.conduitTheme.buttonPrimary ? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBackground, : context.conduitTheme.cardBackground,
borderRadius: BorderRadius.circular(AppBorderRadius.md), borderRadius: BorderRadius.circular(AppBorderRadius.md),
border: Border.all(
color: isSelected
? context.conduitTheme.buttonPrimary
: context.conduitTheme.cardBorder,
width: BorderWidth.regular,
),
), ),
child: Row( child: Row(
children: [ children: [
@@ -393,6 +430,7 @@ class _UnifiedToolsModalState extends ConsumerState<UnifiedToolsModal> {
], ],
), ),
), ),
),
); );
} }