Merge branch 'sultan' into 'diplomatic-quarter-live'

Sultan

See merge request Cloud_Solution/diplomatic-quarter!124
merge-update-with-lab-changes
Mohammad Aljammal 5 years ago
commit 9fcf87126a

@ -3,5 +3,6 @@
<!-- Flutter needs it to communicate with the running application <!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
</manifest> </manifest>

@ -4,4 +4,5 @@
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE" />
</manifest> </manifest>

@ -19,6 +19,7 @@ class GeneralSettings extends StatefulWidget {
class _GeneralSettings extends State<GeneralSettings> class _GeneralSettings extends State<GeneralSettings>
with TickerProviderStateMixin { with TickerProviderStateMixin {
var themeNotifier; var themeNotifier;
var mediaQueryData;
int blindValue = 0; int blindValue = 0;
bool vibration =false; bool vibration =false;
bool accsibility =false; bool accsibility =false;
@ -26,7 +27,6 @@ class _GeneralSettings extends State<GeneralSettings>
bool location =false; bool location =false;
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
var permission = new PermissionService(); var permission = new PermissionService();
var mediaQueryData;
@override @override
void initState() { void initState() {
getValues(); getValues();
@ -81,104 +81,104 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() { setState(() {
accsibility = value; accsibility = value;
}); });
//setAccessibility(value); permission.openSettings();
}, },
activeTrackColor: Colors.lightGreenAccent, activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green, activeColor: Colors.green,
) )
], ],
)), )),
Container( // Container(
padding: EdgeInsets.all(10), // padding: EdgeInsets.all(10),
child: AppText( // child: AppText(
TranslationBase.of(context).blindMode, // TranslationBase.of(context).blindMode,
color: Colors.black, // color: Colors.black,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
), // ),
new Container( // new Container(
color: Colors.white, // color: Colors.white,
padding: EdgeInsets.all(8.0), // padding: EdgeInsets.all(8.0),
child: new Column( // child: new Column(
mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ // children: <Widget>[
new Column( // new Column(
mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ // children: <Widget>[
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
new Text( // new Text(
TranslationBase.of(context).offTheme, // TranslationBase.of(context).offTheme,
style: new TextStyle(fontSize: 16.0), // style: new TextStyle(fontSize: 16.0),
), // ),
Radio( // Radio(
value: 0, // value: 0,
groupValue: blindValue, // groupValue: blindValue,
onChanged: (value) { // onChanged: (value) {
setState(() => {this.blindValue = value}); // setState(() => {this.blindValue = value});
setTheme(value); // setTheme(value);
}, // },
), // ),
], // ],
), // ),
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
new Text( // new Text(
TranslationBase.of(context).invertTheme, // TranslationBase.of(context).invertTheme,
style: new TextStyle( // style: new TextStyle(
fontSize: 16.0, // fontSize: 16.0,
), // ),
), // ),
new Radio( // new Radio(
value: 1, // value: 1,
groupValue: blindValue, // groupValue: blindValue,
onChanged: (value) { // onChanged: (value) {
setState(() => {this.blindValue = value}); // setState(() => {this.blindValue = value});
setTheme(value); // setTheme(value);
}, // },
) // )
], // ],
), // ),
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
new Text( // new Text(
TranslationBase.of(context).dimTheme, // TranslationBase.of(context).dimTheme,
style: new TextStyle(fontSize: 16.0), // style: new TextStyle(fontSize: 16.0),
), // ),
new Radio( // new Radio(
value: 2, // value: 2,
groupValue: blindValue, // groupValue: blindValue,
onChanged: (value) { // onChanged: (value) {
setState(() => {this.blindValue = value}); // setState(() => {this.blindValue = value});
setTheme(value); // setTheme(value);
}, // },
), // ),
], // ],
), // ),
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
new Text( // new Text(
TranslationBase.of(context).bwTheme, // TranslationBase.of(context).bwTheme,
style: new TextStyle(fontSize: 16.0), // style: new TextStyle(fontSize: 16.0),
), // ),
new Radio( // new Radio(
value: 3, // value: 3,
groupValue: blindValue, // groupValue: blindValue,
onChanged: (value) { // onChanged: (value) {
setState(() => {this.blindValue = value}); // setState(() => {this.blindValue = value});
//
setTheme(value); // setTheme(value);
}, // },
), // ),
], // ],
), // ),
], // ],
) // )
])), // ])),
Container( Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: AppText( child: AppText(
@ -200,6 +200,7 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() { setState(() {
camera = value; camera = value;
}); });
permission.setCameraLocationPermission(context);
}, },
activeTrackColor: Colors.lightGreenAccent, activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green, activeColor: Colors.green,
@ -219,6 +220,7 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() { setState(() {
location = value; location = value;
}); });
permission.setCameraLocationPermission(context);
}, },
activeTrackColor: Colors.lightGreenAccent, activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green, activeColor: Colors.green,
@ -266,16 +268,18 @@ class _GeneralSettings extends State<GeneralSettings>
permission.setVibrationPermission(value); permission.setVibrationPermission(value);
} }
setAccessibility(){
if(!accsibility){
}
// permission.setVibrationPermission(value);
}
getValues() async{ getValues() async{
blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled(); blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled(); vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled();
// accsibility = mediaQueryData.accessibleNavigation; camera = await permission.isCameraEnabled();
location = await permission.isLocationEnabled();
setState(() {
location =location;
camera = camera;
vibration = vibration;
blindValue =blindValue;
accsibility = mediaQueryData.accessibleNavigation;
});
} }
getTheme(value) async{ getTheme(value) async{

@ -1,5 +1,8 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -8,17 +11,31 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ProfileSettings extends StatefulWidget { class ProfileSettings extends StatefulWidget {
@override @override
_ProfileSettings createState() => _ProfileSettings(); _ProfileSettings createState() => _ProfileSettings();
} }
class _ProfileSettings extends State<ProfileSettings> class _ProfileSettings extends State<ProfileSettings>
with TickerProviderStateMixin { with TickerProviderStateMixin {
bool smsAlert = true;
bool emailAlert = true;
int language = 1;
final authService = new AuthProvider();
TextEditingController emergencyContact = new TextEditingController();
TextEditingController emailController = new TextEditingController();
TextEditingController emergencyContactName = new TextEditingController();
@override
void initState() {
Future.delayed(new Duration(seconds: 0), () {
getSettings(context);
});
super.initState();
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isVibration = true;
var language = 1;
return BaseView<DashboardViewModel>( return BaseView<DashboardViewModel>(
onModelReady: (model) => model.getPatientRadOrders(), onModelReady: (model) =>{},
builder: (_, model, wi) => Container( builder: (_, model, wi) => Container(
child: child:
ListView(scrollDirection: Axis.vertical, children: <Widget>[ ListView(scrollDirection: Axis.vertical, children: <Widget>[
@ -62,7 +79,10 @@ class _ProfileSettings extends State<ProfileSettings>
value: 2, value: 2,
groupValue: language, groupValue: language,
onChanged: (value) { onChanged: (value) {
language = value; setState(() {
language = value;
});
}, },
) )
], ],
@ -79,7 +99,10 @@ class _ProfileSettings extends State<ProfileSettings>
value: 1, value: 1,
groupValue: language, groupValue: language,
onChanged: (value) { onChanged: (value) {
language = value; setState(() {
language = value;
});
}, },
) )
], ],
@ -97,10 +120,10 @@ class _ProfileSettings extends State<ProfileSettings>
children: [ children: [
AppText(TranslationBase.of(context).emailAlert), AppText(TranslationBase.of(context).emailAlert),
Switch( Switch(
value: isVibration, value: emailAlert,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
isVibration = value; emailAlert = value;
}); });
}, },
activeTrackColor: Colors.lightGreenAccent, activeTrackColor: Colors.lightGreenAccent,
@ -117,10 +140,10 @@ class _ProfileSettings extends State<ProfileSettings>
children: [ children: [
AppText(TranslationBase.of(context).smsAlert), AppText(TranslationBase.of(context).smsAlert),
Switch( Switch(
value: isVibration, value: smsAlert,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
isVibration = value; smsAlert = value;
}); });
}, },
activeTrackColor: Colors.lightGreenAccent, activeTrackColor: Colors.lightGreenAccent,
@ -141,7 +164,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [ children: [
AppText(TranslationBase.of(context).email), AppText(TranslationBase.of(context).email),
TextField( TextField(
style: TextStyle(color: Colors.red), controller: emailController,
decoration: InputDecoration( decoration: InputDecoration(
suffixIcon: Icon(Icons.edit), suffixIcon: Icon(Icons.edit),
)) ))
@ -156,7 +179,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [ children: [
AppText(TranslationBase.of(context).emergencyName), AppText(TranslationBase.of(context).emergencyName),
TextField( TextField(
style: TextStyle(color: Colors.red), controller: emergencyContactName,
decoration: InputDecoration( decoration: InputDecoration(
suffixIcon: Icon(Icons.edit), suffixIcon: Icon(Icons.edit),
)) ))
@ -171,7 +194,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [ children: [
AppText(TranslationBase.of(context).emergencyContact), AppText(TranslationBase.of(context).emergencyContact),
TextField( TextField(
style: TextStyle(color: Colors.red), controller: emergencyContact,
decoration: InputDecoration( decoration: InputDecoration(
suffixIcon: Icon(Icons.edit), suffixIcon: Icon(Icons.edit),
), ),
@ -186,11 +209,44 @@ class _ProfileSettings extends State<ProfileSettings>
child: DefaultButton( child: DefaultButton(
TranslationBase.of(context).submit, TranslationBase.of(context).submit,
() { () {
// print(mobileNo.text); saveSettings();
}, },
)), )),
], ],
)) ))
]))); ])));
} }
getSettings(context){
GifLoaderDialogUtils.showMyDialog(context);
authService.getSettings().then((result)=>{
GifLoaderDialogUtils.hideDialog(context),
setValue(result["PateintInfoForUpdateList"][0])
});
}
setValue(value){
setState(() {
this.language = int.parse(value["PreferredLanguage"]);
this.emailAlert = value["IsEmailAlertRequired"];
this.smsAlert = value["IsSMSAlertRequired"];
this.emailController.text = value["EmailAddress"];
this.emergencyContact.text = value["EmergencyContactNo"];
this.emergencyContactName.text = value["EmergencyContactName"];
});
}
saveSettings(){
GifLoaderDialogUtils.showMyDialog(context);
Map<String, dynamic> request = {};
request["EmailAddress"] =this.emailController.text;
request["EmergencyContactName"] = this.emergencyContactName.text;
request["EmergencyContactNo"] = this.emergencyContact.text;
request["IsEmailAlertRequired"] = this.emailAlert;
request["IsSMSAlertRequired"] = this.smsAlert;
request["PreferredLanguage"] = this.language.toString();
authService.saveSettings(request).then((result)=>{
print(result),
GifLoaderDialogUtils.hideDialog(context)
});
}
} }

