no message

merge-requests/236/head
Zohaib Kambrani 4 years ago
parent 53775d113d
commit 6f6ab8d987

@ -1 +1 @@
3f3d14a0ae775b56806906c2cb14a1f0 067d482a9455eae7d109c3ac5a36de46

@ -40,7 +40,7 @@ class HMGPlatformBridge{
}else if methodCall.method == "isHMGNetworkAvailable"{ }else if methodCall.method == "isHMGNetworkAvailable"{
self.isHMGNetworkAvailable(methodCall:methodCall, result: result) self.isHMGNetworkAvailable(methodCall:methodCall, result: result)
}else if methodCall.method == "registerHmgGeofences"{ }else if methodCall.method == "unRegisterHmgGeofences"{
self.registerHmgGeofences(result: result) self.registerHmgGeofences(result: result)
} }
@ -119,10 +119,16 @@ class HMGPlatformBridge{
if let jsonString = geoFencesJsonString as? String{ if let jsonString = geoFencesJsonString as? String{
let allZones = GeoZoneModel.list(from: jsonString) let allZones = GeoZoneModel.list(from: jsonString)
HMG_Geofence.shared().register(geoZones: allZones) HMG_Geofence.shared().register(geoZones: allZones)
result(true)
}else{ }else{
} }
} }
} }
// Register Geofence
func unRegisterHmgGeofences(result: @escaping FlutterResult){
HMG_Geofence.shared().unRegisterAll()
result(true)
}
} }

