import 'package:diplomaticquarterapp/theme/theme_notifier.dart'; import 'package:diplomaticquarterapp/theme/theme_value.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'; class GeneralSettings extends StatefulWidget { @override _GeneralSettings createState() => _GeneralSettings(); } class _GeneralSettings extends State with TickerProviderStateMixin { var themeNotifier; int blindValue = 0; Widget build(BuildContext context) { bool isVibration = true; themeNotifier = Provider.of(context); return Container( child: ListView(scrollDirection: Axis.vertical, children: [ Container( padding: EdgeInsets.all(10), child: AppText( TranslationBase.of(context).modes, color: Colors.black, fontWeight: FontWeight.bold, ), ), Container( color: Colors.white, padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(TranslationBase.of(context).vibration), Switch( value: isVibration, onChanged: (value) { setState(() { isVibration = value; }); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, ) ], )), Container( color: Colors.white, padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText(TranslationBase.of(context).accessibility), Switch( value: isVibration, onChanged: (value) { setState(() { isVibration = value; }); }, 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: [ new Column( mainAxisAlignment: MainAxisAlignment.center, children: [ 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).permissions, color: Colors.black, fontWeight: FontWeight.bold, ), ), Container( color: Colors.white, padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText(TranslationBase.of(context).cameraPermission), Switch( value: isVibration, onChanged: (value) { setState(() { isVibration = value; }); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, ) ], )), Container( color: Colors.white, padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText(TranslationBase.of(context).locationPermission), Switch( value: isVibration, onChanged: (value) { setState(() { isVibration = value; }); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, ) ], )) ])); } setTheme(value) { switch (value) { case 0: themeNotifier.setTheme(defaultTheme); break; case 1: themeNotifier.setTheme(invertTheme); break; case 2: themeNotifier.setTheme(dimTheme); break; default: themeNotifier.setTheme(defaultTheme); break; } } }