feat: folders implementation
This commit is contained in:
@@ -1,41 +1,63 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'folder.freezed.dart';
|
||||
part 'folder.g.dart';
|
||||
|
||||
// Timestamp converter for Unix timestamps
|
||||
class TimestampConverter implements JsonConverter<DateTime, dynamic> {
|
||||
const TimestampConverter();
|
||||
|
||||
@override
|
||||
DateTime fromJson(dynamic json) {
|
||||
if (json is String) {
|
||||
return DateTime.parse(json);
|
||||
} else if (json is int) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(json * 1000);
|
||||
} else {
|
||||
throw ArgumentError('Invalid date format: $json');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
dynamic toJson(DateTime object) {
|
||||
return object.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
sealed class Folder with _$Folder {
|
||||
const factory Folder({
|
||||
required String id,
|
||||
required String name,
|
||||
@TimestampConverter() required DateTime createdAt,
|
||||
@TimestampConverter() required DateTime updatedAt,
|
||||
String? parentId,
|
||||
String? userId,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
@Default(false) bool isExpanded,
|
||||
@Default([]) List<String> conversationIds,
|
||||
@Default([]) List<Folder> subfolders,
|
||||
@Default({}) Map<String, dynamic> metadata,
|
||||
Map<String, dynamic>? meta,
|
||||
Map<String, dynamic>? data,
|
||||
Map<String, dynamic>? items,
|
||||
}) = _Folder;
|
||||
|
||||
factory Folder.fromJson(Map<String, dynamic> json) => _$FolderFromJson(json);
|
||||
factory Folder.fromJson(Map<String, dynamic> json) {
|
||||
// Extract conversation IDs from items.chats if available
|
||||
final items = json['items'] as Map<String, dynamic>?;
|
||||
final chats = items?['chats'] as List?;
|
||||
|
||||
// Handle both string IDs and conversation objects
|
||||
final conversationIds = chats?.map((chat) {
|
||||
if (chat is String) {
|
||||
return chat;
|
||||
} else if (chat is Map<String, dynamic>) {
|
||||
return chat['id'] as String? ?? '';
|
||||
}
|
||||
return '';
|
||||
}).where((id) => id.isNotEmpty).toList().cast<String>() ?? <String>[];
|
||||
|
||||
// Handle Unix timestamp conversion
|
||||
DateTime? parseTimestamp(dynamic timestamp) {
|
||||
if (timestamp == null) return null;
|
||||
if (timestamp is int) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||
}
|
||||
if (timestamp is String) {
|
||||
return DateTime.parse(timestamp);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create the modified JSON with proper field mapping
|
||||
return Folder(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
parentId: json['parent_id'] as String?,
|
||||
userId: json['user_id'] as String?,
|
||||
createdAt: parseTimestamp(json['created_at']),
|
||||
updatedAt: parseTimestamp(json['updated_at']),
|
||||
isExpanded: json['is_expanded'] as bool? ?? false,
|
||||
conversationIds: conversationIds,
|
||||
meta: json['meta'] as Map<String, dynamic>?,
|
||||
data: json['data'] as Map<String, dynamic>?,
|
||||
items: json['items'] as Map<String, dynamic>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import '../models/server_config.dart';
|
||||
import '../models/user.dart';
|
||||
import '../models/model.dart';
|
||||
import '../models/conversation.dart';
|
||||
import '../models/folder.dart';
|
||||
import '../models/user_settings.dart';
|
||||
import '../models/folder.dart';
|
||||
import '../models/file_info.dart';
|
||||
@@ -278,7 +279,60 @@ final conversationsProvider = FutureProvider<List<Conversation>>((ref) async {
|
||||
foundation.debugPrint(
|
||||
'DEBUG: Successfully fetched ${conversations.length} conversations',
|
||||
);
|
||||
return conversations;
|
||||
|
||||
// Also fetch folder information and update conversations with folder IDs
|
||||
try {
|
||||
final foldersData = await api.getFolders();
|
||||
foundation.debugPrint('DEBUG: Fetched ${foldersData.length} folders for conversation mapping');
|
||||
|
||||
// Parse folder data into Folder objects
|
||||
final folders = foldersData.map((folderData) => Folder.fromJson(folderData)).toList();
|
||||
|
||||
// Create a map of conversation ID to folder ID
|
||||
final conversationToFolder = <String, String>{};
|
||||
for (final folder in folders) {
|
||||
for (final conversationId in folder.conversationIds) {
|
||||
conversationToFolder[conversationId] = folder.id;
|
||||
}
|
||||
}
|
||||
|
||||
// Update conversations with folder IDs and add missing folder conversations
|
||||
final updatedConversations = <Conversation>[];
|
||||
final existingConversationIds = conversations.map((c) => c.id).toSet();
|
||||
|
||||
for (final conversation in conversations) {
|
||||
final folderId = conversationToFolder[conversation.id];
|
||||
if (folderId != null) {
|
||||
updatedConversations.add(conversation.copyWith(folderId: folderId));
|
||||
foundation.debugPrint('DEBUG: Updated conversation ${conversation.id.substring(0, 8)} with folderId: $folderId');
|
||||
} else {
|
||||
updatedConversations.add(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
// Add conversations that are in folders but not in the main list
|
||||
for (final folder in folders) {
|
||||
for (final conversationId in folder.conversationIds) {
|
||||
if (!existingConversationIds.contains(conversationId)) {
|
||||
// Create a minimal conversation object for folder-only conversations
|
||||
// We'll need to fetch the full conversation details
|
||||
try {
|
||||
final fullConversation = await api.getConversation(conversationId);
|
||||
updatedConversations.add(fullConversation.copyWith(folderId: folder.id));
|
||||
foundation.debugPrint('DEBUG: Added folder conversation ${conversationId.substring(0, 8)} from folder ${folder.name}');
|
||||
} catch (e) {
|
||||
foundation.debugPrint('DEBUG: Failed to fetch folder conversation $conversationId: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foundation.debugPrint('DEBUG: Final conversation count: ${updatedConversations.length}');
|
||||
return updatedConversations;
|
||||
} catch (e) {
|
||||
foundation.debugPrint('DEBUG: Failed to fetch folder information: $e');
|
||||
return conversations; // Return original conversations if folder fetch fails
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
foundation.debugPrint('DEBUG: Error fetching conversations: $e');
|
||||
foundation.debugPrint('DEBUG: Stack trace: $stackTrace');
|
||||
@@ -649,13 +703,20 @@ final conversationSuggestionsProvider = FutureProvider<List<String>>((
|
||||
// Folders provider
|
||||
final foldersProvider = FutureProvider<List<Folder>>((ref) async {
|
||||
final api = ref.watch(apiServiceProvider);
|
||||
if (api == null) return [];
|
||||
if (api == null) {
|
||||
foundation.debugPrint('DEBUG: No API service available for folders');
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
foundation.debugPrint('DEBUG: Fetching folders from API...');
|
||||
final foldersData = await api.getFolders();
|
||||
return foldersData
|
||||
foundation.debugPrint('DEBUG: Raw folders data: $foldersData');
|
||||
final folders = foldersData
|
||||
.map((folderData) => Folder.fromJson(folderData))
|
||||
.toList();
|
||||
foundation.debugPrint('DEBUG: Parsed ${folders.length} folders');
|
||||
return folders;
|
||||
} catch (e) {
|
||||
foundation.debugPrint('DEBUG: Error fetching folders: $e');
|
||||
return [];
|
||||
|
||||
@@ -404,6 +404,17 @@ class ApiService {
|
||||
// Process regular conversations (excluding pinned and archived ones)
|
||||
for (final chatData in regularChatList) {
|
||||
try {
|
||||
// Debug: Check if conversation has folder_id in raw data
|
||||
if (chatData.containsKey('folder_id') && chatData['folder_id'] != null) {
|
||||
debugPrint('🔍 DEBUG: Found conversation with folder_id in raw data: ${chatData['id']} -> ${chatData['folder_id']}');
|
||||
}
|
||||
|
||||
// Debug: Check what fields are available in the chat data
|
||||
if (regularChatList.indexOf(chatData) == 0) {
|
||||
debugPrint('🔍 DEBUG: Sample chat data fields: ${chatData.keys.toList()}');
|
||||
debugPrint('🔍 DEBUG: Sample chat data: ${chatData.toString().substring(0, 200)}...');
|
||||
}
|
||||
|
||||
final conversation = _parseOpenWebUIChat(chatData);
|
||||
// Only add if not already added as pinned or archived
|
||||
if (!pinnedIds.contains(conversation.id) &&
|
||||
@@ -477,6 +488,11 @@ class ApiService {
|
||||
final archived = chatData['archived'] as bool? ?? false;
|
||||
final shareId = chatData['share_id'] as String?;
|
||||
final folderId = chatData['folder_id'] as String?;
|
||||
|
||||
// Debug logging for folder assignment
|
||||
if (folderId != null) {
|
||||
debugPrint('🔍 DEBUG: Conversation ${id.substring(0, 8)} has folderId: $folderId');
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'DEBUG: Parsed conversation $id: pinned=$pinned, archived=$archived',
|
||||
@@ -929,13 +945,24 @@ class ApiService {
|
||||
|
||||
// Folders
|
||||
Future<List<Map<String, dynamic>>> getFolders() async {
|
||||
debugPrint('DEBUG: Fetching folders');
|
||||
final response = await _dio.get('/api/v1/folders/');
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
return data.cast<Map<String, dynamic>>();
|
||||
try {
|
||||
debugPrint('DEBUG: Fetching folders from /api/v1/folders/');
|
||||
final response = await _dio.get('/api/v1/folders/');
|
||||
debugPrint('DEBUG: Folders response status: ${response.statusCode}');
|
||||
debugPrint('DEBUG: Folders response data: ${response.data}');
|
||||
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
debugPrint('DEBUG: Found ${data.length} folders');
|
||||
return data.cast<Map<String, dynamic>>();
|
||||
} else {
|
||||
debugPrint('DEBUG: Response data is not a list: ${data.runtimeType}');
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('DEBUG: Error in getFolders: $e');
|
||||
rethrow;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> createFolder({
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../features/auth/views/connect_signin_page.dart';
|
||||
import '../../features/settings/views/searchable_settings_page.dart';
|
||||
import '../../features/profile/views/profile_page.dart';
|
||||
import '../../features/files/views/files_page.dart';
|
||||
|
||||
import '../../features/chat/views/conversation_search_page.dart';
|
||||
import '../../shared/widgets/themed_dialogs.dart';
|
||||
|
||||
@@ -221,6 +222,8 @@ class NavigationService {
|
||||
page = const FilesPage();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case Routes.chatsList:
|
||||
page = const ChatsListPage();
|
||||
break;
|
||||
@@ -246,5 +249,6 @@ class Routes {
|
||||
static const String serverConnection = '/server-connection';
|
||||
static const String search = '/search';
|
||||
static const String files = '/files';
|
||||
|
||||
static const String chatsList = '/chats-list';
|
||||
}
|
||||
|
||||
@@ -105,8 +105,10 @@ class _ErrorBoundaryState extends ConsumerState<ErrorBoundary> {
|
||||
}
|
||||
|
||||
// Default error UI
|
||||
return Scaffold(
|
||||
backgroundColor: context.conduitTheme.surfaceBackground,
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: context.conduitTheme.surfaceBackground,
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -145,7 +147,8 @@ class _ErrorBoundaryState extends ConsumerState<ErrorBoundary> {
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Wrap child in error handler
|
||||
|
||||
@@ -546,6 +546,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
_navigateToFiles();
|
||||
},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Platform.isIOS ? CupertinoIcons.person : Icons.person_outline,
|
||||
@@ -582,6 +583,8 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
).push(MaterialPageRoute(builder: (context) => const FilesPage()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _navigateToProfile() {
|
||||
Navigator.of(
|
||||
context,
|
||||
@@ -1229,6 +1232,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
@@ -1239,6 +1243,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Spacing.xs),
|
||||
@@ -1618,25 +1623,7 @@ class _ModelSelectorSheetState extends ConsumerState<_ModelSelectorSheet> {
|
||||
),
|
||||
),
|
||||
|
||||
// Header
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: Spacing.sm),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Choose Model',
|
||||
style: TextStyle(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontSize: AppTypography.headlineMedium,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Removed capabilities legend to reduce icon noise
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// Search field
|
||||
Padding(
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../../core/models/model.dart';
|
||||
import '../../../core/providers/app_providers.dart';
|
||||
import '../../../shared/theme/theme_extensions.dart';
|
||||
import '../../../shared/theme/app_theme.dart';
|
||||
import '../../../shared/widgets/conduit_components.dart';
|
||||
|
||||
class ModelSelectorPage extends ConsumerStatefulWidget {
|
||||
const ModelSelectorPage({super.key});
|
||||
@@ -53,17 +54,27 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final modelsAsync = ref.watch(modelsProvider);
|
||||
final selectedModel = ref.watch(selectedModelProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Select Model'),
|
||||
leading: IconButton(
|
||||
icon: Icon(Platform.isIOS ? CupertinoIcons.back : Icons.arrow_back),
|
||||
backgroundColor: context.conduitTheme.surfaceBackground,
|
||||
elevation: Elevation.none,
|
||||
scrolledUnderElevation: Elevation.none,
|
||||
leading: ConduitIconButton(
|
||||
icon: Platform.isIOS
|
||||
? CupertinoIcons.back
|
||||
: Icons.arrow_back_rounded,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
'Select Model',
|
||||
style: AppTypography.headlineMediumStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
@@ -71,10 +82,10 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(Spacing.md),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.scaffoldBackgroundColor,
|
||||
color: context.conduitTheme.surfaceBackground,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: theme.dividerColor.withValues(alpha: 0.1),
|
||||
color: context.conduitTheme.dividerColor.withValues(alpha: 0.1),
|
||||
width: BorderWidth.regular,
|
||||
),
|
||||
),
|
||||
@@ -96,27 +107,22 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.cube_box
|
||||
: Icons.view_in_ar,
|
||||
size: 64,
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
size: IconSize.xxl,
|
||||
color: context.conduitTheme.iconSecondary,
|
||||
),
|
||||
const SizedBox(height: Spacing.md),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
Text(
|
||||
'No models available',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.6,
|
||||
),
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Spacing.sm),
|
||||
Text(
|
||||
'Please check your Open-WebUI configuration',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.5,
|
||||
),
|
||||
style: AppTypography.bodyMediumStyle.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -132,28 +138,23 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.search
|
||||
: Icons.search_off,
|
||||
size: 64,
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
: Icons.search_rounded,
|
||||
size: IconSize.xxl,
|
||||
color: context.conduitTheme.iconSecondary,
|
||||
),
|
||||
const SizedBox(height: Spacing.md),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
Text(
|
||||
'No models found',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.6,
|
||||
),
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Spacing.sm),
|
||||
Text(
|
||||
'Try searching with different keywords',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.5,
|
||||
),
|
||||
style: AppTypography.bodyMediumStyle.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -183,9 +184,10 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
),
|
||||
child: Text(
|
||||
group.title!,
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
style: AppTypography.labelStyle.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -206,7 +208,13 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
loading: () => Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
context.conduitTheme.buttonPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
error: (error, _) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -214,32 +222,48 @@ class _ModelSelectorPageState extends ConsumerState<ModelSelectorPage> {
|
||||
Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.exclamationmark_triangle
|
||||
: Icons.error_outline,
|
||||
size: 48,
|
||||
color: theme.colorScheme.error,
|
||||
: Icons.error_rounded,
|
||||
size: IconSize.xxl,
|
||||
color: context.conduitTheme.error,
|
||||
),
|
||||
const SizedBox(height: Spacing.md),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
Text(
|
||||
'Failed to load models',
|
||||
style: theme.textTheme.titleMedium,
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Spacing.sm),
|
||||
Text(
|
||||
error.toString(),
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(
|
||||
alpha: 0.6,
|
||||
),
|
||||
'Please try again later',
|
||||
style: AppTypography.bodyMediumStyle.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
ElevatedButton.icon(
|
||||
const SizedBox(height: Spacing.xl),
|
||||
ElevatedButton(
|
||||
onPressed: () => ref.refresh(modelsProvider),
|
||||
icon: Icon(
|
||||
Platform.isIOS ? CupertinoIcons.refresh : Icons.refresh,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: context.conduitTheme.buttonPrimary,
|
||||
foregroundColor: context.conduitTheme.buttonPrimaryText,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.buttonPadding,
|
||||
vertical: Spacing.md,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.button),
|
||||
),
|
||||
elevation: Elevation.none,
|
||||
),
|
||||
child: Text(
|
||||
'Retry',
|
||||
style: AppTypography.labelStyle.copyWith(
|
||||
color: context.conduitTheme.buttonPrimaryText,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
label: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -339,20 +363,18 @@ class ModelTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
elevation: isSelected ? 2 : 0,
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary.withValues(alpha: 0.1)
|
||||
: null,
|
||||
? context.conduitTheme.buttonPrimary.withValues(alpha: 0.1)
|
||||
: context.conduitTheme.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
||||
side: BorderSide(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: theme.dividerColor.withValues(alpha: 0.3),
|
||||
? context.conduitTheme.buttonPrimary
|
||||
: context.conduitTheme.dividerColor.withValues(alpha: 0.3),
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
),
|
||||
@@ -369,9 +391,11 @@ class ModelTile extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
model.name,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: isSelected ? FontWeight.w600 : null,
|
||||
color: isSelected ? theme.colorScheme.primary : null,
|
||||
style: AppTypography.bodyLargeStyle.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected
|
||||
? context.conduitTheme.buttonPrimary
|
||||
: context.conduitTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -380,7 +404,7 @@ class ModelTile extends StatelessWidget {
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.checkmark_circle_fill
|
||||
: Icons.check_circle,
|
||||
color: theme.colorScheme.primary,
|
||||
color: context.conduitTheme.buttonPrimary,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -388,8 +412,8 @@ class ModelTile extends StatelessWidget {
|
||||
const SizedBox(height: Spacing.xs),
|
||||
Text(
|
||||
model.description!,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
style: AppTypography.bodySmallStyle.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -303,66 +303,71 @@ class _ModernMessageBubbleState extends ConsumerState<ModernMessageBubble>
|
||||
left: Spacing.xxxl,
|
||||
right: Spacing.xs,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: GestureDetector(
|
||||
onLongPress: () => _toggleActions(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.messagePadding,
|
||||
vertical: Spacing.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
context.conduitTheme.chatBubbleUser.withValues(
|
||||
alpha: 0.95,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: GestureDetector(
|
||||
onLongPress: () => _toggleActions(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.messagePadding,
|
||||
vertical: Spacing.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
context.conduitTheme.chatBubbleUser.withValues(
|
||||
alpha: 0.95,
|
||||
),
|
||||
context.conduitTheme.chatBubbleUser,
|
||||
],
|
||||
),
|
||||
context.conduitTheme.chatBubbleUser,
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppBorderRadius.messageBubble,
|
||||
),
|
||||
border: Border.all(
|
||||
color: context.conduitTheme.chatBubbleUserBorder,
|
||||
width: BorderWidth.regular,
|
||||
),
|
||||
boxShadow: ConduitShadows.high,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display images if any
|
||||
if (widget.message.attachmentIds != null &&
|
||||
widget.message.attachmentIds!.isNotEmpty)
|
||||
_buildAttachmentImages(),
|
||||
|
||||
// Display text content if any
|
||||
if (widget.message.content.isNotEmpty) ...[
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppBorderRadius.messageBubble,
|
||||
),
|
||||
border: Border.all(
|
||||
color: context.conduitTheme.chatBubbleUserBorder,
|
||||
width: BorderWidth.regular,
|
||||
),
|
||||
boxShadow: ConduitShadows.high,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display images if any
|
||||
if (widget.message.attachmentIds != null &&
|
||||
widget.message.attachmentIds!.isNotEmpty)
|
||||
const SizedBox(height: Spacing.sm),
|
||||
_buildCustomText(
|
||||
widget.message.content,
|
||||
context.conduitTheme.chatBubbleUserText,
|
||||
),
|
||||
],
|
||||
_buildAttachmentImages(),
|
||||
|
||||
// Action buttons for user messages
|
||||
if (_showActions) ...[
|
||||
const SizedBox(height: Spacing.md),
|
||||
_buildUserActionButtons(),
|
||||
// Display text content if any
|
||||
if (widget.message.content.isNotEmpty) ...[
|
||||
if (widget.message.attachmentIds != null &&
|
||||
widget.message.attachmentIds!.isNotEmpty)
|
||||
const SizedBox(height: Spacing.sm),
|
||||
_buildCustomText(
|
||||
widget.message.content,
|
||||
context.conduitTheme.chatBubbleUserText,
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Action buttons below the message bubble
|
||||
if (_showActions) ...[
|
||||
const SizedBox(height: Spacing.sm),
|
||||
_buildUserActionButtons(),
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -461,16 +466,16 @@ class _ModernMessageBubbleState extends ConsumerState<ModernMessageBubble>
|
||||
] else
|
||||
// Fallback: show empty state for non-streaming empty messages
|
||||
const SizedBox.shrink(),
|
||||
|
||||
// Action buttons
|
||||
if (_showActions) ...[
|
||||
const SizedBox(height: Spacing.md),
|
||||
_buildActionButtons(),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Action buttons below the message content
|
||||
if (_showActions) ...[
|
||||
const SizedBox(height: Spacing.sm),
|
||||
_buildActionButtons(),
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -483,44 +483,49 @@ class ConduitEmptyState extends StatelessWidget {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(isCompact ? Spacing.md : Spacing.lg),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: isCompact ? IconSize.xxl : IconSize.xxl + Spacing.md,
|
||||
height: isCompact ? IconSize.xxl : IconSize.xxl + Spacing.md,
|
||||
decoration: BoxDecoration(
|
||||
color: context.conduitTheme.surfaceBackground,
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.circular),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: isCompact ? IconSize.xxl : IconSize.xxl + Spacing.md,
|
||||
height: isCompact ? IconSize.xxl : IconSize.xxl + Spacing.md,
|
||||
decoration: BoxDecoration(
|
||||
color: context.conduitTheme.surfaceBackground,
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.circular),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: isCompact ? IconSize.xl : TouchTarget.minimum,
|
||||
color: context.conduitTheme.iconSecondary,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: isCompact ? IconSize.xl : TouchTarget.minimum,
|
||||
color: context.conduitTheme.iconSecondary,
|
||||
SizedBox(height: isCompact ? Spacing.sm : Spacing.md),
|
||||
Text(
|
||||
title,
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(height: isCompact ? Spacing.sm : Spacing.md),
|
||||
Text(
|
||||
title,
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: context.conduitTheme.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
SizedBox(height: Spacing.sm),
|
||||
Text(
|
||||
message,
|
||||
style: AppTypography.standard.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: isCompact ? 2 : null,
|
||||
overflow: isCompact ? TextOverflow.ellipsis : null,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: Spacing.sm),
|
||||
Text(
|
||||
message,
|
||||
style: AppTypography.standard.copyWith(
|
||||
color: context.conduitTheme.textSecondary,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (action != null) ...[
|
||||
SizedBox(height: isCompact ? Spacing.md : Spacing.lg),
|
||||
action!,
|
||||
if (action != null) ...[
|
||||
SizedBox(height: isCompact ? Spacing.md : Spacing.lg),
|
||||
action!,
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user