IOS Fixes

merge-requests/116/head
Sikander Saleem 3 years ago
parent 47a697f352
commit 091abc68bf

@ -3,8 +3,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
class ApiConsts { class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server //static String baseUrl = "http://10.200.204.20:2801/"; // Local server
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server //static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
// static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:audio_waveforms/audio_waveforms.dart'; import 'package:audio_waveforms/audio_waveforms.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -11,7 +12,6 @@ import 'package:http/http.dart';
import 'package:just_audio/just_audio.dart' as JustAudio; import 'package:just_audio/just_audio.dart' as JustAudio;
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart'; import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/app_permissions.dart';
import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/encryption.dart'; import 'package:mohem_flutter_app/classes/encryption.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
@ -1292,14 +1292,19 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
File file = File(path!); File file = File(path!);
file.readAsBytesSync(); file.readAsBytesSync();
Utils.hideLoading(context); Utils.hideLoading(context);
await playerController.preparePlayer(file.path, 1.0); await data.voiceController!.preparePlayer(file.path, 1.0);
data.voiceController!.startPlayer(finishMode: FinishMode.pause);
notifyListeners(); notifyListeners();
playerController.startPlayer(finishMode: FinishMode.pause);
} catch (e) { } catch (e) {
Utils.showToast("Cannot open file."); Utils.showToast("Cannot open file.");
} }
} }
void stopPlaying(BuildContext context, {required SingleUserChatModel data}) async {
data.voiceController!.stopPlayer();
notifyListeners();
}
Future<String> downChatVoice(Uint8List bytes, String ext, SingleUserChatModel data) async { Future<String> downChatVoice(Uint8List bytes, String ext, SingleUserChatModel data) async {
String dirPath = '${(await getApplicationDocumentsDirectory()).path}/chat_audios'; String dirPath = '${(await getApplicationDocumentsDirectory()).path}/chat_audios';
if (!await Directory(dirPath).exists()) { if (!await Directory(dirPath).exists()) {

@ -118,7 +118,11 @@ class ChatBubble extends StatelessWidget {
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13) if (fileTypeID == 13)
currentWaveBubble(context, cItem).onPress(() { currentWaveBubble(context, cItem).onPress(() {
data.playVoice(context, data: cItem); if(cItem.voiceController!.playerState == PlayerState.playing){
data.stopPlaying(context, data: cItem);
}else{
data.playVoice(context, data: cItem);
}
}) })
else else
Row( Row(
@ -203,7 +207,8 @@ class ChatBubble extends StatelessWidget {
], ],
), ),
), ),
).paddingOnly(bottom: 7).onPress(() {}), ).paddingOnly(bottom: 7).onPress(() {
}),
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3) if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(5.0), borderRadius: BorderRadius.circular(5.0),
@ -221,7 +226,12 @@ class ChatBubble extends StatelessWidget {
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13) if (fileTypeID == 13)
recipetWaveBubble(context, cItem).onPress(() { recipetWaveBubble(context, cItem).onPress(() {
data.playVoice(context, data: cItem); if(cItem.voiceController!.playerState == PlayerState.playing){
data.stopPlaying(context, data: cItem);
}else{
data.playVoice(context, data: cItem);
}
}) })
else else
Row( Row(
@ -310,8 +320,8 @@ class ChatBubble extends StatelessWidget {
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
const Icon( Icon(
Icons.play_arrow, data.voiceController!.playerState == PlayerState.playing ? Icons.stop_circle : Icons.play_arrow,
color: MyColors.lightGreenColor, color: MyColors.lightGreenColor,
).paddingAll(10), ).paddingAll(10),
AudioFileWaveforms( AudioFileWaveforms(
@ -338,7 +348,6 @@ class ChatBubble extends StatelessWidget {
} }
Widget recipetWaveBubble(BuildContext context, SingleUserChatModel data) { Widget recipetWaveBubble(BuildContext context, SingleUserChatModel data) {
PlayerController repController = PlayerController();
return Container( return Container(
margin: const EdgeInsets.all(0), margin: const EdgeInsets.all(0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -359,8 +368,8 @@ class ChatBubble extends StatelessWidget {
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
const Icon( Icon(
Icons.play_arrow, data.voiceController!.playerState == PlayerState.playing ? Icons.stop_circle : Icons.play_arrow,
color: MyColors.white, color: MyColors.white,
).paddingAll(10), ).paddingAll(10),
AudioFileWaveforms( AudioFileWaveforms(

Loading…
Cancel
Save