fix web project folder actions
This commit is contained in:
@@ -2,6 +2,11 @@ import 'project_folder_stub.dart'
|
||||
if (dart.library.io) 'project_folder_io.dart'
|
||||
as platform;
|
||||
|
||||
String? workspaceFolderPickerUnavailableMessage({required bool isWeb}) =>
|
||||
isWeb
|
||||
? 'إضافة مجلد كامل غير مدعومة في نسخة الويب الحالية. أرفق ملفات محددة للتحليل، أو افتح مشروعًا مسجلًا مسبقًا من «مشاريعي». لتسجيل مجلد جديد استخدم تطبيق سطح المكتب.'
|
||||
: null;
|
||||
|
||||
bool get canCreateProjectFolders => platform.canCreateProjectFolders;
|
||||
|
||||
Future<String> createProjectFolder(String parentPath, String projectName) =>
|
||||
|
||||
+71
-15
@@ -105,10 +105,33 @@ class _ChatPageState extends State<ChatPage> {
|
||||
context.read<ChatCubit>().toggleWorkspaceMode();
|
||||
return;
|
||||
}
|
||||
if (kIsWeb) {
|
||||
final state = context.read<ChatCubit>().state;
|
||||
final message = workspaceFolderPickerUnavailableMessage(isWeb: true)!;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
state.savedWorkspacePaths.isEmpty
|
||||
? message
|
||||
: 'اختر مشروعًا مسجلًا من قائمة «مشاريعي»، أو أرفق ملفات محددة للتحليل.',
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
await _addWorkspaceProject();
|
||||
}
|
||||
|
||||
Future<void> _addWorkspaceProject() async {
|
||||
final unsupportedMessage = workspaceFolderPickerUnavailableMessage(
|
||||
isWeb: kIsWeb,
|
||||
);
|
||||
if (unsupportedMessage != null) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(unsupportedMessage)));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final directory = await getDirectoryPath(
|
||||
confirmButtonText: 'تسجيل هذا المشروع',
|
||||
@@ -1176,15 +1199,24 @@ class _ChatPageState extends State<ChatPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'إضافة مشروع موجود إلى القائمة',
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: chat.isSending ? null : _addWorkspaceProject,
|
||||
icon: const Icon(Icons.create_new_folder_outlined, size: 19),
|
||||
),
|
||||
if (!kIsWeb)
|
||||
IconButton(
|
||||
tooltip: 'إضافة مشروع موجود إلى القائمة',
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: chat.isSending ? null : _addWorkspaceProject,
|
||||
icon: const Icon(Icons.create_new_folder_outlined, size: 19),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (chat.savedWorkspacePaths.isEmpty)
|
||||
if (chat.savedWorkspacePaths.isEmpty && kIsWeb)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
||||
child: Text(
|
||||
'سجّل المجلد من تطبيق سطح المكتب، أو أرفق ملفات محددة من زر المشبك.',
|
||||
style: TextStyle(color: Color(0xFF718078), fontSize: 12),
|
||||
),
|
||||
)
|
||||
else if (chat.savedWorkspacePaths.isEmpty)
|
||||
TextButton.icon(
|
||||
onPressed: chat.isSending ? null : _addWorkspaceProject,
|
||||
icon: const Icon(Icons.add, size: 16),
|
||||
@@ -1487,7 +1519,19 @@ class _ChatPageState extends State<ChatPage> {
|
||||
),
|
||||
),
|
||||
SizedBox(width: compact ? 2 : 12),
|
||||
if (constraints.maxWidth >= 900)
|
||||
if (kIsWeb && constraints.maxWidth >= 900)
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: chat.isSending ? null : _pickCodeFiles,
|
||||
icon: const Icon(Icons.attach_file_rounded),
|
||||
label: const Text('إرفاق ملفات للتحليل'),
|
||||
)
|
||||
else if (kIsWeb)
|
||||
IconButton.filledTonal(
|
||||
onPressed: chat.isSending ? null : _pickCodeFiles,
|
||||
tooltip: 'إرفاق ملفات للتحليل',
|
||||
icon: const Icon(Icons.attach_file_rounded),
|
||||
)
|
||||
else if (constraints.maxWidth >= 900)
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: chat.isSending ? null : _addWorkspaceProject,
|
||||
icon: const Icon(Icons.create_new_folder_outlined),
|
||||
@@ -1915,7 +1959,9 @@ class _ChatPageState extends State<ChatPage> {
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
chat.savedWorkspacePaths.isEmpty
|
||||
kIsWeb
|
||||
? 'في نسخة الويب، أرفق ملفات محددة عبر زر المشبك أو اختر مشروعًا سبق تسجيله. تسجيل مجلد كامل متاح في تطبيق سطح المكتب.'
|
||||
: chat.savedWorkspacePaths.isEmpty
|
||||
? 'سجّل مجلد مشروع موجود على جهازك؛ بعدها يقرأ الوكيل الملفات التي تختارها ويجيب عنها.'
|
||||
: 'اختر مجلد مشروع مسجلًا من «مشاريعي»، أو سجّل مجلدًا موجودًا جديدًا ليقرأ الوكيل ملفاته.',
|
||||
style: const TextStyle(
|
||||
@@ -1928,12 +1974,22 @@ class _ChatPageState extends State<ChatPage> {
|
||||
spacing: 10,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
onPressed:
|
||||
chat.isSending ? null : _addWorkspaceProject,
|
||||
icon: const Icon(Icons.folder_open_outlined),
|
||||
label: const Text('فتح مجلد مشروع موجود'),
|
||||
),
|
||||
if (kIsWeb)
|
||||
FilledButton.icon(
|
||||
onPressed:
|
||||
chat.isSending ? null : _pickCodeFiles,
|
||||
icon: const Icon(Icons.attach_file_rounded),
|
||||
label: const Text('إرفاق ملفات للتحليل'),
|
||||
)
|
||||
else
|
||||
FilledButton.icon(
|
||||
onPressed:
|
||||
chat.isSending
|
||||
? null
|
||||
: _addWorkspaceProject,
|
||||
icon: const Icon(Icons.folder_open_outlined),
|
||||
label: const Text('فتح مجلد مشروع موجود'),
|
||||
),
|
||||
if (canCreateProjectFolders)
|
||||
OutlinedButton.icon(
|
||||
onPressed:
|
||||
|
||||
Reference in New Issue
Block a user