You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/settings/general_setting.dart

435 lines
15 KiB
Dart

import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
4 years ago
import 'package:diplomaticquarterapp/theme/theme_notifier.dart';
import 'package:diplomaticquarterapp/theme/theme_value.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
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';
4 years ago
import 'package:provider/provider.dart';
4 years ago
import 'package:screen/screen.dart';
class GeneralSettings extends StatefulWidget {
@override
_GeneralSettings createState() => _GeneralSettings();
}
class _GeneralSettings extends State<GeneralSettings>
with TickerProviderStateMixin {
4 years ago
var themeNotifier;
int blindValue = 0;
4 years ago
bool vibration =false;
bool accsibility =false;
bool camera =false;
bool location =false;
var sharedPref = new AppSharedPreferences();
var permission = new PermissionService();
4 years ago
var mediaQueryData;
@override
void initState() {
getValues();
super.initState();
}
Widget build(BuildContext context) {
4 years ago
mediaQueryData = MediaQuery.of(context);
themeNotifier = Provider.of<ThemeNotifier>(context);
return Container(
child: ListView(scrollDirection: Axis.vertical, children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: AppText(
4 years ago
TranslationBase.of(context).modes,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
4 years ago
AppText(TranslationBase.of(context).vibration),
Switch(
4 years ago
value: vibration,
onChanged: (value) {
setState(() {
4 years ago
vibration = value;
});
setVibration(value);
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
4 years ago
AppText(TranslationBase.of(context).accessibility),
Switch(
4 years ago
value: accsibility,
onChanged: (value) {
setState(() {
4 years ago
accsibility = value;
});
4 years ago
//setAccisibility(value);
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
4 years ago
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);
},
),
],
),
],
)
])),
4 years ago
Container(
padding: EdgeInsets.all(10),
child: AppText(
4 years ago
TranslationBase.of(context).permissions,
4 years ago
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
4 years ago
AppText(TranslationBase.of(context).cameraPermission),
4 years ago
Switch(
4 years ago
value: camera,
4 years ago
onChanged: (value) {
setState(() {
4 years ago
camera = value;
4 years ago
});
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
Container(
color: Colors.white,
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
4 years ago
AppText(TranslationBase.of(context).locationPermission),
4 years ago
Switch(
4 years ago
value: location,
4 years ago
onChanged: (value) {
setState(() {
4 years ago
location = value;
4 years ago
});
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
))
]));
}
4 years ago
setTheme(value) async{
4 years ago
switch (value) {
case 0:
{
themeNotifier.setTheme(await getTheme(value));
Screen.setBrightness(1.0);
}
4 years ago
break;
case 1:
{
4 years ago
themeNotifier.setTheme(ThemeData(
fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans',
primarySwatch: Colors.grey,
visualDensity: VisualDensity.adaptivePlatformDensity,
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
hintColor: Colors.grey[400],
cardColor: Colors.black,
buttonColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: Colors.grey,
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,
backgroundColor: Colors.grey,
highlightColor: Colors.grey[100].withOpacity(0.4),
splashColor: Colors.transparent,
primaryColor: Colors.grey,
bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)),
cursorColor: Colors.grey,
iconTheme: IconThemeData(),
appBarTheme: AppBarTheme(
color: Colors.grey,
brightness: Brightness.dark,
elevation: 10.0,
actionsIconTheme: IconThemeData(
color: Colors.grey,
),
),
));
Screen.setBrightness(1.0);
}
4 years ago
break;
case 2:
themeNotifier.setTheme(await getTheme(value));
4 years ago
Screen.setBrightness(0.01);
break;
case 3:
{
themeNotifier.setTheme(await getTheme(value));
Screen.setBrightness(1.0);
}
4 years ago
break;
default:
{
themeNotifier.setTheme(await getTheme(value));
Screen.setBrightness(1.0);
}
4 years ago
break;
}
4 years ago
//permission.setTheme(value);
}
setVibration(value){
permission.setVibrationPermission(value);
}
4 years ago
setAccisibility(){
if(!accsibility){
}
// permission.setVibrationPermission(value);
}
getValues() async{
4 years ago
blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled();
accsibility =mediaQueryData.accessibleNavigation;
}
getTheme(value) async{
if(value ==1){
return ThemeData(
4 years ago
fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans',
primarySwatch: Colors.grey,
visualDensity: VisualDensity.adaptivePlatformDensity,
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
hintColor: Colors.grey[400],
cardColor: Colors.black,
buttonColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: Colors.grey,
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,
backgroundColor: Colors.grey,
highlightColor: Colors.grey[100].withOpacity(0.4),
splashColor: Colors.transparent,
primaryColor: Colors.grey,
bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)),
cursorColor: Colors.grey,
iconTheme: IconThemeData(),
appBarTheme: AppBarTheme(
color: Colors.grey,
brightness: Brightness.dark,
elevation: 10.0,
actionsIconTheme: IconThemeData(
color: Colors.grey,
),
),
);
}else if(value ==3){
return ThemeData(
4 years ago
fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans',
primarySwatch: Colors.grey,
visualDensity: VisualDensity.adaptivePlatformDensity,
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
hintColor: Colors.grey[400],
cardColor: Colors.black,
buttonColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: Colors.grey,
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,
backgroundColor: Colors.grey,
highlightColor: Colors.grey[100].withOpacity(0.4),
splashColor: Colors.transparent,
primaryColor: Colors.grey,
bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)),
cursorColor: Colors.grey,
iconTheme: IconThemeData(),
appBarTheme: AppBarTheme(
color: Colors.black45,
brightness: Brightness.dark,
elevation: 10.0,
actionsIconTheme: IconThemeData(
color: Colors.grey,
),
),
);
}else {
return ThemeData(
4 years ago
fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans',
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
hintColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: Color(0xffEEEEEE),
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,
backgroundColor: Colors.white,
highlightColor: Colors.grey[100].withOpacity(0.4),
splashColor: Colors.transparent,
primaryColor: Color(0xff40ACC9),
bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)),
cursorColor: Colors.grey,
cardColor: Colors.white,
iconTheme: IconThemeData(),
appBarTheme: AppBarTheme(
color: Color(0xff40ACC9),
brightness: Brightness.dark,
elevation: 10.0,
actionsIconTheme: IconThemeData(
color: Color(0xff40ACC9),
),
),
);
}
4 years ago
}
}