|
|
|
|
@ -32,6 +32,7 @@ import 'package:uuid/uuid.dart';
|
|
|
|
|
|
|
|
|
|
class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
ScrollController scrollController = ScrollController();
|
|
|
|
|
|
|
|
|
|
TextEditingController message = TextEditingController();
|
|
|
|
|
TextEditingController search = TextEditingController();
|
|
|
|
|
List<SingleUserChatModel> userChatHistory = [];
|
|
|
|
|
@ -1180,7 +1181,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
chatReplyId: null,
|
|
|
|
|
isAttachment: true,
|
|
|
|
|
isReply: isMsgReply,
|
|
|
|
|
voicFile: voiceFile,
|
|
|
|
|
voiceFile: voiceFile,
|
|
|
|
|
);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -1198,7 +1199,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
bool? isReply,
|
|
|
|
|
bool? isAttachment,
|
|
|
|
|
int? chatReplyId,
|
|
|
|
|
File? voicFile}) async {
|
|
|
|
|
File? voiceFile}) async {
|
|
|
|
|
Uuid uuid = const Uuid();
|
|
|
|
|
String contentNo = uuid.v4();
|
|
|
|
|
String msg = msgText!;
|
|
|
|
|
@ -1219,10 +1220,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
fileTypeResponse: isAttachment!
|
|
|
|
|
? FileTypeResponse(
|
|
|
|
|
fileTypeId: fileTypeId,
|
|
|
|
|
fileTypeName: getFileExtension(voicFile!.path).toString(),
|
|
|
|
|
fileTypeName: getFileExtension(voiceFile!.path).toString(),
|
|
|
|
|
fileKind: "file",
|
|
|
|
|
fileName: msgText,
|
|
|
|
|
fileTypeDescription: getFileTypeDescription(getFileExtension(voicFile!.path).toString()),
|
|
|
|
|
fileTypeDescription: getFileTypeDescription(getFileExtension(voiceFile!.path).toString()),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
image: null,
|
|
|
|
|
@ -1293,7 +1294,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
file.readAsBytesSync();
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
await data.voiceController!.preparePlayer(file.path, 1.0);
|
|
|
|
|
data.voiceController!.startPlayer(finishMode: FinishMode.pause);
|
|
|
|
|
data.voiceController!.startPlayer(finishMode: FinishMode.stop);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.showToast("Cannot open file.");
|
|
|
|
|
@ -1301,7 +1302,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stopPlaying(BuildContext context, {required SingleUserChatModel data}) async {
|
|
|
|
|
await data.voiceController!.pausePlayer();
|
|
|
|
|
await data.voiceController!.stopPlayer();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1316,9 +1317,24 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
return file.path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// data.scrollController.animateTo(
|
|
|
|
|
// data.scrollController.position.maxScrollExtent,
|
|
|
|
|
void scrollToMsg(SingleUserChatModel data) {
|
|
|
|
|
if (data.userChatReplyResponse != null && data.userChatReplyResponse!.userChatHistoryId != null) {
|
|
|
|
|
int index = userChatHistory.indexWhere((SingleUserChatModel element) => element.userChatHistoryId == data.userChatReplyResponse!.userChatHistoryId);
|
|
|
|
|
double contentSize = scrollController.position.viewportDimension + scrollController.position.maxScrollExtent;
|
|
|
|
|
double target = contentSize * index / userChatHistory.length;
|
|
|
|
|
scrollController.position.animateTo(
|
|
|
|
|
target,
|
|
|
|
|
duration: const Duration(seconds: 1),
|
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// scrollController.scrollTo(index: 150, duration: Duration(seconds: 1));
|
|
|
|
|
// scrollController.animateTo(offset, duration: duration, curve: curve);
|
|
|
|
|
}
|
|
|
|
|
// scrollController.animateTo(
|
|
|
|
|
// scrollController.position.maxScrollExtent,
|
|
|
|
|
// duration: const Duration(milliseconds: 100),
|
|
|
|
|
// curve: Curves.easeOut,
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|