@ -48,7 +48,8 @@ const LOGGED_IN_USER_URL =
const FORGOT_PATIENT_ID = const FORGOT_PATIENT_ID =
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard'; const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate';
const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
bool isLogin = false; bool isLogin = false;
bool isLoading = true; bool isLoading = true;
@ -457,4 +458,40 @@ class AuthProvider with ChangeNotifier {
//return Future.value(error); //return Future.value(error);
} }
} }
getSettings() async{
dynamic localRes;
try {
await new BaseAppClient().post(PROFILE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: {});
return Future.value(localRes);
} catch (error) {
throw error;
//return Future.value(error);
}
}
Future saveSettings(request) async{
dynamic localRes;
try {
await new BaseAppClient().post(SAVE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
//return Future.value(error);
}
}
} }

@ -1,3 +1,4 @@
import 'package:android_intent/android_intent.dart';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart';
@ -8,7 +9,8 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:localstorage/localstorage.dart'; import 'package:localstorage/localstorage.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:vibration/vibration.dart';
class PermissionService extends BaseService { class PermissionService extends BaseService {
final LocalStorage storage = new LocalStorage("permission"); final LocalStorage storage = new LocalStorage("permission");
@ -19,12 +21,21 @@ class PermissionService extends BaseService {
} }
isVibrationEnabled() { isVibrationEnabled() {
return storage.getItem('isVibration') ==null ? false :true; return (storage.getItem('isVibration') ==null) || (storage.getItem('isVibration')) ==false ? false :true;
} }
vibrate(){ vibrate(callback, context) async{
if (callback == null)
return null;
if(isVibrationEnabled() ==true){ if(isVibrationEnabled() ==true){
HapticFeedback.vibrate(); if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 100);
callback();
}
}else{
callback();
} }
} }
@ -35,5 +46,23 @@ class PermissionService extends BaseService {
isThemeEnabled() { isThemeEnabled() {
return storage.getItem('isTheme'); return storage.getItem('isTheme');
} }
cameraPermission() async{
Map<Permission, PermissionStatus> statuses = await [
Permission.camera,
].request();
}
isCameraEnabled() async{
print(await Permission.camera.status);
return await Permission.camera.status == PermissionStatus.granted ? true : false;
}
setCameraLocationPermission(context) async{
Navigator.pop(context);
openAppSettings();
}
isLocationEnabled() async{
return await Permission.location.status == PermissionStatus.granted ? true : false;
}
openSettings() async{
openAppSettings();
}
} }

