Merge branch 'diplomatic-quarter-live' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into diplomatic-quarter-haroon

fix_issues
haroon amjad 5 years ago
commit 10025103ac

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

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

@ -19,6 +19,7 @@ class GeneralSettings extends StatefulWidget {
class _GeneralSettings extends State<GeneralSettings>
with TickerProviderStateMixin {
var themeNotifier;
var mediaQueryData;
int blindValue = 0;
bool vibration =false;
bool accsibility =false;
@ -26,7 +27,6 @@ class _GeneralSettings extends State<GeneralSettings>
bool location =false;
var sharedPref = new AppSharedPreferences();
var permission = new PermissionService();
var mediaQueryData;
@override
void initState() {
getValues();
@ -81,104 +81,104 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() {
accsibility = value;
});
//setAccessibility(value);
permission.openSettings();
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
Container(
padding: EdgeInsets.all(10),
child: AppText(
TranslationBase.of(context).blindMode,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
new Container(
color: Colors.white,
padding: EdgeInsets.all(8.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text(
TranslationBase.of(context).offTheme,
style: new TextStyle(fontSize: 16.0),
),
Radio(
value: 0,
groupValue: blindValue,
onChanged: (value) {
setState(() => {this.blindValue = value});
setTheme(value);
},
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text(
TranslationBase.of(context).invertTheme,
style: new TextStyle(
fontSize: 16.0,
),
),
new Radio(
value: 1,
groupValue: blindValue,
onChanged: (value) {
setState(() => {this.blindValue = value});
setTheme(value);
},
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text(
TranslationBase.of(context).dimTheme,
style: new TextStyle(fontSize: 16.0),
),
new Radio(
value: 2,
groupValue: blindValue,
onChanged: (value) {
setState(() => {this.blindValue = value});
setTheme(value);
},
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text(
TranslationBase.of(context).bwTheme,
style: new TextStyle(fontSize: 16.0),
),
new Radio(
value: 3,
groupValue: blindValue,
onChanged: (value) {
setState(() => {this.blindValue = value});
setTheme(value);
},
),
],
),
],
)
])),
// Container(
// padding: EdgeInsets.all(10),
// child: AppText(
// TranslationBase.of(context).blindMode,
// color: Colors.black,
// fontWeight: FontWeight.bold,
// ),
// ),
// new Container(
// color: Colors.white,
// padding: EdgeInsets.all(8.0),
// child: new Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// new Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// new Text(
// TranslationBase.of(context).offTheme,
// style: new TextStyle(fontSize: 16.0),
// ),
// Radio(
// value: 0,
// groupValue: blindValue,
// onChanged: (value) {
// setState(() => {this.blindValue = value});
// setTheme(value);
// },
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// new Text(
// TranslationBase.of(context).invertTheme,
// style: new TextStyle(
// fontSize: 16.0,
// ),
// ),
// new Radio(
// value: 1,
// groupValue: blindValue,
// onChanged: (value) {
// setState(() => {this.blindValue = value});
// setTheme(value);
// },
// )
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// new Text(
// TranslationBase.of(context).dimTheme,
// style: new TextStyle(fontSize: 16.0),
// ),
// new Radio(
// value: 2,
// groupValue: blindValue,
// onChanged: (value) {
// setState(() => {this.blindValue = value});
// setTheme(value);
// },
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// new Text(
// TranslationBase.of(context).bwTheme,
// style: new TextStyle(fontSize: 16.0),
// ),
// new Radio(
// value: 3,
// groupValue: blindValue,
// onChanged: (value) {
// setState(() => {this.blindValue = value});
//
// setTheme(value);
// },
// ),
// ],
// ),
// ],
// )
// ])),
Container(
padding: EdgeInsets.all(10),
child: AppText(
@ -200,6 +200,7 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() {
camera = value;
});
permission.setCameraLocationPermission(context);
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
@ -219,6 +220,7 @@ class _GeneralSettings extends State<GeneralSettings>
setState(() {
location = value;
});
permission.setCameraLocationPermission(context);
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
@ -266,16 +268,18 @@ class _GeneralSettings extends State<GeneralSettings>
permission.setVibrationPermission(value);
}
setAccessibility(){
if(!accsibility){
}
// permission.setVibrationPermission(value);
}
getValues() async{
blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled();
// accsibility = mediaQueryData.accessibleNavigation;
blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled();
camera = await permission.isCameraEnabled();
location = await permission.isLocationEnabled();
setState(() {
location =location;
camera = camera;
vibration = vibration;
blindValue =blindValue;
accsibility = mediaQueryData.accessibleNavigation;
});
}
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/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/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -8,17 +11,31 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ProfileSettings extends StatefulWidget {
@override
_ProfileSettings createState() => _ProfileSettings();
}
class _ProfileSettings extends State<ProfileSettings>
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) {
bool isVibration = true;
var language = 1;
return BaseView<DashboardViewModel>(
onModelReady: (model) => model.getPatientRadOrders(),
onModelReady: (model) =>{},
builder: (_, model, wi) => Container(
child:
ListView(scrollDirection: Axis.vertical, children: <Widget>[
@ -62,7 +79,10 @@ class _ProfileSettings extends State<ProfileSettings>
value: 2,
groupValue: language,
onChanged: (value) {
language = value;
setState(() {
language = value;
});
},
)
],
@ -79,7 +99,10 @@ class _ProfileSettings extends State<ProfileSettings>
value: 1,
groupValue: language,
onChanged: (value) {
language = value;
setState(() {
language = value;
});
},
)
],
@ -97,10 +120,10 @@ class _ProfileSettings extends State<ProfileSettings>
children: [
AppText(TranslationBase.of(context).emailAlert),
Switch(
value: isVibration,
value: emailAlert,
onChanged: (value) {
setState(() {
isVibration = value;
emailAlert = value;
});
},
activeTrackColor: Colors.lightGreenAccent,
@ -117,10 +140,10 @@ class _ProfileSettings extends State<ProfileSettings>
children: [
AppText(TranslationBase.of(context).smsAlert),
Switch(
value: isVibration,
value: smsAlert,
onChanged: (value) {
setState(() {
isVibration = value;
smsAlert = value;
});
},
activeTrackColor: Colors.lightGreenAccent,
@ -141,7 +164,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [
AppText(TranslationBase.of(context).email),
TextField(
style: TextStyle(color: Colors.red),
controller: emailController,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
))
@ -156,7 +179,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [
AppText(TranslationBase.of(context).emergencyName),
TextField(
style: TextStyle(color: Colors.red),
controller: emergencyContactName,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
))
@ -171,7 +194,7 @@ class _ProfileSettings extends State<ProfileSettings>
children: [
AppText(TranslationBase.of(context).emergencyContact),
TextField(
style: TextStyle(color: Colors.red),
controller: emergencyContact,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
),
@ -186,11 +209,44 @@ class _ProfileSettings extends State<ProfileSettings>
child: DefaultButton(
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 =
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
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 {
bool isLogin = false;
bool isLoading = true;
@ -457,4 +458,40 @@ class AuthProvider with ChangeNotifier {
//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/shared_pref_kay.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/services.dart';
import 'package:localstorage/localstorage.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:vibration/vibration.dart';
class PermissionService extends BaseService {
final LocalStorage storage = new LocalStorage("permission");
@ -19,12 +21,21 @@ class PermissionService extends BaseService {
}
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){
HapticFeedback.vibrate();
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 100);
callback();
}
}else{
callback();
}
}
@ -35,5 +46,23 @@ class PermissionService extends BaseService {
isThemeEnabled() {
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: () {
_animationController.forward();
},
onTap: (){Feedback.wrapForTap(widget.onTap, context); permission.vibrate();},
onTap: (){permission.vibrate(widget.onTap, context);},
behavior: HitTestBehavior.opaque,
child: Transform.scale(
scale: _buttonSize,

@ -24,6 +24,6 @@ class DefaultButton extends StatelessWidget {
this.text,
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: () {
_animationController.forward();
},
onTap:(){ Feedback.wrapForTap(widget.onTap, context); permission.vibrate();},
onTap: (){permission.vibrate(widget.onTap, context);},
behavior: HitTestBehavior.opaque,
child: Transform.scale(
scale: _buttonSize,

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

@ -144,7 +144,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
onTapCancel: () {
_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),
behavior: HitTestBehavior.opaque,
child: Transform.scale(

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

Loading…
Cancel
Save