permission issue fixed

merge-requests/321/head
Sultan Khan 3 years ago
parent b4a7235fc8
commit 85e803651c

@ -75,7 +75,7 @@ class AddFamilyMemberType extends StatelessWidget {
),
AppText(
TranslationBase.of(context)
.nationalID,
.idNo,
fontSize: SizeConfig
.textMultiplier *
2,

@ -278,44 +278,46 @@ class _RegisterInfo extends State<RegisterInfo> {
registerNow() {
dynamic request = getTempUserRequest();
GifLoaderDialogUtils.showMyDialog(context);
this.authService.registerUser(request).then((result) => {
GifLoaderDialogUtils.hideDialog(context),
// userData = result.list;
//AuthenticatedUser.fromJson(result['List'][0]),
if(result is String){
new ConfirmDialog(
context: context,
confirmMessage: result,
okText: TranslationBase.of(context).ok,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () => {
ConfirmDialog.closeAlertDialog(context)
},
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)})
.showAlertDialog(context)
}else
{
result.list.isFamily = false,
sharedPref.setObject(USER_PROFILE, result.list),
this.sharedPref.setObject(MAIN_USER, result.list),
sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
sharedPref.setString(TOKEN, result.authenticationTokenID),
Navigator.of(context).pushNamed(HOME)
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
this
.authService
.registerUser(request)
.then((result) => {
GifLoaderDialogUtils.hideDialog(context),
// userData = result.list;
//AuthenticatedUser.fromJson(result['List'][0]),
if (result is String)
{
new ConfirmDialog(
context: context,
confirmMessage: result,
okText: TranslationBase.of(context).ok,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () =>
{ConfirmDialog.closeAlertDialog(context)},
cancelFunction: () => {
ConfirmDialog.closeAlertDialog(context)
}).showAlertDialog(context)
}
else
{
result.list.isFamily = false,
sharedPref.setObject(USER_PROFILE, result.list),
this.sharedPref.setObject(MAIN_USER, result.list),
sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
sharedPref.setString(TOKEN, result.authenticationTokenID),
Navigator.of(context).pushNamed(HOME)
}
})
.catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
ConfirmDialog dialog = new ConfirmDialog(
context: context,
confirmMessage: err,
okText: TranslationBase.of(context).confirm,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () => {
ConfirmDialog.closeAlertDialog(context)
},
okFunction: () => {ConfirmDialog.closeAlertDialog(context)},
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)});
dialog.showAlertDialog(context);
});
}
@ -347,12 +349,12 @@ class _RegisterInfo extends State<RegisterInfo> {
"PatientIdentificationNo": registerInfo.idNumber,
"MobileNumber": registerd_data.patientMobileNumber,
"PatientOutSA": registerd_data.zipCode == '966' ? 0 : 1,
"FirstNameN":registerInfo.firstNameAr =='-' ?"": registerInfo.firstNameAr,
"FirstName": registerInfo.firstNameEn =='-' ?"":registerInfo.firstNameEn,
"MiddleNameN":registerInfo.secondNameAr =='-' ? "" : registerInfo.secondNameAr,
"MiddleName":registerInfo.secondNameEn == '-' ? "": registerInfo.secondNameEn,
"LastNameN": registerInfo.lastNameAr =='-'? "" : registerInfo.lastNameAr,
"LastName": registerInfo.lastNameEn =='-' ? "": registerInfo.lastNameEn,
"FirstNameN": registerInfo.firstNameAr,
"FirstName": registerInfo.firstNameEn,
"MiddleNameN": registerInfo.secondNameAr,
"MiddleName": registerInfo.secondNameEn,
"LastNameN": registerInfo.lastNameAr,
"LastName": registerInfo.lastNameEn,
"StrDateofBirth": registerInfo.dateOfBirth,
"DateofBirth": DateUtil.convertISODateToJsonDate(
registerInfo.dateOfBirth.replaceAll('/', '-')),

@ -21,6 +21,7 @@ import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class Register extends StatefulWidget {
@override
@ -294,12 +295,12 @@ class _Register extends State<Register> {
// DOB: this.dateOption === '1' ? this.dateOfBirth : moment(this.dateOfBirth).format('DD/MM/YYYY'),
// IsHijri: Number(this.dateOption)
// }
final DateFormat dateFormat = DateFormat('dd/MM/yyyy');
GifLoaderDialogUtils.showMyDialog(context);
var request = CheckUserStatusRequest();
request.patientIdentificationID = nationalIDorFile.text;
request.dOB = isHijri == 1
? dob
: "${selectedDate.toLocal()}".split(' ')[0].replaceAll('-', '/');
request.dOB = isHijri == 1 ? dob : dateFormat.format(selectedDate);
request.isHijri = isHijri;
request.patientOutSA = countryCode == '966' ? 0 : 1;
this.authService.checkUserStatus(request).then((result) => {
@ -311,7 +312,12 @@ class _Register extends State<Register> {
Navigator.of(context).push(FadePage(page: ConfirmLogin())),
}
else
{AppToast.showErrorToast(message: result)}
{
AppToast.showErrorToast(
message: result
? result
: TranslationBase.of(context).somethingWentWrong)
}
});
}

@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:provider/provider.dart';
import 'package:screen/screen.dart';
@ -27,10 +28,14 @@ class _GeneralSettings extends State<GeneralSettings>
bool location = false;
var sharedPref = new AppSharedPreferences();
var permission = new PermissionService();
LocationPermission locationPermission;
var mediaQueryData;
@override
void initState() {
getValues();
setState(() {
getValues();
});
super.initState();
}
@ -215,9 +220,12 @@ class _GeneralSettings extends State<GeneralSettings>
Switch(
value: location,
onChanged: (value) {
setState(() {
location = value;
});
if (value == true) {
Navigator.pop(context);
this.setLocationPermission();
} else {
Geolocator.openLocationSettings();
}
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
@ -227,6 +235,23 @@ class _GeneralSettings extends State<GeneralSettings>
]));
}
setLocationPermission() async {
locationPermission = await Geolocator.checkPermission();
if (locationPermission == LocationPermission.denied) {
locationPermission = await Geolocator.requestPermission();
if (locationPermission != LocationPermission.denied) {
setState(() {
location = true;
});
} else {
this.location = false;
}
} else {
Geolocator.openLocationSettings();
this.location = true;
}
}
setTheme(value) async {
switch (value) {
case 0:
@ -277,20 +302,26 @@ class _GeneralSettings extends State<GeneralSettings>
vibration = permission.isVibrationEnabled() == null
? false
: permission.isVibrationEnabled();
accsibility = mediaQueryData.accessibleNavigation;
setTheme(blindValue);
// accsibility = mediaQueryData.accessibleNavigation;
//setTheme(blindValue);
}
this.location = await this.permission.isLocationEnabled();
}
getTheme(value) async {
if (value == 1) {
return invertThemes(
fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'WorkSans'
);
fontName:
Provider.of<ProjectViewModel>(context, listen: false).isArabic
? 'Cairo'
: 'WorkSans');
} else if (value == 3) {
return bwThemes(
fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'WorkSans'
);
fontName:
Provider.of<ProjectViewModel>(context, listen: false).isArabic
? 'Cairo'
: 'WorkSans');
} else {
return defaultTheme(
fontName:

@ -44,7 +44,7 @@ class _ProfileSettings extends State<ProfileSettings>
child: model.user != null
? ListView(scrollDirection: Axis.vertical, children: <Widget>[
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -74,7 +74,7 @@ class _ProfileSettings extends State<ProfileSettings>
padding: EdgeInsets.all(10),
),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
@ -93,7 +93,7 @@ class _ProfileSettings extends State<ProfileSettings>
],
)),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
@ -116,7 +116,7 @@ class _ProfileSettings extends State<ProfileSettings>
padding: EdgeInsets.all(10),
),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
@ -136,7 +136,7 @@ class _ProfileSettings extends State<ProfileSettings>
],
)),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
@ -160,7 +160,7 @@ class _ProfileSettings extends State<ProfileSettings>
padding: EdgeInsets.all(10),
),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(
@ -175,7 +175,7 @@ class _ProfileSettings extends State<ProfileSettings>
],
)),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(
@ -190,7 +190,7 @@ class _ProfileSettings extends State<ProfileSettings>
],
)),
Container(
color: Theme.of(context).primaryColor,
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(

@ -10,9 +10,11 @@ import 'package:flutter/services.dart';
import 'package:localstorage/localstorage.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:vibration/vibration.dart';
import 'package:geolocator/geolocator.dart' as geo;
class PermissionService extends BaseService {
final LocalStorage storage = new LocalStorage("permission");
geo.LocationPermission locationPermission;
AppGlobal appGlobal = new AppGlobal();
setVibrationPermission(flag) async {
@ -20,23 +22,24 @@ class PermissionService extends BaseService {
}
isVibrationEnabled() {
return (storage.getItem('isVibration') ==null) || (storage.getItem('isVibration')) ==false ? false :true;
return (storage.getItem('isVibration') == null) ||
(storage.getItem('isVibration')) == false
? false
: true;
}
vibrate(callback, context) async{
if (callback == null)
return null;
if(isVibrationEnabled() ==true){
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 100);
callback();
vibrate(callback, context) async {
if (callback == null) return null;
if (isVibrationEnabled() == true) {
if (await Vibration.hasVibrator()) {
Vibration.vibrate(duration: 100);
callback();
}
}else{
} else {
callback();
}
}
setTheme(flag) async {
storage.setItem('isTheme', flag);
}
@ -44,23 +47,35 @@ class PermissionService extends BaseService {
isThemeEnabled() {
return storage.getItem('isTheme');
}
cameraPermission() async{
Map<Permission, PermissionStatus> statuses = await [
Permission.camera,
].request();
}
isCameraEnabled() async{
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;
return await Permission.camera.status == PermissionStatus.granted
? true
: false;
}
setCameraLocationPermission(context) async{
setCameraLocationPermission(context) async {
Navigator.pop(context);
openAppSettings();
}
isLocationEnabled() async{
return await Permission.location.status == PermissionStatus.granted ? true : false;
isLocationEnabled() async {
var permission = await geo.Geolocator.checkPermission();
if (permission == geo.LocationPermission.denied) {
return false;
} else {
return true;
}
}
openSettings() async{
openSettings() async {
openAppSettings();
}
}

@ -1575,6 +1575,9 @@ class TranslationBase {
String get preferredunit =>
localizedValues["preferredunit"][locale.languageCode];
String get trySaying => localizedValues["try-saying"][locale.languageCode];
String get somethingWentWrong =>
localizedValues["somethingWentWrong"][locale.languageCode];
String get enterIdentificationNumber =>
localizedValues["enterIdentificationNumber"][locale.languageCode];
String get accountActivationDesc =>

Loading…
Cancel
Save