setting page inprogress

merge-update-with-lab-changes
Sultan Khan 5 years ago
parent 4c8c4e3725
commit d2f391ab7f

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; 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_notifier.dart';
import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
@ -24,7 +25,7 @@ class _GeneralSettings extends State<GeneralSettings>
bool camera =false; bool camera =false;
bool location =false; bool location =false;
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
var permission = new PermissionService();
@override @override
void initState() { void initState() {
getValues(); getValues();
@ -256,16 +257,16 @@ class _GeneralSettings extends State<GeneralSettings>
} }
break; break;
} }
sharedPref.setInt(THEME_VALUE, value); permission.setTheme(value);
} }
setVibration(value){ setVibration(value){
sharedPref.setBool(IS_VIBRATION, value); permission.setVibrationPermission(value);
} }
getValues() async{ getValues() async{
blindValue= await sharedPref.getInt(THEME_VALUE) ?? 0; blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled();
vibration= await sharedPref.getBool(IS_VIBRATION) ?? false; vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled();
} }
getTheme(value) async{ getTheme(value) async{
if(value ==1){ if(value ==1){

@ -6,11 +6,27 @@ import 'package:diplomaticquarterapp/models/Request.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:localstorage/localstorage.dart';
class PermissionService extends BaseService { class PermissionService extends BaseService {
AppSharedPreferences sharedPref = AppSharedPreferences(); final LocalStorage storage = new LocalStorage("permission");
AppGlobal appGlobal = new AppGlobal(); AppGlobal appGlobal = new AppGlobal();
setVibrationPermission(flag) async {
storage.setItem('isVibration', flag);
}
isVibrationEnabled() {
return storage.getItem('isVibration');
}
setTheme(flag) async {
storage.setItem('isTheme', flag);
}
isThemeEnabled() {
return storage.getItem('isTheme');
}
} }

@ -1,4 +1,6 @@
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
/// Button widget /// Button widget
@ -33,7 +35,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
double _buttonSize = 1.0; double _buttonSize = 1.0;
AnimationController _animationController; AnimationController _animationController;
Animation _animation; Animation _animation;
PermissionService permission = new PermissionService();
@override @override
void initState() { void initState() {
_animationController = AnimationController( _animationController = AnimationController(
@ -88,7 +90,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: Feedback.wrapForTap(widget.onTap, context), onTap: (){Feedback.wrapForTap(widget.onTap, context); if(permission.isVibrationEnabled()){ HapticFeedback.vibrate();}},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -1,12 +1,15 @@
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class DefaultButton extends StatelessWidget { class DefaultButton extends StatelessWidget {
final String text; final String text;
final Function onPress; final Function onPress;
final Color textColor; final Color textColor;
final Color color; final Color color;
PermissionService permission = new PermissionService();
DefaultButton(this.text, this.onPress, {this.color, this.textColor}); DefaultButton(this.text, this.onPress, {this.color, this.textColor});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -21,6 +24,6 @@ class DefaultButton extends StatelessWidget {
this.text, this.text,
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
), ),
onPressed: () => this.onPress())); onPressed: () =>{ this.onPress(), if(permission.isVibrationEnabled()){ HapticFeedback.vibrate()}}));
} }
} }

@ -40,6 +40,7 @@ dependencies:
# Native # Native
flutter_device_type: ^0.2.0 flutter_device_type: ^0.2.0
local_auth: ^0.6.2+3 local_auth: ^0.6.2+3
localstorage: ^3.0.3+6
maps_launcher: ^1.2.1 maps_launcher: ^1.2.1
url_launcher: ^5.5.0 url_launcher: ^5.5.0
shared_preferences: ^0.5.8 shared_preferences: ^0.5.8

Loading…
Cancel
Save