import 'package:camera/camera.dart'; import 'package:teso/Pages/PageWidgets/Settings/privacy.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:teso/Classes/TesoUser.dart'; import 'package:teso/Pages/PageWidgets/Settings/AccountSettings.dart'; import 'package:teso/Pages/PageWidgets/Settings/EditProfile.dart'; import 'package:teso/Pages/PageWidgets/Settings/terms.dart'; import 'package:teso/Pages/Sub_Pages/AccountSettings/BlockedUser.dart'; import 'package:teso/Pages/Sub_Pages/PersonalSub/Referral.dart'; import 'package:teso/providers/app_provider.dart'; import 'package:teso/providers/pageAnimations.dart'; import 'package:teso/providers/user_provider.dart'; import 'package:teso/providers/device_provider.dart'; import 'package:teso/util/consts.dart'; class Setting extends StatefulWidget { final Function? logOut; final List? connectedCameras; const Setting({Key? key, this.logOut, this.connectedCameras}) : super(key: key); @override _SettingState createState() => _SettingState(logOut: this.logOut); } class _SettingState extends State { Function? logOut; _SettingState({this.logOut}); bool enabled = true; TesoUser? currentUser; @override void initState() { super.initState(); } void editProfileDialog(context, TesoUser? user) { showModalBottomSheet( context: context, isScrollControlled: true, enableDrag: true, shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(30.0)), ), builder: (BuildContext bc) { return EditProfile( userProfile: user, // connectedCameras: widget.connectedCameras, ); }); } void accountSettingsDialog(context) { showModalBottomSheet( context: context, isScrollControlled: true, enableDrag: true, shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(30.0)), ), builder: (BuildContext bc) { return AccountSettings(); }); } @override Widget build(BuildContext context) { return Container( height: MediaQuery.of(context).size.height * 0.9, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: new Wrap( children: [ new Container( margin: EdgeInsets.only( left: 20.0, top: 20.0, bottom: 12.0, ), child: Row( children: [ Container( child: InkWell( onTap: () => Navigator.pop(context), child: Icon(Icons.close), ), ), Expanded( child: Container( width: double.infinity, child: Center( child: Text( "Settings", style: TextStyle( fontSize: 20.0, ), ), ), ), ), ], )), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Divider(), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Text( "Personnal Information", style: TextStyle(fontSize: 15), ), ), new Consumer( builder: (BuildContext context, UserProvider user, Widget? child) { if (user.currentUser == null) { return Container(); } else { return new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('Edit Profile'), onTap: () => editProfileDialog(context, user.currentUser), ); } }, ), new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('Account settings'), onTap: () => accountSettingsDialog(context), ), new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('Refer and Earn'), onTap: () { Navigator.push( context, PageTransition( type: PageTransitionType.rightToLeft, child: Referrals(), ), ); }, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Divider(), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Text("Connections"), ), new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('Blocked accounts'), onTap: () => Navigator.push( context, PageTransition( child: BlockAccounts(), type: PageTransitionType.leftToRight)), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Divider(), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Text("Support"), ), new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('Terms of use'), onTap: () => Navigator.push( context, PageTransition( child: TermsUse(), type: PageTransitionType.leftToRight)), ), new ListTile( trailing: new Icon(Icons.arrow_forward_ios), title: new Text('See Privacy Policy'), onTap: () => Navigator.push( context, PageTransition( child: Privacy(), type: PageTransitionType.leftToRight)), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Divider(), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Text("Actions"), ), new Consumer(builder: (BuildContext context, DeviceProvider value, Widget? child) { return SwitchListTile( secondary: Icon(Icons.camera), title: Text( "Coupon Alerts", ), subtitle: Text( "Enabling coupon alerts would you allow receive proximity coupons"), value: value.serviceEnabled == null ? false : value.serviceEnabled!, onChanged: (v) { Provider.of(context, listen: false) .toggleBackgroundMode(context); }, ); }), new Consumer(builder: (BuildContext context, UserProvider value, Widget? child) { return SwitchListTile( secondary: Icon( Icons.dark_mode_outlined, ), title: Text( "Dark Mode", ), value: Provider.of(context).theme == Constants.lightTheme ? false : true, onChanged: (v) { if (v) { Provider.of(context, listen: false) .setTheme(Constants.darkTheme, "dark"); } else { Provider.of(context, listen: false) .setTheme(Constants.lightTheme, "light"); } }, ); }), new ListTile( title: new Text('Log out'), onTap: () => logOut!(), ), ], ), ), ); } }