@ -71,6 +71,12 @@ class HMG_Geofence:NSObject{
return locationManager.monitoredRegions return locationManager.monitoredRegions
} }
func unRegisterAll(){
for region in locationManager.monitoredRegions {
locationManager.stopMonitoring(for: circularRegion)
}
}
} }
// CLLocationManager Delegates // CLLocationManager Delegates
@ -150,8 +156,8 @@ extension HMG_Geofence{
func notifyServer(forRegion:CLRegion, transition:Transition, location:CLLocation?){ func notifyServer(forRegion:CLRegion, transition:Transition, location:CLLocation?){
showNotification(title: "Notifying server..." , subtitle: forRegion.identifier, message: "") showNotification(title: "Notifying server..." , subtitle: forRegion.identifier, message: "")
if let userProfileJson = UserDefaults.standard.string(forKey: "user-profile"), if let userProfileJson = UserDefaults.standard.string(forKey: "flutter.user-profile"),
let userProfile = dictionary(from: userProfileJson), let patientId = userProfile["PatientID"] as? String{ let userProfile = dictionary(from: userProfileJson), let patientId = userProfile["PatientID"] as? Int{
if let idString = forRegion.identifier.split(separator: "_").first, let idInt = Int(idString){ if let idString = forRegion.identifier.split(separator: "_").first, let idInt = Int(idString){
let body:[String:Any] = [ let body:[String:Any] = [
@ -168,21 +174,5 @@ extension HMG_Geofence{
} }
} }
// func notifyServer(forRegion:GeoZoneModel, transition:Transition, location:CLLocation?){
// flutterMethodChannel?.invokeMethod("getLogGeofenceFullUrl", arguments: nil){ fullUrlString in
// if let url = fullUrlString as? String{
// flutterMethodChannel?.invokeMethod("getDefaultHttpParameters", arguments: nil){ params in
// if var body = params as? [String : Any]{
// body.updateValue(forZone.geofenceId, forKey: "PointsID")
// body.updateValue(transition.rawValue, forKey: "GeoType")
// httpPostRequest(urlString: url, jsonBody: body){ (status,json) in
// showNotification(title: transition.name(), subtitle: forZone.identifier(), message: status ? "Success: sent to server " : "Failed: sent to server ")
// }
// }
// }
// }
// }
// }
} }

@ -56,10 +56,10 @@ class GeofencingServices extends BaseService {
} }
addTestingGeoZones(List zones) { addTestingGeoZones(List zones) {
zones.add({"GEOF_ID": -1, "Description": "ZiK Home", "Latitude": "24.691136", "Longitude": "46.650116", "Radius": 100, "Type": 1}); zones.add({"GEOF_ID": 12, "Description": "ZiK Home", "Latitude": "24.691136", "Longitude": "46.650116", "Radius": 100, "Type": 1});
zones.add({"GEOF_ID": -2, "Description": "CS Office", "Latitude": "24.7087913", "Longitude": "46.6656461", "Radius": 100, "Type": 1}); zones.add({"GEOF_ID": 13, "Description": "CS Office", "Latitude": "24.7087913", "Longitude": "46.6656461", "Radius": 100, "Type": 1});
zones.add({"GEOF_ID": -3, "Description": "Mahmoud Shrouf Home", "Latitude": "24.777577", "Longitude": "46.652675", "Radius": 100, "Type": 1}); zones.add({"GEOF_ID": 14, "Description": "Mahmoud Shrouf Home", "Latitude": "24.777577", "Longitude": "46.652675", "Radius": 100, "Type": 1});
zones.add({"GEOF_ID": -4, "Description": "Panorama Mall", "Latitude": "24.692453", "Longitude": "46.669168", "Radius": 450, "Type": 1}); zones.add({"GEOF_ID": 14, "Description": "Panorama Mall", "Latitude": "24.692453", "Longitude": "46.669168", "Radius": 450, "Type": 1});
zones.add({"GEOF_ID": -5, "Description": "Saudi Architects Crossing", "Latitude": "24.698375", "Longitude": "46.668567", "Radius": 140, "Type": 1}); zones.add({"GEOF_ID": 16, "Description": "Saudi Architects Crossing", "Latitude": "24.698375", "Longitude": "46.668567", "Radius": 140, "Type": 1});
} }
} }

@ -50,6 +50,8 @@ class LandingPage extends StatefulWidget {
} }
class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver { class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
var authProvider = new AuthProvider();
int currentTab = 0; int currentTab = 0;
PageController pageController; PageController pageController;
ProjectViewModel projectViewModel; ProjectViewModel projectViewModel;
@ -148,9 +150,11 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
if (results[Permission.locationAlways].isGranted || results[Permission.location].isGranted) { if (results[Permission.locationAlways].isGranted || results[Permission.location].isGranted) {
debugPrint("Fetching GEO ZONES from HMG service..."); debugPrint("Fetching GEO ZONES from HMG service...");
locator<GeofencingServices>().getAllGeoZones(GeoZonesRequestModel()).then((geoZones) { locator<GeofencingServices>().getAllGeoZones(GeoZonesRequestModel()).then((geoZones) {
debugPrint("GEO ZONES saved to AppPreferences with key '$HMG_GEOFENCES'");
debugPrint("Finished Fetching GEO ZONES from HMG service..."); debugPrint("Finished Fetching GEO ZONES from HMG service...");
projectViewModel.platformBridge().registerHmgGeofences(); debugPrint("GEO ZONES saved to AppPreferences with key '$HMG_GEOFENCES'");
if (authProvider.isLogin) {
projectViewModel.platformBridge().registerHmgGeofences();
}
}); });
} }

@ -43,11 +43,9 @@ class _Login extends State<Login> {
final authService = new AuthProvider(); final authService = new AuthProvider();
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
bool isLoading = false; bool isLoading = false;
AppointmentRateViewModel appointmentRateViewModel = AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>();
locator<AppointmentRateViewModel>();
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
locator<AuthenticatedUserObject>();
ProjectViewModel projectViewModel; ProjectViewModel projectViewModel;
@ -89,25 +87,15 @@ class _Login extends State<Login> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
MobileNo( MobileNo(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value),
onNumberChange: (value) =>
{mobileNo = value, validateForm()},
onCountryChange: (value) => countryCode = value),
Container( Container(
child: TextFields( child: TextFields(
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
controller: nationalIDorFile, controller: nationalIDorFile,
onChanged: (value) => {validateForm()}, onChanged: (value) => {validateForm()},
prefixIcon: Icon( prefixIcon: Icon(loginType == 1 ? Icons.chrome_reader_mode : Icons.receipt, color: Color(0xFF40ACC9)),
loginType == 1 padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10),
? Icons.chrome_reader_mode hintText: loginType == 1 ? TranslationBase.of(context).nationalID : TranslationBase.of(context).fileNo,
: Icons.receipt,
color: Color(0xFF40ACC9)),
padding: EdgeInsets.only(
top: 20, bottom: 20, left: 10, right: 10),
hintText: loginType == 1
? TranslationBase.of(context).nationalID
: TranslationBase.of(context).fileNo,
)) ))
], ],
), ),
@ -121,16 +109,16 @@ class _Login extends State<Login> {
color: Colors.grey, color: Colors.grey,
height: 2, height: 2,
), ),
SizedBox(height: 10,), SizedBox(
height: 10,
),
Row( Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: DefaultButton( child: DefaultButton(
TranslationBase.of(context).login, TranslationBase.of(context).login,
() => {this.startLogin()}, () => {this.startLogin()},
color: isButtonDisabled == true color: isButtonDisabled == true ? Colors.grey : Colors.grey[900],
? Colors.grey
: Colors.grey[900],
textColor: Colors.white, textColor: Colors.white,
)) ))
], ],
@ -152,8 +140,7 @@ class _Login extends State<Login> {
void validateForm() { void validateForm() {
//TODO fix login //TODO fix login
if (util.validateIDBox(nationalIDorFile.text, loginType) == if (util.validateIDBox(nationalIDorFile.text, loginType) == true /*&&
true /*&&
mobileNo.length >= 9 */ mobileNo.length >= 9 */
&& &&
util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) {
@ -208,15 +195,13 @@ class _Login extends State<Login> {
okText: TranslationBase.of(context).confirm, okText: TranslationBase.of(context).confirm,
cancelText: TranslationBase.of(context).cancel_nocaps, cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () => { okFunction: () => {
ConfirmDialog.closeAlertDialog(context), ConfirmDialog.closeAlertDialog(context),
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
REGISTER, REGISTER,
), ),
}, },
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)});
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
}); });
// SMSOTP.showLoadingDialog(context, false), // SMSOTP.showLoadingDialog(context, false),
} }
@ -241,10 +226,13 @@ class _Login extends State<Login> {
} }
// request.isRegister = false; // request.isRegister = false;
this.authService.checkActivationCode(request, code).then((result) => { this.authService.checkActivationCode(request, code).then((result) => {
// Register GeoZones after login
registerGeoZones(),
result = CheckActivationCode.fromJson(result), result = CheckActivationCode.fromJson(result),
result.list.isFamily =false, result.list.isFamily = false,
this.sharedPref.setObject(USER_PROFILE, result.list), this.sharedPref.setObject(USER_PROFILE, result.list),
this.sharedPref.setObject(MAIN_USER, result.list), this.sharedPref.setObject(MAIN_USER, result.list),
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
this.sharedPref.setString(TOKEN, result.authenticationTokenID), this.sharedPref.setString(TOKEN, result.authenticationTokenID),
authenticatedUserObject.getUser(), authenticatedUserObject.getUser(),
@ -283,6 +271,10 @@ class _Login extends State<Login> {
}); });
} }
void registerGeoZones() {
projectViewModel.platformBridge().registerHmgGeofences();
}
// showLoader(bool isTrue) { // showLoader(bool isTrue) {
// setState(() { // setState(() {
// isLoading = isTrue; // isLoading = isTrue;

