Merge branch 'master' into faiz_cs

merge-requests/134/head
Faiz Hashmi 3 years ago
commit 10ef069a06

@ -520,5 +520,6 @@
"noUpcoming": "لا يوجد قادم", "noUpcoming": "لا يوجد قادم",
"fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية", "fakeLocation": ".لقد تتبعنا أنك تحاول استخدام موقع مزيف! يعتبر هذا مخالفة وقد تم إخطار الموارد البشرية",
"noWinner": "حزين! لم يفز أحد اليوم.", "noWinner": "حزين! لم يفز أحد اليوم.",
"myTeam" : "فريقي"
"youCanPlayDemo": "لكن يمكنك لعب العرض" "youCanPlayDemo": "لكن يمكنك لعب العرض"
} }

@ -520,5 +520,6 @@
"noUpcoming": "There is no upcoming", "noUpcoming": "There is no upcoming",
"fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified.", "fakeLocation": "We traced out that you try to use a fake location! This is considered a violation, and HR has been notified.",
"noWinner": "Sad! No one won today.", "noWinner": "Sad! No one won today.",
"myTeam" : "My Team"
"youCanPlayDemo": "But you can play demo" "youCanPlayDemo": "But you can play demo"
} }

@ -507,5 +507,6 @@ abstract class LocaleKeys {
static const fakeLocation = 'fakeLocation'; static const fakeLocation = 'fakeLocation';
static const noWinner = 'noWinner'; static const noWinner = 'noWinner';
static const youCanPlayDemo = 'youCanPlayDemo'; static const youCanPlayDemo = 'youCanPlayDemo';
static const myTeam = 'myTeam';
} }