@ -90,7 +90,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: (){Feedback.wrapForTap(widget.onTap, context); permission.vibrate();}, onTap: (){permission.vibrate(widget.onTap, context);},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -24,6 +24,6 @@ class DefaultButton extends StatelessWidget {
this.text, this.text,
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
), ),
onPressed: () =>{ this.onPress(), permission.vibrate()})); onPressed:(){permission.vibrate(this.onPress, context); }));
} }
} }

@ -63,7 +63,7 @@ class _FloatingButtonState extends State<FloatingButton>
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap:(){ Feedback.wrapForTap(widget.onTap, context); permission.vibrate();}, onTap: (){permission.vibrate(widget.onTap, context);},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -88,7 +88,7 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
_animationController.forward(); _animationController.forward();
}, },
// onTap: Feedback.wrapForTap(widget.onTap, context), // onTap: Feedback.wrapForTap(widget.onTap, context),
onTap: () =>{ widget.onTap(), permission.vibrate()}, onTap: (){permission.vibrate(widget.onTap, context);},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -144,7 +144,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: () =>{ widget.disabled ? null : widget.onTap(), permission.vibrate()}, onTap: () =>{ widget.disabled ? null : permission.vibrate(widget.onTap, context)},
// onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context), // onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(

@ -152,7 +152,7 @@ dependencies:
after_layout: ^1.0.7 after_layout: ^1.0.7
twilio_programmable_video: ^0.5.0+3 twilio_programmable_video: ^0.5.0+3
flutter_tts: ^1.2.6 flutter_tts: ^1.2.6
vibration: ^1.7.2
speech_to_text: speech_to_text:
path: speech_to_text path: speech_to_text

Loading…
Cancel
Save