no message

merge-requests/546/head
haroon amjad 3 years ago
parent 816dfe4a12
commit 8b1733e917

@ -20,6 +20,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-feature android:name="android.hardware.location.network" android:required="false" /> <uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" /> <uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/> <uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/>

File diff suppressed because it is too large Load Diff

@ -3,7 +3,6 @@ import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
@ -27,19 +26,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final bool isInWishList; final bool isInWishList;
final Function addToCartFunction; final Function addToCartFunction;
ProductAppBar( ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, this.isInWishList, this.addToCartFunction}) : super(key: key);
{Key key,
this.product,
this.model,
this.addToWishlistFunction,
this.quantity,
this.deleteFromWishlistFunction,
this.isInWishList,
this.addToCartFunction})
: super(key: key);
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
locator<AuthenticatedUserObject>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -76,7 +65,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
icon: Icons.shopping_cart, icon: Icons.shopping_cart,
color: Colors.grey[800], color: Colors.grey[800],
onPress: () { onPress: () {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
locator<NavigationService>().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route<dynamic> r) => false); locator<NavigationService>().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route<dynamic> r) => false);
// Navigator.push( // Navigator.push(
@ -84,11 +72,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
// MaterialPageRoute(builder: (context) => CartOrderPage()), // MaterialPageRoute(builder: (context) => CartOrderPage()),
// ); // );
}), }),
if (Provider.of<OrderPreviewViewModel>(context, if (Provider.of<OrderPreviewViewModel>(context, listen: false).cartResponse.quantityCount != 0)
listen: false)
.cartResponse
.quantityCount !=
0)
Positioned( Positioned(
top: 0, top: 0,
right: -1.0, right: -1.0,
@ -101,11 +85,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
height: 18, height: 18,
child: Center( child: Center(
child: Texts( child: Texts(
Provider.of<OrderPreviewViewModel>(context, Provider.of<OrderPreviewViewModel>(context, listen: false).cartResponse.quantityCount.toString(),
listen: false)
.cartResponse
.quantityCount
.toString(),
style: "caption", style: "caption",
medium: true, medium: true,
color: Colors.white, color: Colors.white,
@ -144,7 +124,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
return Container( return Container(
child: new Wrap( child: new Wrap(
children: <Widget>[ children: <Widget>[
if (product.stockAvailability != 'Out of stock') if (product.stockAvailability != 'Out of stock' && !product.isRx)
new ListTile( new ListTile(
leading: Icon(Icons.shopping_cart), leading: Icon(Icons.shopping_cart),
title: Text( title: Text(
@ -153,17 +133,12 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
onTap: () async { onTap: () async {
if (quantity > 0) { if (quantity > 0) {
{ {
await addToCartFunction( await addToCartFunction(quantity: quantity, itemID: itemID, model: model);
quantity: quantity,
itemID: itemID,
model: model);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} else { } else {
AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity);
// "you should add quantity"
);
} }
}), }),
ListTile( ListTile(
@ -172,9 +147,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
color: !isInWishList ? Colors.white : Colors.red[800], color: !isInWishList ? Colors.white : Colors.red[800],
), ),
title: Text( title: Text(
isInWishList isInWishList ? TranslationBase.of(context).removeFromWishlist : TranslationBase.of(context).addToWishlist,
? TranslationBase.of(context).removeFromWishlist
: TranslationBase.of(context).addToWishlist,
), ),
onTap: () async { onTap: () async {
if (isInWishList) if (isInWishList)
@ -189,8 +162,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
TranslationBase.of(context).compare, TranslationBase.of(context).compare,
), ),
onTap: () { onTap: () {
Provider.of<CompareList>(context, listen: false) Provider.of<CompareList>(context, listen: false).addItem(specificationData, context);
.addItem(specificationData,context);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),

@ -77,7 +77,7 @@ class _CallPageState extends State<CallPage> {
), ),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
roomId = await signaling.createRoom(_remoteRenderer); // roomId = await signaling.createRoom(_remoteRenderer);
textEditingController.text = roomId; textEditingController.text = roomId;
setState(() {}); setState(() {});
}, },
@ -89,10 +89,10 @@ class _CallPageState extends State<CallPage> {
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
// Add roomId // Add roomId
signaling.joinRoom( // signaling.joinRoom(
textEditingController.text, // textEditingController.text,
_remoteRenderer, // _remoteRenderer,
); // );
}, },
child: Text("Join room"), child: Text("Join room"),
), ),
@ -101,7 +101,7 @@ class _CallPageState extends State<CallPage> {
), ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
signaling.hangUp(_localRenderer); // signaling.hangUp(_localRenderer);
}, },
child: Text("Hangup"), child: Text("Hangup"),
) )

@ -1,6 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:cloud_firestore/cloud_firestore.dart'; // import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart';
typedef void StreamStateCallback(MediaStream stream); typedef void StreamStateCallback(MediaStream stream);
@ -21,150 +21,74 @@ class Signaling {
String currentRoomText; String currentRoomText;
StreamStateCallback onAddRemoteStream; StreamStateCallback onAddRemoteStream;
Future<String> createRoom(RTCVideoRenderer remoteRenderer) async { // Future<String> createRoom(RTCVideoRenderer remoteRenderer) async {
FirebaseFirestore db = FirebaseFirestore.instance; // // FirebaseFirestore db = FirebaseFirestore.instance;
DocumentReference roomRef = db.collection('rooms').doc(); // // DocumentReference roomRef = db.collection('rooms').doc();
//
print('Create PeerConnection with configuration: $configuration'); // print('Create PeerConnection with configuration: $configuration');
//
peerConnection = await createPeerConnection(configuration); // peerConnection = await createPeerConnection(configuration);
//
registerPeerConnectionListeners(); // registerPeerConnectionListeners();
//
localStream.getTracks().forEach((track) { // localStream.getTracks().forEach((track) {
peerConnection?.addTrack(track, localStream); // peerConnection?.addTrack(track, localStream);
}); // });
//
// Code for collecting ICE candidates below // // Code for collecting ICE candidates below
var callerCandidatesCollection = roomRef.collection('callerCandidates'); // var callerCandidatesCollection = roomRef.collection('callerCandidates');
//
peerConnection?.onIceCandidate = (RTCIceCandidate candidate) { // peerConnection?.onIceCandidate = (RTCIceCandidate candidate) {
print('Got candidate: ${candidate.toMap()}'); // print('Got candidate: ${candidate.toMap()}');
callerCandidatesCollection.add(candidate.toMap()); // callerCandidatesCollection.add(candidate.toMap());
}; // };
// Finish Code for collecting ICE candidate // // Finish Code for collecting ICE candidate
//
// Add code for creating a room // // Add code for creating a room
RTCSessionDescription offer = await peerConnection.createOffer(); // RTCSessionDescription offer = await peerConnection.createOffer();
await peerConnection.setLocalDescription(offer); // await peerConnection.setLocalDescription(offer);
print('Created offer: $offer'); // print('Created offer: $offer');
//
Map<String, dynamic> roomWithOffer = {'offer': offer.toMap()}; // Map<String, dynamic> roomWithOffer = {'offer': offer.toMap()};
//
await roomRef.set(roomWithOffer); // await roomRef.set(roomWithOffer);
var roomId = roomRef.id; // var roomId = roomRef.id;
print('New room created with SDK offer. Room ID: $roomId'); // print('New room created with SDK offer. Room ID: $roomId');
currentRoomText = 'Current room is $roomId - You are the caller!'; // currentRoomText = 'Current room is $roomId - You are the caller!';
// Created a Room // // Created a Room
//
peerConnection?.onTrack = (RTCTrackEvent event) { // peerConnection?.onTrack = (RTCTrackEvent event) {
print('Got remote track: ${event.streams[0]}'); // print('Got remote track: ${event.streams[0]}');
//
event.streams[0].getTracks().forEach((track) { // event.streams[0].getTracks().forEach((track) {
print('Add a track to the remoteStream $track'); // print('Add a track to the remoteStream $track');
remoteStream?.addTrack(track); // remoteStream?.addTrack(track);
}); // });
}; // };
//
// Listening for remote session description below // // Listening for remote session description below
roomRef.snapshots().listen((snapshot) async { // roomRef.snapshots().listen((snapshot) async {
print('Got updated room: ${snapshot.data()}'); // print('Got updated room: ${snapshot.data()}');
//
Map<String, dynamic> data = snapshot.data() as Map<String, dynamic>; // Map<String, dynamic> data = snapshot.data() as Map<String, dynamic>;
if (peerConnection?.getRemoteDescription() != null && data['answer'] != null) { // if (peerConnection?.getRemoteDescription() != null && data['answer'] != null) {
var answer = RTCSessionDescription( // var answer = RTCSessionDescription(
data['answer']['sdp'], // data['answer']['sdp'],
data['answer']['type'], // data['answer']['type'],
); // );
//
print("Someone tried to connect"); // print("Someone tried to connect");
await peerConnection?.setRemoteDescription(answer); // await peerConnection?.setRemoteDescription(answer);
} // }
}); // });
// Listening for remote session description above // // Listening for remote session description above
//
// Listen for remote Ice candidates below // // Listen for remote Ice candidates below
roomRef.collection('calleeCandidates').snapshots().listen((snapshot) { // roomRef.collection('calleeCandidates').snapshots().listen((snapshot) {
snapshot.docChanges.forEach((change) { // snapshot.docChanges.forEach((change) {
if (change.type == DocumentChangeType.added) { // if (change.type == DocumentChangeType.added) {
Map<String, dynamic> data = change.doc.data() as Map<String, dynamic>; // Map<String, dynamic> data = change.doc.data() as Map<String, dynamic>;
print('Got new remote ICE candidate: ${jsonEncode(data)}'); // print('Got new remote ICE candidate: ${jsonEncode(data)}');
peerConnection.addCandidate(
RTCIceCandidate(
data['candidate'],
data['sdpMid'],
data['sdpMLineIndex'],
),
);
}
});
});
// Listen for remote ICE candidates above
return roomId;
}
Future<void> joinRoom(String roomId, RTCVideoRenderer remoteVideo) async {
FirebaseFirestore db = FirebaseFirestore.instance;
DocumentReference roomRef = db.collection('rooms').doc('$roomId');
var roomSnapshot = await roomRef.get();
print('Got room ${roomSnapshot.exists}');
if (roomSnapshot.exists) {
print('Create PeerConnection with configuration: $configuration');
peerConnection = await createPeerConnection(configuration);
registerPeerConnectionListeners();
localStream.getTracks().forEach((track) {
peerConnection?.addTrack(track, localStream);
});
// Code for collecting ICE candidates below
var calleeCandidatesCollection = roomRef.collection('calleeCandidates');
peerConnection.onIceCandidate = (RTCIceCandidate candidate) {
if (candidate == null) {
print('onIceCandidate: complete!');
return;
}
print('onIceCandidate: ${candidate.toMap()}');
calleeCandidatesCollection.add(candidate.toMap());
};
// Code for collecting ICE candidate above
peerConnection?.onTrack = (RTCTrackEvent event) {
print('Got remote track: ${event.streams[0]}');
event.streams[0].getTracks().forEach((track) {
print('Add a track to the remoteStream: $track');
remoteStream?.addTrack(track);
});
};
// Code for creating SDP answer below
var data = roomSnapshot.data() as Map<String, dynamic>;
print('Got offer $data');
var offer = data['offer'];
await peerConnection?.setRemoteDescription(
RTCSessionDescription(offer['sdp'], offer['type']),
);
var answer = await peerConnection.createAnswer();
print('Created Answer $answer');
await peerConnection.setLocalDescription(answer);
Map<String, dynamic> roomWithAnswer = {
'answer': {'type': answer.type, 'sdp': answer.sdp}
};
await roomRef.update(roomWithAnswer);
// Finished creating SDP answer
// Listening for remote ICE candidates below
// roomRef.collection('callerCandidates').snapshots().listen((snapshot) {
// snapshot.docChanges.forEach((document) {
// var data = document.doc.data() as Map<String, dynamic>;
// print(data);
// print('Got new remote ICE candidate: $data');
// peerConnection.addCandidate( // peerConnection.addCandidate(
// RTCIceCandidate( // RTCIceCandidate(
// data['candidate'], // data['candidate'],
@ -172,10 +96,86 @@ class Signaling {
// data['sdpMLineIndex'], // data['sdpMLineIndex'],
// ), // ),
// ); // );
// }
// }); // });
// }); // });
} // // Listen for remote ICE candidates above
} //
// return roomId;
// }
// Future<void> joinRoom(String roomId, RTCVideoRenderer remoteVideo) async {
// FirebaseFirestore db = FirebaseFirestore.instance;
// DocumentReference roomRef = db.collection('rooms').doc('$roomId');
// var roomSnapshot = await roomRef.get();
// print('Got room ${roomSnapshot.exists}');
//
// if (roomSnapshot.exists) {
// print('Create PeerConnection with configuration: $configuration');
// peerConnection = await createPeerConnection(configuration);
//
// registerPeerConnectionListeners();
//
// localStream.getTracks().forEach((track) {
// peerConnection?.addTrack(track, localStream);
// });
//
// // Code for collecting ICE candidates below
// var calleeCandidatesCollection = roomRef.collection('calleeCandidates');
// peerConnection.onIceCandidate = (RTCIceCandidate candidate) {
// if (candidate == null) {
// print('onIceCandidate: complete!');
// return;
// }
// print('onIceCandidate: ${candidate.toMap()}');
// calleeCandidatesCollection.add(candidate.toMap());
// };
// // Code for collecting ICE candidate above
//
// peerConnection?.onTrack = (RTCTrackEvent event) {
// print('Got remote track: ${event.streams[0]}');
// event.streams[0].getTracks().forEach((track) {
// print('Add a track to the remoteStream: $track');
// remoteStream?.addTrack(track);
// });
// };
//
// // Code for creating SDP answer below
// var data = roomSnapshot.data() as Map<String, dynamic>;
// print('Got offer $data');
// var offer = data['offer'];
// await peerConnection?.setRemoteDescription(
// RTCSessionDescription(offer['sdp'], offer['type']),
// );
// var answer = await peerConnection.createAnswer();
// print('Created Answer $answer');
//
// await peerConnection.setLocalDescription(answer);
//
// Map<String, dynamic> roomWithAnswer = {
// 'answer': {'type': answer.type, 'sdp': answer.sdp}
// };
//
// await roomRef.update(roomWithAnswer);
// // Finished creating SDP answer
//
// // Listening for remote ICE candidates below
// // roomRef.collection('callerCandidates').snapshots().listen((snapshot) {
// // snapshot.docChanges.forEach((document) {
// // var data = document.doc.data() as Map<String, dynamic>;
// // print(data);
// // print('Got new remote ICE candidate: $data');
// // peerConnection.addCandidate(
// // RTCIceCandidate(
// // data['candidate'],
// // data['sdpMid'],
// // data['sdpMLineIndex'],
// // ),
// // );
// // });
// // });
// }
// }
Future<void> openUserMedia( Future<void> openUserMedia(
RTCVideoRenderer localVideo, RTCVideoRenderer localVideo,
@ -189,32 +189,32 @@ class Signaling {
remoteVideo.srcObject = await createLocalMediaStream('key'); remoteVideo.srcObject = await createLocalMediaStream('key');
} }
Future<void> hangUp(RTCVideoRenderer localVideo) async { // Future<void> hangUp(RTCVideoRenderer localVideo) async {
List<MediaStreamTrack> tracks = localVideo.srcObject.getTracks(); // List<MediaStreamTrack> tracks = localVideo.srcObject.getTracks();
tracks.forEach((track) { // tracks.forEach((track) {
track.stop(); // track.stop();
}); // });
//
if (remoteStream != null) { // if (remoteStream != null) {
remoteStream.getTracks().forEach((track) => track.stop()); // remoteStream.getTracks().forEach((track) => track.stop());
} // }
if (peerConnection != null) peerConnection.close(); // if (peerConnection != null) peerConnection.close();
//
if (roomId != null) { // if (roomId != null) {
var db = FirebaseFirestore.instance; // var db = FirebaseFirestore.instance;
var roomRef = db.collection('rooms').doc(roomId); // var roomRef = db.collection('rooms').doc(roomId);
var calleeCandidates = await roomRef.collection('calleeCandidates').get(); // var calleeCandidates = await roomRef.collection('calleeCandidates').get();
calleeCandidates.docs.forEach((document) => document.reference.delete()); // calleeCandidates.docs.forEach((document) => document.reference.delete());
//
var callerCandidates = await roomRef.collection('callerCandidates').get(); // var callerCandidates = await roomRef.collection('callerCandidates').get();
callerCandidates.docs.forEach((document) => document.reference.delete()); // callerCandidates.docs.forEach((document) => document.reference.delete());
//
await roomRef.delete(); // await roomRef.delete();
} // }
//
localStream.dispose(); // localStream.dispose();
remoteStream?.dispose(); // remoteStream?.dispose();
} // }
void registerPeerConnectionListeners() { void registerPeerConnectionListeners() {
peerConnection?.onIceGatheringState = (RTCIceGatheringState state) { peerConnection?.onIceGatheringState = (RTCIceGatheringState state) {

@ -36,8 +36,7 @@ dependencies:
fl_chart: ^0.12.3 fl_chart: ^0.12.3
# Permissions # Permissions
permission_handler: ^5.0.0+hotfix.3 permission_handler: ^5.1.0+2
device_info: ^0.4.2+4
# Flutter Html View # Flutter Html View
flutter_html: ^1.2.0 flutter_html: ^1.2.0
@ -46,7 +45,6 @@ dependencies:
pull_to_refresh: 1.6.2 pull_to_refresh: 1.6.2
# Native # Native
flutter_device_type: ^0.2.0
local_auth: ^0.6.2+3 local_auth: ^0.6.2+3
localstorage: ^3.0.3+6 localstorage: ^3.0.3+6
maps_launcher: ^1.2.1 maps_launcher: ^1.2.1
@ -55,7 +53,6 @@ dependencies:
flutter_flexible_toast: ^0.1.4 flutter_flexible_toast: ^0.1.4
firebase_messaging: ^7.0.3 firebase_messaging: ^7.0.3
firebase_analytics: ^6.3.0 firebase_analytics: ^6.3.0
cloud_firestore: ^0.14.3
# Progress bar # Progress bar
progress_hud_v2: ^2.0.0 progress_hud_v2: ^2.0.0
percent_indicator: ^2.1.5 percent_indicator: ^2.1.5
@ -156,7 +153,6 @@ dependencies:
cached_network_image: ^2.4.1 cached_network_image: ^2.4.1
flutter_tts: flutter_tts:
path: flutter_tts-voice_enhancement path: flutter_tts-voice_enhancement
# flutter_tts: ^1.2.6
sms_otp_auto_verify: ^1.2.2 sms_otp_auto_verify: ^1.2.2
wifi: ^0.1.5 wifi: ^0.1.5

Loading…
Cancel
Save