@ -119,16 +119,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
void getUserRecentChats() async { void getUserRecentChats() async {
if (chatHubConnection.state != HubConnectionState.Connected) {
getUserAutoLoginToken().whenComplete(() async {
await buildHubConnection();
getUserRecentChats();
});
return;
}
ChatUserModel recentChat = await ChatApiClient().getRecentChats(); ChatUserModel recentChat = await ChatApiClient().getRecentChats();
ChatUserModel favUList = await ChatApiClient().getFavUsers(); ChatUserModel favUList = await ChatApiClient().getFavUsers();
if (favUList.response != null && recentChat.response != null) { if (favUList.response != null && recentChat.response != null) {
favUsersList = favUList.response!; favUsersList = favUList.response!;
favUsersList.sort( favUsersList.sort(
@ -1208,19 +1200,42 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
playerController.dispose(); playerController.dispose();
} }
void startRecoding() async { void startRecoding(BuildContext context) async {
PermissionStatus status = await Permission.microphone.request(); await Permission.microphone.request().then((PermissionStatus status) {
if (status.isDenied == true) { if (status.isPermanentlyDenied) {
startRecoding(); Utils.confirmDialog(
} else { context,
isVoiceMsg = true; "The app needs microphone access to be able to record audio.",
recorderController.reset(); onTap: () {
await recorderController.record(path); Navigator.of(context).pop();
_recodeDuration = 0; openAppSettings();
_startTimer(); },
isRecoding = !isRecoding; );
notifyListeners(); } else if (status.isDenied) {
} Utils.confirmDialog(
context,
"The app needs microphone access to be able to record audio.",
onTap: () {
Navigator.of(context).pop();
openAppSettings();
},
);
} else if (status.isGranted) {
sRecoding();
} else {
startRecoding(context);
}
});
}
void sRecoding() async {
isVoiceMsg = true;
recorderController.reset();
await recorderController.record(path);
_recodeDuration = 0;
_startTimer();
isRecoding = !isRecoding;
notifyListeners();
} }
Future<void> _startTimer() async { Future<void> _startTimer() async {
@ -1295,15 +1310,23 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
return numberStr; return numberStr;
} }
Future<String> downChatVoice(Uint8List bytes, String ext, SingleUserChatModel data) async { Future<File> downChatVoice(Uint8List bytes, String ext, SingleUserChatModel data) async {
String dirPath = '${(await getApplicationDocumentsDirectory()).path}/chat_audios'; File file;
if (!await Directory(dirPath).exists()) { try {
await Directory(dirPath).create(); String dirPath = '${(await getApplicationDocumentsDirectory()).path}/chat_audios';
await File('$dirPath/.nomedia').create(); if (!await Directory(dirPath).exists()) {
await Directory(dirPath).create();
await File('$dirPath/.nomedia').create();
}
file = File("$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}" + ext);
await file.writeAsBytes(bytes);
} catch (e) {
if (kDebugMode) {
print(e);
}
file = File("");
} }
File file = File("$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}." + ext); return file;
await file.writeAsBytes(bytes);
return file.path;
} }
void scrollToMsg(SingleUserChatModel data) { void scrollToMsg(SingleUserChatModel data) {

@ -244,7 +244,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void getCategoryOffersListAPI(BuildContext context) async { void getCategoryOffersListAPI(BuildContext context) async {
try { try {
// Utils.showLoading(context); // Utils.showLoading(context);
getOffersList = await OffersAndDiscountsApiClient().getOffersList(0, 6); getOffersList = await OffersAndDiscountsApiClient().getOffersList(0, 10);
isOffersLoading = false; isOffersLoading = false;
notifyListeners(); notifyListeners();
} catch (ex) { } catch (ex) {

@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart'; import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart'; import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart';
@ -56,35 +57,70 @@ class ChatBubble extends StatelessWidget {
userName = AppState().chatDetails!.response!.userName == cItem.currentUserName.toString() ? "You" : cItem.currentUserName.toString(); 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( void playVoice(
BuildContext context, { BuildContext context, {
required SingleUserChatModel data, required SingleUserChatModel data,
}) async { }) async {
if (data.voice != null && data.voice!.existsSync()) { if (data.voice != null && data.voice!.existsSync()) {
await data.voiceController!.setFilePath(data!.voice!.path); if (Platform.isIOS) {
await data.voiceController!.setLoopMode(LoopMode.off); Duration? duration = await data.voiceController!.setAudioSource(MyCustomStream(data.voice!.readAsBytesSync()));
Duration? duration = await data.voiceController!.load();
await data.voiceController!.seek(duration);
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;
Duration? duration = await data.voiceController!.setFilePath(file.path);
await data.voiceController!.setLoopMode(LoopMode.off);
await data.voiceController!.seek(duration); await data.voiceController!.seek(duration);
await data.voiceController!.setLoopMode(LoopMode.off);
await data.voiceController!.setVolume(1.0); await data.voiceController!.setVolume(1.0);
await data.voiceController!.load(); await data.voiceController!.load();
Utils.hideLoading(context); 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(); await data.voiceController!.play();
} catch (e) {
Utils.hideLoading(context);
Utils.showToast(e.toString());
} }
} else {
Utils.showLoading(context);
Uint8List encodedString = await ChatApiClient().downloadURL(fileName: data.contant!, fileTypeDescription: provider.getFileTypeDescription(data.fileTypeResponse!.fileTypeName ?? ""));
// try {
File sFile = await provider.downChatVoice(encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
if(sFile.path.isEmpty){
logger.d("Path Is Emptyyyyyyy");
}else{
logger.d("Path Exsists");
}
data.voice = sFile;
if (Platform.isIOS) {
logger.d("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();
Utils.hideLoading(context);
data.voiceController!.play();
} else {
Duration? duration = await data.voiceController!.setFilePath(sFile.path);
await data.voiceController!.setLoopMode(LoopMode.off);
await data.voiceController!.seek(duration);
Utils.hideLoading(context);
await data.voiceController!.play();
}
// } catch (e) {
// Utils.hideLoading(context);
// Utils.showToast(e.toString());
// }
} }
} }
@ -439,3 +475,23 @@ class ChatBubble extends StatelessWidget {
); );
} }
} }
// Feed your own stream of bytes into the player
class MyCustomStream extends StreamAudioSource {
final Uint8List bytes;
MyCustomStream(this.bytes);
@override
Future<StreamAudioResponse> request([int? start, int? end]) async {
start ??= 0;
end ??= bytes.length;
return StreamAudioResponse(
sourceLength: bytes.length,
contentLength: end - start,
offset: start,
stream: Stream.value(bytes.sublist(start, end)),
contentType: 'audio/aac',
);
}
}

@ -275,7 +275,6 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
: null, : null,
), ),
onChanged: (String val) { onChanged: (String val) {
print(val.length);
if (val.isNotEmpty) { if (val.isNotEmpty) {
m.isTextMsg = true; m.isTextMsg = true;
} else { } else {
@ -302,7 +301,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
Icons.mic, Icons.mic,
color: MyColors.lightGreenColor, color: MyColors.lightGreenColor,
).paddingOnly(right: 15).onPress(() { ).paddingOnly(right: 15).onPress(() {
m.startRecoding(); m.startRecoding(context);
}), }),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26) SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
.onPress( .onPress(

@ -83,7 +83,7 @@ class _ChatHomeState extends State<ChatHome> {
children: <Widget>[ children: <Widget>[
myTab(LocaleKeys.mychats.tr(), 0), myTab(LocaleKeys.mychats.tr(), 0),
myTab(LocaleKeys.favorite.tr(), 1), myTab(LocaleKeys.favorite.tr(), 1),
AppState().getempStatusIsManager ? myTab("My Team", 2) : const SizedBox(), AppState().getempStatusIsManager ? myTab(LocaleKeys.myTeam.tr(), 2) : const SizedBox(),
], ],
), ),
), ),

@ -101,7 +101,7 @@ class _MyTeamScreenState extends State<MyTeamScreen> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
(m.teamMembersList![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), (m.teamMembersList[index].userName! ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13),
], ],
).expanded, ).expanded,
// SizedBox( // SizedBox(

@ -415,7 +415,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
); );
}, },
separatorBuilder: (BuildContext cxt, int index) => 8.width, separatorBuilder: (BuildContext cxt, int index) => 8.width,
itemCount: 6), itemCount: 9),
); );
}, },
), ),
@ -463,7 +463,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
"assets/icons/create_req.svg", "assets/icons/create_req.svg",
color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color, color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color,
).paddingAll(4), ).paddingAll(4),
label: LocaleKeys.createRequest.tr(), label: LocaleKeys.mowadhafhiRequest.tr(),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Stack( icon: Stack(

@ -136,7 +136,6 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
@override @override
void dispose() { void dispose() {
print("// TODO: implement dispose");
super.dispose(); super.dispose();
provider.chatUsersList = []; provider.chatUsersList = [];
provider.pageNo = 1; provider.pageNo = 1;

@ -76,7 +76,7 @@ AppBar ChatAppBarWidget(BuildContext context,
if (chatUser!.isTyping!) ("Typing ...").toText10(color: MyColors.textMixColor) else const SizedBox(), if (chatUser!.isTyping!) ("Typing ...").toText10(color: MyColors.textMixColor) else const SizedBox(),
], ],
), ),
) ).expanded
], ],
); );
}), }),

@ -20,7 +20,7 @@ class ImageOptions {
if (Platform.isAndroid) { if (Platform.isAndroid) {
cameraImageAndroid(image); cameraImageAndroid(image);
} else { } else {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 10))?.path ?? ""); File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);
@ -33,7 +33,7 @@ class ImageOptions {
if (Platform.isAndroid) { if (Platform.isAndroid) {
galleryImageAndroid(image); galleryImageAndroid(image);
} else { } else {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 10))?.path ?? ""); File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);
@ -114,7 +114,7 @@ class ImageOptions {
} }
void galleryImageAndroid(Function(String, File) image) async { void galleryImageAndroid(Function(String, File) image) async {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 10))?.path ?? ""); File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);
@ -124,7 +124,7 @@ void galleryImageAndroid(Function(String, File) image) async {
} }
void cameraImageAndroid(Function(String, File) image) async { void cameraImageAndroid(Function(String, File) image) async {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 10))?.path ?? ""); File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.1.5+300015 version: 3.6.0+300060
environment: environment:
sdk: ">=2.16.0 <3.0.0" sdk: ">=2.16.0 <3.0.0"

Loading…
Cancel
Save