"Updated ChatsModel, added ImagePicker import, modified Prompts class, added getFileType function in AppInitializer, removed MethodChannel in FirebaseApi, and updated AiChatState with new file and isRecorded properties."
This commit is contained in:
commit
aaf9a42962
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:didvan/models/ai/bots_model.dart';
|
||||
import 'package:didvan/models/ai/files_model.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class ChatsModel {
|
||||
int? id;
|
||||
|
|
@ -98,8 +99,8 @@ class Prompts {
|
|||
bool? finished;
|
||||
bool? error;
|
||||
bool? audio;
|
||||
FilesModel? fileLocal;
|
||||
int? duration;
|
||||
FilesModel? fileLocal;
|
||||
|
||||
Prompts(
|
||||
{this.id,
|
||||
|
|
@ -111,8 +112,8 @@ class Prompts {
|
|||
this.createdAt,
|
||||
this.finished,
|
||||
this.error,
|
||||
this.fileLocal,
|
||||
this.audio,
|
||||
this.fileLocal,
|
||||
this.duration});
|
||||
|
||||
Prompts.fromJson(Map<String, dynamic> json) {
|
||||
|
|
@ -147,7 +148,7 @@ class Prompts {
|
|||
String? text,
|
||||
String? file,
|
||||
String? fileName,
|
||||
FilesModel? fileLocal,
|
||||
XFile? fileLocal,
|
||||
String? role,
|
||||
String? createdAt,
|
||||
bool? finished,
|
||||
|
|
@ -161,7 +162,6 @@ class Prompts {
|
|||
text: text ?? this.text,
|
||||
file: file ?? this.file,
|
||||
fileName: fileName ?? this.fileName,
|
||||
fileLocal: fileLocal ?? this.fileLocal,
|
||||
role: role ?? this.role,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
finished: finished ?? this.finished,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
enum MyFileType{
|
||||
image,
|
||||
audio,
|
||||
file
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
// ignore_for_file: avoid_web_libraries_in_flutter
|
||||
|
||||
import 'package:didvan/main.dart';
|
||||
import 'package:didvan/models/ai/file_type.dart';
|
||||
import 'package:didvan/models/notification_message.dart';
|
||||
import 'package:didvan/models/requests/news.dart';
|
||||
import 'package:didvan/models/requests/radar.dart';
|
||||
|
|
@ -16,6 +17,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
class AppInitializer {
|
||||
static String? fcmToken;
|
||||
|
|
@ -204,4 +206,34 @@ class AppInitializer {
|
|||
Navigator.of(context).pushNamed(Routes.web, arguments: src);
|
||||
}
|
||||
}
|
||||
|
||||
static MyFileType getFileType(String extName) {
|
||||
MyFileType result;
|
||||
|
||||
switch (p.extension(extName)) {
|
||||
case '.mp3':
|
||||
case '.wav':
|
||||
case '.aac':
|
||||
case '.m4a':
|
||||
case '.ogg':
|
||||
case '.flac':
|
||||
case '.wma':
|
||||
case '.amr':
|
||||
case '.midi':
|
||||
case '.weba':
|
||||
result = MyFileType.audio;
|
||||
break;
|
||||
case '.png':
|
||||
case '.jpg':
|
||||
result = MyFileType.image;
|
||||
break;
|
||||
case '.pdf':
|
||||
result = MyFileType.file;
|
||||
break;
|
||||
default:
|
||||
result = MyFileType.file;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:didvan/services/notification/notification_service.dart';
|
|||
import 'package:didvan/services/storage/storage.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class FirebaseApi {
|
||||
|
|
@ -75,13 +74,6 @@ class FirebaseApi {
|
|||
if (kDebugMode) {
|
||||
print("forground: ${NotificationData.fromJson(message.data).toJson()}");
|
||||
}
|
||||
const platform = MethodChannel('com.didvan.didvanapp/notification');
|
||||
|
||||
await platform.invokeMethod('showNotification', {
|
||||
'title': message.notification!.title,
|
||||
'message': message.notification!.body
|
||||
});
|
||||
|
||||
// }
|
||||
try {
|
||||
await NotificationService.showFirebaseNotification(message);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:didvan/main.dart';
|
||||
import 'package:didvan/models/ai/files_model.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
|
@ -10,7 +11,6 @@ import 'package:persian_number_utility/persian_number_utility.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
import 'package:didvan/models/ai/bots_model.dart';
|
||||
import 'package:didvan/models/ai/chats_model.dart';
|
||||
import 'package:didvan/models/ai/files_model.dart';
|
||||
import 'package:didvan/models/ai/messages_model.dart';
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/models/view/alert_data.dart';
|
||||
|
|
@ -34,6 +34,7 @@ class AiChatState extends CoreProvier {
|
|||
int? chatId;
|
||||
ChatsModel? chat;
|
||||
FilesModel? file;
|
||||
bool isRecorded = false;
|
||||
TextEditingController message = TextEditingController();
|
||||
|
||||
Future<void> _scrolledEnd() async {
|
||||
|
|
@ -161,6 +162,10 @@ class AiChatState extends CoreProvier {
|
|||
chatId: chatId,
|
||||
file: uploadedFile,
|
||||
edite: isEdite);
|
||||
file = null;
|
||||
isRecorded = false;
|
||||
update();
|
||||
|
||||
final res = await AiApiService().getResponse(req).catchError((e) {
|
||||
_onError(e);
|
||||
// return e;
|
||||
|
|
|
|||
Loading…
Reference in New Issue