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