|
|
|
|
@ -56,47 +56,64 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
userName = AppState().chatDetails!.response!.userName == cItem.currentUserName.toString() ? "You" : cItem.currentUserName.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> getCurrentUrl(String url)async{
|
|
|
|
|
if(Platform.isIOS){
|
|
|
|
|
String a = url.substring(url.indexOf("Documents/") + 10, url.length) ;
|
|
|
|
|
Directory dir = await getApplicationDocumentsDirectory();
|
|
|
|
|
a = "${dir.path}/$a";
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void playVoice(
|
|
|
|
|
BuildContext context, {
|
|
|
|
|
required SingleUserChatModel data,
|
|
|
|
|
}) async {
|
|
|
|
|
if (data.voice != null && data.voice!.existsSync()) {
|
|
|
|
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
Duration? duration = await data.voiceController!.setAudioSource(MyCustomStream(data.voice!.readAsBytesSync()));
|
|
|
|
|
await data.voiceController!.seek(duration);
|
|
|
|
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
|
|
|
|
await data.voiceController!.setVolume(1.0);
|
|
|
|
|
await data.voiceController!.load();
|
|
|
|
|
data.voiceController!.play();
|
|
|
|
|
} else {
|
|
|
|
|
await data.voiceController!.setFilePath(data!.voice!.path);
|
|
|
|
|
Duration? duration = await data.voiceController!.load();
|
|
|
|
|
await data.voiceController!.seek(duration);
|
|
|
|
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
|
|
|
|
await data.voiceController!.play();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
Uint8List encodedString = await ChatApiClient().downloadURL(fileName: data.contant!, fileTypeDescription: provider.getFileTypeDescription(data.fileTypeResponse!.fileTypeName ?? ""));
|
|
|
|
|
try {
|
|
|
|
|
String path = await provider.downChatVoice(encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
|
|
|
|
|
File file = File(path!);
|
|
|
|
|
await file.readAsBytes();
|
|
|
|
|
data.voice = file;
|
|
|
|
|
// try {
|
|
|
|
|
File sFile = await provider.downChatVoice(encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
|
|
|
|
|
data.voice = sFile;
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
Duration? duration = await data.voiceController!.setAudioSource(MyCustomStream(encodedString));
|
|
|
|
|
Duration? duration = await data.voiceController!.setAudioSource(MyCustomStream(data.voice!.readAsBytesSync()));
|
|
|
|
|
await data.voiceController!.seek(duration);
|
|
|
|
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
|
|
|
|
await data.voiceController!.setVolume(1.0);
|
|
|
|
|
await data.voiceController!.load();
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
data.voiceController!.play();
|
|
|
|
|
} else {
|
|
|
|
|
Duration? duration = await data.voiceController!.setFilePath(file.path);
|
|
|
|
|
Duration? duration = await data.voiceController!.setFilePath(sFile.path);
|
|
|
|
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
|
|
|
|
await data.voiceController!.seek(duration);
|
|
|
|
|
await data.voiceController!.setVolume(1.0);
|
|
|
|
|
await data.voiceController!.load();
|
|
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
await data.voiceController!.play();
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(e.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// Utils.showToast(e.toString());
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -126,7 +143,7 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
Widget currentUser(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
children: [
|
|
|
|
|
if (isReplied)
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
|
|
|
@ -212,7 +229,7 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(top: 11, left: 13, right: 13, bottom: 5).objectContainerView(disablePadding: true, radius: 10).paddingOnly(left: MediaQuery.of(context).size.width * 0.3);
|
|
|
|
|
).paddingOnly(top: 11, left: 13, right: 13, bottom: 5).objectContainerView(disablePadding: true).paddingOnly(left: MediaQuery.of(context).size.width * 0.3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget receiptUser(BuildContext context) {
|
|
|
|
|
@ -352,7 +369,6 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
Widget currentWaveBubble(BuildContext context, SingleUserChatModel data) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.all(0),
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border(
|
|
|
|
|
left: BorderSide(width: 6, color: isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
|
|
|
|
|
@ -424,7 +440,7 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
child: const CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
} else if (playing != true) {
|
|
|
|
|
return const Icon(
|
|
|
|
|
return Icon(
|
|
|
|
|
Icons.play_arrow,
|
|
|
|
|
size: 30,
|
|
|
|
|
color: MyColors.lightGreenColor,
|
|
|
|
|
@ -432,7 +448,7 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
playVoice(context, data: modelData);
|
|
|
|
|
});
|
|
|
|
|
} else if (processingState != ProcessingState.completed) {
|
|
|
|
|
return const Icon(
|
|
|
|
|
return Icon(
|
|
|
|
|
Icons.pause,
|
|
|
|
|
size: 30,
|
|
|
|
|
color: MyColors.lightGreenColor,
|
|
|
|
|
@ -440,7 +456,7 @@ class ChatBubble extends StatelessWidget {
|
|
|
|
|
pausePlaying(context, data: modelData);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return const Icon(
|
|
|
|
|
return Icon(
|
|
|
|
|
Icons.replay,
|
|
|
|
|
size: 30,
|
|
|
|
|
color: MyColors.lightGreenColor,
|
|
|
|
|
|