@ -90,6 +90,7 @@ class PlatformBridge {
static const enable_wifi_if_not = "enableWifiIfNot"; static const enable_wifi_if_not = "enableWifiIfNot";
static const show_loading_method = "loading"; static const show_loading_method = "loading";
static const register_Hmg_Geofences = "registerHmgGeofences"; static const register_Hmg_Geofences = "registerHmgGeofences";
static const un_register_Hmg_Geofences = "unRegisterHmgGeofences";
Future<Object> connectHMGInternetWifi(String patientId) { Future<Object> connectHMGInternetWifi(String patientId) {
print("Invoking platform method: $hmg_internet_wifi_connect_method"); print("Invoking platform method: $hmg_internet_wifi_connect_method");
@ -144,4 +145,8 @@ class PlatformBridge {
void registerHmgGeofences() async { void registerHmgGeofences() async {
final int result = await platform.invokeMethod(register_Hmg_Geofences); final int result = await platform.invokeMethod(register_Hmg_Geofences);
} }
void unRegisterHmgGeofences() async {
final int result = await platform.invokeMethod(un_register_Hmg_Geofences);
}
} }

@ -39,8 +39,7 @@ class _AppDrawerState extends State<AppDrawer> {
var familyFileProvider = FamilyFilesProvider(); var familyFileProvider = FamilyFilesProvider();
AuthenticatedUser user; AuthenticatedUser user;
AuthenticatedUser mainUser; AuthenticatedUser mainUser;
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
locator<AuthenticatedUserObject>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -64,67 +63,45 @@ class _AppDrawerState extends State<AppDrawer> {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
child: child: Image.asset('assets/images/DQ/DQ_logo.png'),
Image.asset('assets/images/DQ/DQ_logo.png'), margin: EdgeInsets.all(SizeConfig.imageSizeMultiplier * 4),
margin: EdgeInsets.all(
SizeConfig.imageSizeMultiplier * 4),
), ),
(user != null && projectProvider.isLogin) (user != null && projectProvider.isLogin)
? Padding( ? Padding(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
child: Column( child: Column(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
mainAxisAlignment: Row(
MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Row( Padding(
children: <Widget>[ padding: EdgeInsets.only(right: 5),
Padding( child: Icon(
padding: EdgeInsets.only( Icons.account_circle,
right: 5),
child: Icon(
Icons.account_circle,
color: Color(0xFF40ACC9),
)),
AppText(
user.firstName +
' ' +
user.lastName,
color: Color(0xFF40ACC9), color: Color(0xFF40ACC9),
) )),
], AppText(
), user.firstName + ' ' + user.lastName,
Row(children: <Widget>[ color: Color(0xFF40ACC9),
Padding( )
padding: EdgeInsets.only( ],
left: 30, top: 5), ),
child: Column( Row(children: <Widget>[
children: <Widget>[ Padding(
AppText( padding: EdgeInsets.only(left: 30, top: 5),
TranslationBase.of( child: Column(
context) children: <Widget>[
.fileno + AppText(
": " + TranslationBase.of(context).fileno + ": " + user.patientID.toString(),
user.patientID color: Color(0xFF40ACC9),
.toString(), fontSize: SizeConfig.textMultiplier * 1.5,
color: ),
Color(0xFF40ACC9), AppText(
fontSize: SizeConfig user.bloodGroup != null ? 'Blood Group: ' + user.bloodGroup : '',
.textMultiplier * fontSize: SizeConfig.textMultiplier * 1.5,
1.5, ),
), ],
AppText( ))
user.bloodGroup != null ])
? 'Blood Group: ' + ]))
user.bloodGroup
: '',
fontSize: SizeConfig
.textMultiplier *
1.5,
),
],
))
])
]))
: SizedBox(), : SizedBox(),
], ],
), ),
@ -135,9 +112,7 @@ class _AppDrawerState extends State<AppDrawer> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
InkWell( InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).arabicChange, Icons.translate),
TranslationBase.of(context).arabicChange,
Icons.translate),
onTap: () { onTap: () {
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
// WELCOME_LOGIN, // WELCOME_LOGIN,
@ -170,20 +145,13 @@ class _AppDrawerState extends State<AppDrawer> {
), ),
FutureBuilder( FutureBuilder(
future: getFamilyFiles(), // async work future: getFamilyFiles(), // async work
builder: (BuildContext context, builder: (BuildContext context, AsyncSnapshot<GetAllSharedRecordsByStatusResponse> snapshot) {
AsyncSnapshot<
GetAllSharedRecordsByStatusResponse>
snapshot) {
switch (snapshot.connectionState) { switch (snapshot.connectionState) {
case ConnectionState.waiting: case ConnectionState.waiting:
return Padding( return Padding(padding: EdgeInsets.all(10), child: Text('Loading....'));
padding: EdgeInsets.all(10),
child: Text('Loading....'));
default: default:
if (snapshot.hasError) if (snapshot.hasError)
return Padding( return Padding(padding: EdgeInsets.all(10), child: Text(snapshot.error));
padding: EdgeInsets.all(10),
child: Text(snapshot.error));
else else
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -198,76 +166,49 @@ class _AppDrawerState extends State<AppDrawer> {
children: [ children: [
user.isFamily == true user.isFamily == true
? Container( ? Container(
padding: padding: EdgeInsets.only(bottom: 5),
EdgeInsets.only(
bottom: 5),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
switchUser( switchUser(mainUser, context);
mainUser,
context);
}, },
child: Row( child: Row(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment children: <Widget>[
.start,
children: <
Widget>[
Expanded( Expanded(
child: Icon( child: Icon(Icons.person),
Icons
.person),
), ),
Expanded( Expanded(
flex: 7, flex: 7,
child: Column( child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
crossAxisAlignment: AppText(mainUser.firstName + ' ' + mainUser.lastName),
CrossAxisAlignment.start, AppText(TranslationBase.of(context).fileno + ": " + mainUser.patientID.toString()),
children: <Widget>[ ])),
AppText(mainUser.firstName + ' ' + mainUser.lastName),
AppText(TranslationBase.of(context).fileno + ": " + mainUser.patientID.toString()),
])),
], ],
))) )))
: SizedBox(), : SizedBox(),
Column( Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment mainAxisSize: MainAxisSize.min,
.start, children: snapshot.data.getAllSharedRecordsByStatusList.map<Widget>((result) {
mainAxisSize: return result.status == 3
MainAxisSize.min,
children: snapshot.data
.getAllSharedRecordsByStatusList
.map<Widget>(
(result) {
return result
.status ==
3
? Container( ? Container(
padding: EdgeInsets padding: EdgeInsets.only(bottom: 5),
.only(
bottom:
5),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
switchUser( switchUser(result, context);
result,
context);
}, },
child: Row( child: Row(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start, children: <Widget>[
children: <
Widget>[
Expanded( Expanded(
child: child: Icon(Icons.person, color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black),
Icon(Icons.person, color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black),
), ),
Expanded( Expanded(
flex: 7, flex: 7,
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
AppText(result.patientName, color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black), AppText(result.patientName, color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black),
AppText(TranslationBase.of(context).fileno + ": " + result.iD.toString(), color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black), AppText(TranslationBase.of(context).fileno + ": " + result.iD.toString(),
color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black),
])), ])),
], ],
))) )))
@ -279,24 +220,15 @@ class _AppDrawerState extends State<AppDrawer> {
}, },
), ),
InkWell( InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).notification, Icons.notifications),
TranslationBase.of(context)
.notification,
Icons.notifications),
onTap: () { onTap: () {
//NotificationsPage //NotificationsPage
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.push( Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => NotificationsPage()));
context,
MaterialPageRoute(
builder: (BuildContext context) =>
NotificationsPage()));
}, },
), ),
InkWell( InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).appsetting, Icons.settings_input_composite),
TranslationBase.of(context).appsetting,
Icons.settings_input_composite),
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
SETTINGS, SETTINGS,
@ -304,23 +236,17 @@ class _AppDrawerState extends State<AppDrawer> {
}, },
), ),
InkWell( InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).rateApp, Icons.star),
TranslationBase.of(context).rateApp,
Icons.star),
onTap: () { onTap: () {
if (Platform.isIOS) { if (Platform.isIOS) {
launch( launch("https://apps.apple.com/sa/app/dr-suliaman-alhabib/id733503978");
"https://apps.apple.com/sa/app/dr-suliaman-alhabib/id733503978");
} else { } else {
launch( launch("https://play.google.com/store/apps/details?id=com.ejada.hmg&hl=en");
"https://play.google.com/store/apps/details?id=com.ejada.hmg&hl=en");
} }
}, },
), ),
InkWell( InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).logout, Icons.lock_open),
TranslationBase.of(context).logout,
Icons.lock_open),
onTap: () { onTap: () {
logout(); logout();
}, },
@ -328,9 +254,7 @@ class _AppDrawerState extends State<AppDrawer> {
], ],
) )
: InkWell( : InkWell(
child: DrawerItem( child: DrawerItem(TranslationBase.of(context).loginregister, Icons.lock_open),
TranslationBase.of(context).loginregister,
Icons.lock_open),
onTap: () { onTap: () {
login(); login();
}, },
@ -389,11 +313,9 @@ class _AppDrawerState extends State<AppDrawer> {
checkUserData() async { checkUserData() async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) { if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson( var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE));
await this.sharedPref.getObject(USER_PROFILE));
var data2 = AuthenticatedUser.fromJson( var data2 = AuthenticatedUser.fromJson(await this.sharedPref.getObject(MAIN_USER));
await this.sharedPref.getObject(MAIN_USER));
print(data2); print(data2);
setState(() { setState(() {
this.user = data; this.user = data;
@ -409,6 +331,7 @@ class _AppDrawerState extends State<AppDrawer> {
await sharedPref.clear(); await sharedPref.clear();
this.user = null; this.user = null;
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);
projectProvider.platformBridge().unRegisterHmgGeofences();
} }
login() async { login() async {
@ -427,8 +350,7 @@ class _AppDrawerState extends State<AppDrawer> {
if (user != null) { if (user != null) {
if (await sharedPref.getObject(FAMILY_FILE) != null) { if (await sharedPref.getObject(FAMILY_FILE) != null) {
// print(await sharedPref.getObject(FAMILY_FILE)); // print(await sharedPref.getObject(FAMILY_FILE));
return Future.value(GetAllSharedRecordsByStatusResponse.fromJson( return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(await sharedPref.getObject(FAMILY_FILE)));
await sharedPref.getObject(FAMILY_FILE)));
} else { } else {
return familyFileProvider.getSharedRecordByStatus(); return familyFileProvider.getSharedRecordByStatus();
} }
@ -437,17 +359,11 @@ class _AppDrawerState extends State<AppDrawer> {
switchUser(user, context) { switchUser(user, context) {
Utils.showProgressDialog(context); Utils.showProgressDialog(context);
this this.familyFileProvider.silentLoggin(user is AuthenticatedUser ? null : user, mainUser: user is AuthenticatedUser).then((value) => loginAfter(value, context)).catchError((err) {
.familyFileProvider
.silentLoggin(user is AuthenticatedUser ? null : user,
mainUser: user is AuthenticatedUser)
.then((value) => loginAfter(value, context))
.catchError((err) {
print(err); print(err);
AppToast.showErrorToast(message: err); AppToast.showErrorToast(message: err);
Navigator.of(context).pop(); Navigator.of(context).pop();
}).showProgressBar( }).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6));
text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6));
} }
loginAfter(result, context) async { loginAfter(result, context) async {

Loading…
Cancel
Save