|
|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/theme_notifier.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/theme_value.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@ -16,8 +18,7 @@ class GeneralSettings extends StatefulWidget {
|
|
|
|
|
_GeneralSettings createState() => _GeneralSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _GeneralSettings extends State<GeneralSettings>
|
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
|
class _GeneralSettings extends State<GeneralSettings> with TickerProviderStateMixin {
|
|
|
|
|
var themeNotifier;
|
|
|
|
|
int blindValue = 0;
|
|
|
|
|
bool vibration = false;
|
|
|
|
|
@ -28,6 +29,7 @@ class _GeneralSettings extends State<GeneralSettings>
|
|
|
|
|
var permission = new PermissionService();
|
|
|
|
|
LocationPermission locationPermission;
|
|
|
|
|
var mediaQueryData;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
this.getValues();
|
|
|
|
|
@ -38,196 +40,243 @@ class _GeneralSettings extends State<GeneralSettings>
|
|
|
|
|
mediaQueryData = MediaQuery.of(context);
|
|
|
|
|
themeNotifier = Provider.of<ThemeNotifier>(context);
|
|
|
|
|
return Container(
|
|
|
|
|
child: ListView(scrollDirection: Axis.vertical, children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: AppText(
|
|
|
|
|
TranslationBase.of(context).modes,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
AppText(TranslationBase.of(context).vibration),
|
|
|
|
|
Switch(
|
|
|
|
|
value: vibration,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
vibration = value;
|
|
|
|
|
});
|
|
|
|
|
setVibration(value);
|
|
|
|
|
},
|
|
|
|
|
activeTrackColor: Colors.lightGreenAccent,
|
|
|
|
|
activeColor: Colors.green,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
AppText(TranslationBase.of(context).accessibility),
|
|
|
|
|
Switch(
|
|
|
|
|
value: accsibility,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
accsibility = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
activeTrackColor: Colors.lightGreenAccent,
|
|
|
|
|
activeColor: Colors.green,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: AppText(
|
|
|
|
|
TranslationBase.of(context).blindMode,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
new Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
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);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(21.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).alert,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.64,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).modesBelow,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: vibration,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
vibration = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
activeColor: CustomColors.accentColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).prefferedMode,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
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(
|
|
|
|
|
children: [
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: accsibility,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
accsibility = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
activeColor: CustomColors.accentColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).accessibility,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
|
|
|
|
TranslationBase.of(context).dimTheme,
|
|
|
|
|
style: new TextStyle(fontSize: 16.0),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
mHeight(16),
|
|
|
|
|
mHeight(12),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).blindMode,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.64,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).prefferedMode,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
new Radio(
|
|
|
|
|
value: 0,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
blindValue = value;
|
|
|
|
|
setTheme(value);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).offTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
new Radio(
|
|
|
|
|
value: 2,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() => {this.blindValue = value});
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Radio(
|
|
|
|
|
value: 1,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
blindValue = value;
|
|
|
|
|
setTheme(value);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).invertTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
new Text(
|
|
|
|
|
TranslationBase.of(context).bwTheme,
|
|
|
|
|
style: new TextStyle(fontSize: 16.0),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Radio(
|
|
|
|
|
value: 2,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
blindValue = value;
|
|
|
|
|
setTheme(value);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).dimTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
new Radio(
|
|
|
|
|
value: 3,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() => {this.blindValue = value});
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Radio(
|
|
|
|
|
value: 1,
|
|
|
|
|
groupValue: blindValue,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
blindValue = value;
|
|
|
|
|
setTheme(value);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).bwTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
mHeight(12),
|
|
|
|
|
mHeight(12),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).permissions,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.64,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).permissionsBellow,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: camera,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
camera = value;
|
|
|
|
|
});
|
|
|
|
|
this.permission.openSettings();
|
|
|
|
|
},
|
|
|
|
|
activeColor: CustomColors.accentColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).cameraPermission,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: location,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
if (value == true) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
this.setLocationPermission();
|
|
|
|
|
} else {
|
|
|
|
|
Geolocator.openLocationSettings();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
activeColor: CustomColors.accentColor,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).locationPermission,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
])),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: AppText(
|
|
|
|
|
TranslationBase.of(context).permissions,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
mHeight(16),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
AppText(TranslationBase.of(context).cameraPermission),
|
|
|
|
|
Switch(
|
|
|
|
|
value: camera,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
camera = value;
|
|
|
|
|
});
|
|
|
|
|
this.permission.openSettings();
|
|
|
|
|
},
|
|
|
|
|
activeTrackColor: Colors.lightGreenAccent,
|
|
|
|
|
activeColor: Colors.green,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
AppText(TranslationBase.of(context).locationPermission),
|
|
|
|
|
Switch(
|
|
|
|
|
value: location,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
if (value == true) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
this.setLocationPermission();
|
|
|
|
|
} else {
|
|
|
|
|
Geolocator.openLocationSettings();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
activeTrackColor: Colors.lightGreenAccent,
|
|
|
|
|
activeColor: Colors.green,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
]));
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setLocationPermission() async {
|
|
|
|
|
@ -292,11 +341,8 @@ class _GeneralSettings extends State<GeneralSettings>
|
|
|
|
|
|
|
|
|
|
getValues() async {
|
|
|
|
|
if (permission.isThemeEnabled() != null) {
|
|
|
|
|
blindValue =
|
|
|
|
|
permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
|
|
|
|
|
vibration = permission.isVibrationEnabled() == null
|
|
|
|
|
? false
|
|
|
|
|
: permission.isVibrationEnabled();
|
|
|
|
|
blindValue = permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
|
|
|
|
|
vibration = permission.isVibrationEnabled() == null ? false : permission.isVibrationEnabled();
|
|
|
|
|
// accsibility = mediaQueryData.accessibleNavigation;
|
|
|
|
|
//setTheme(blindValue);
|
|
|
|
|
}
|
|
|
|
|
@ -310,19 +356,11 @@ class _GeneralSettings extends State<GeneralSettings>
|
|
|
|
|
|
|
|
|
|
getTheme(value) async {
|
|
|
|
|
if (value == 1) {
|
|
|
|
|
return invertThemes(
|
|
|
|
|
fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'Poppins'
|
|
|
|
|
);
|
|
|
|
|
return invertThemes(fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'Poppins');
|
|
|
|
|
} else if (value == 3) {
|
|
|
|
|
return bwThemes(
|
|
|
|
|
fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'Poppins'
|
|
|
|
|
);
|
|
|
|
|
return bwThemes(fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'Poppins');
|
|
|
|
|
} else {
|
|
|
|
|
return defaultTheme(
|
|
|
|
|
fontName:
|
|
|
|
|
Provider.of<ProjectViewModel>(context, listen: false).isArabic
|
|
|
|
|
? 'Cairo'
|
|
|
|
|
: 'Poppins');
|
|
|
|
|
return defaultTheme(fontName: Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 'Cairo' : 'Poppins');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|