@ -1,7 +1,15 @@
import ' package:diplomaticquarterapp/config/shared_pref_kay.dart ' ;
import ' package:diplomaticquarterapp/services/permission/permission_service.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/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:provider/provider.dart ' ;
import ' package:screen/screen.dart ' ;
class GeneralSettings extends StatefulWidget {
@ override
@ -10,15 +18,30 @@ class GeneralSettings extends StatefulWidget {
class _GeneralSettings extends State < GeneralSettings >
with TickerProviderStateMixin {
var themeNotifier ;
int blindValue = 0 ;
bool vibration = false ;
bool accessibility = false ;
bool camera = false ;
bool location = false ;
var sharedPref = new AppSharedPreferences ( ) ;
var permission = new PermissionService ( ) ;
@ override
void initState ( ) {
getValues ( ) ;
super . initState ( ) ;
}
Widget build ( BuildContext context ) {
bool isVibration = true ;
var bindValue ;
themeNotifier = Provider . of < ThemeNotifier > ( context ) ;
return Container (
child: ListView ( scrollDirection: Axis . vertical , children: < Widget > [
Container (
padding: EdgeInsets . all ( 10 ) ,
child: AppText (
' Modes ' ,
TranslationBase . of ( context ) . modes ,
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
@ -29,13 +52,15 @@ class _GeneralSettings extends State<GeneralSettings>
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Text( ' Vibration touch feedback ' ) ,
AppText( TranslationBase . of ( context ) . vibration ) ,
Switch (
value: isV ibration,
value: v ibration,
onChanged: ( value ) {
setState ( ( ) {
isVibration = value ;
vibration = value ;
} ) ;
setVibration ( value ) ;
} ,
activeTrackColor: Colors . lightGreenAccent ,
activeColor: Colors . green ,
@ -48,12 +73,12 @@ class _GeneralSettings extends State<GeneralSettings>
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Text( ' Accsibility Mode ' ) ,
AppText( TranslationBase . of ( context ) . accessibility ) ,
Switch (
value: isVibration ,
value: accessibility ,
onChanged: ( value ) {
setState ( ( ) {
isVibration = value ;
accessibility = value ;
} ) ;
} ,
activeTrackColor: Colors . lightGreenAccent ,
@ -64,7 +89,7 @@ class _GeneralSettings extends State<GeneralSettings>
Container (
padding: EdgeInsets . all ( 10 ) ,
child: AppText (
' Modes for Partially Blind ' ,
TranslationBase . of ( context ) . blindMode ,
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
@ -82,14 +107,15 @@ class _GeneralSettings extends State<GeneralSettings>
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
new Text (
' Off ' ,
TranslationBase . of ( context ) . offTheme ,
style: new TextStyle ( fontSize: 16.0 ) ,
) ,
new Radio (
Radio (
value: 0 ,
groupValue: b indValue,
groupValue: b l indValue,
onChanged: ( value ) {
bindValue = value ;
setState ( ( ) = > { this . blindValue = value } ) ;
setTheme ( value ) ;
} ,
) ,
] ,
@ -98,16 +124,17 @@ class _GeneralSettings extends State<GeneralSettings>
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
new Text (
' Invert ' ,
TranslationBase . of ( context ) . invertTheme ,
style: new TextStyle (
fontSize: 16.0 ,
) ,
) ,
new Radio (
value: 1 ,
groupValue: b indValue,
groupValue: b l indValue,
onChanged: ( value ) {
bindValue = value ;
setState ( ( ) = > { this . blindValue = value } ) ;
setTheme ( value ) ;
} ,
)
] ,
@ -116,14 +143,15 @@ class _GeneralSettings extends State<GeneralSettings>
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
new Text (
' Dim ' ,
TranslationBase . of ( context ) . dimTheme ,
style: new TextStyle ( fontSize: 16.0 ) ,
) ,
new Radio (
value: 2 ,
groupValue: b indValue,
groupValue: b l indValue,
onChanged: ( value ) {
bindValue = value ;
setState ( ( ) = > { this . blindValue = value } ) ;
setTheme ( value ) ;
} ,
) ,
] ,
@ -132,14 +160,16 @@ class _GeneralSettings extends State<GeneralSettings>
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
new Text (
' Black and White ' ,
TranslationBase . of ( context ) . bwTheme ,
style: new TextStyle ( fontSize: 16.0 ) ,
) ,
new Radio (
value: 2 ,
groupValue: b indValue,
value: 3 ,
groupValue: b l indValue,
onChanged: ( value ) {
bindValue = value ;
setState ( ( ) = > { this . blindValue = value } ) ;
setTheme ( value ) ;
} ,
) ,
] ,
@ -150,7 +180,7 @@ class _GeneralSettings extends State<GeneralSettings>
Container (
padding: EdgeInsets . all ( 10 ) ,
child: AppText (
' Permission ' ,
TranslationBase . of ( context ) . permissions ,
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
@ -161,12 +191,12 @@ class _GeneralSettings extends State<GeneralSettings>
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Text( ' Camera ' ) ,
AppText( TranslationBase . of ( context ) . cameraPermission ) ,
Switch (
value: isVibration ,
value: camera ,
onChanged: ( value ) {
setState ( ( ) {
isVibration = value ;
camera = value ;
} ) ;
} ,
activeTrackColor: Colors . lightGreenAccent ,
@ -180,12 +210,12 @@ class _GeneralSettings extends State<GeneralSettings>
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Text( ' Location ' ) ,
AppText( TranslationBase . of ( context ) . locationPermission ) ,
Switch (
value: isVibr ation,
value: loc ation,
onChanged: ( value ) {
setState ( ( ) {
isVibr ation = value ;
loc ation = value ;
} ) ;
} ,
activeTrackColor: Colors . lightGreenAccent ,
@ -195,4 +225,165 @@ class _GeneralSettings extends State<GeneralSettings>
) )
] ) ) ;
}
setTheme ( value ) async {
switch ( value ) {
case 0 :
{
themeNotifier . setTheme ( await getTheme ( value ) ) ;
Screen . setBrightness ( 1.0 ) ;
}
break ;
case 1 :
{
themeNotifier . setTheme ( await getTheme ( value ) ) ;
Screen . setBrightness ( 1.0 ) ;
}
break ;
case 2 :
themeNotifier . setTheme ( await getTheme ( value ) ) ;
Screen . setBrightness ( 0.01 ) ;
break ;
case 3 :
{
themeNotifier . setTheme ( await getTheme ( value ) ) ;
Screen . setBrightness ( 1.0 ) ;
}
break ;
default :
{
themeNotifier . setTheme ( await getTheme ( value ) ) ;
Screen . setBrightness ( 1.0 ) ;
}
break ;
}
permission . setTheme ( value ) ;
}
setVibration ( value ) {
permission . setVibrationPermission ( value ) ;
}
getValues ( ) async {
blindValue = permission . isThemeEnabled ( ) = = null ? 0 : permission . isThemeEnabled ( ) ;
vibration = permission . isVibrationEnabled ( ) = = null ? false : permission . isVibrationEnabled ( ) ;
}
getTheme ( value ) async {
if ( value = = 1 ) {
return 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 ,
) ,
) ,
) ;
} else if ( value = = 3 ) {
return 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 . black45 ,
brightness: Brightness . dark ,
elevation: 10.0 ,
actionsIconTheme: IconThemeData (
color: Colors . grey ,
) ,
) ,
) ;
} else {
return ThemeData (
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 ) ,
) ,
) ,
) ;
}
}
}