diff --git a/lib/service/shared_prefs.dart b/lib/service/shared_prefs.dart index 01dba09..3383ef5 100644 --- a/lib/service/shared_prefs.dart +++ b/lib/service/shared_prefs.dart @@ -40,7 +40,7 @@ class SharedPrefs { } /// get/set langage - String get langage => _sharedPrefs.getString('key_langage') ?? ""; + String get langage => _sharedPrefs.getString('key_langage') ?? "fr"; set langage(String value) { _sharedPrefs.setString('key_langage', value); @@ -97,38 +97,38 @@ class SharedPrefs { } /// get/set isSimulator - bool get isSimulator => _sharedPrefs.getBool('key_issimulator') ?? false; + bool get isSimulator => _sharedPrefs.getBool('key_is_simulator') ?? false; set isSimulator(bool value) { - _sharedPrefs.setBool('key_issimulator', value); + _sharedPrefs.setBool('key_is_simulator', value); } /// get/set application's document directory - String get documentsDir => _sharedPrefs.getString('documentsDir') ?? ""; + String get documentsDir => _sharedPrefs.getString('key_documents_dir') ?? ""; set documentsDir(String value) { - _sharedPrefs.setString('documentsDir', value); + _sharedPrefs.setString('key_documents_dir', value); } /// get/set application's photo directory - String get photosDir => _sharedPrefs.getString('photosDir') ?? ""; + String get photosDir => _sharedPrefs.getString('key_photos_dir') ?? ""; set photosDir(String value) { - _sharedPrefs.setString('photosDir', value); + _sharedPrefs.setString('key_photos_dir', value); } /// get/set application's cache directory - String get cacheDir => _sharedPrefs.getString('cacheDir') ?? ""; + String get cacheDir => _sharedPrefs.getString('key_cache_dir') ?? ""; set cacheDir(String value) { - _sharedPrefs.setString('cacheDir', value); + _sharedPrefs.setString('key_cache_dir', value); } /// get/set url MP4 - String get urlMP4 => _sharedPrefs.getString('urlMP4') ?? ""; + String get urlMP4 => _sharedPrefs.getString('key_url_mp4') ?? ""; set urlMP4(String value) { - _sharedPrefs.setString('urlMP4', value); + _sharedPrefs.setString('key_url_mp4', value); } /// get/set onboarding visualizaton @@ -140,17 +140,39 @@ class SharedPrefs { /// Get/set last calendar refresh String get lastCalendarRefresh => - _sharedPrefs.getString('key_lastCalendarRefresh') ?? ""; + _sharedPrefs.getString('key_last_calendar_refresh') ?? ""; set lastCalendarRefresh(String value) { - _sharedPrefs.setString('key_lastCalendarRefresh', value); + _sharedPrefs.setString('key_last_calendar_refresh', value); } /// Get/set userAgent String get mobileUserAgent => - _sharedPrefs.getString('key_mobileUserAgent') ?? ""; + _sharedPrefs.getString('key_mobile_user_agent') ?? ""; set mobileUserAgent(String value) { - _sharedPrefs.setString('key_mobileUserAgent', value); + _sharedPrefs.setString('key_mobile_user_agent', value); + } + + /// get/set photo quality + String get photoQuality => + _sharedPrefs.getString('key_photo_quality') ?? "Defaut"; + + set photoQuality(String value) { + _sharedPrefs.setString('key_photo_quality', value); + } + + /// get/set photo resising + bool get photoResizing => _sharedPrefs.getBool('key_photo_resizing') ?? true; + + set photoResizing(bool value) { + _sharedPrefs.setBool('key_photo_resizing', value); + } + + /// get/set photo sound + bool get photoSound => _sharedPrefs.getBool('key_photo_sound') ?? true; + + set photoSound(bool value) { + _sharedPrefs.setBool('key_photo_sound', value); } } diff --git a/lib/ui/account/notification_setting.dart b/lib/ui/account/notification_setting.dart deleted file mode 100644 index 1237d4f..0000000 --- a/lib/ui/account/notification_setting.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:mobdr/config/constant.dart'; -import 'package:mobdr/config/global_style.dart'; -import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:flutter/material.dart'; - -class NotificationSettingPage extends StatefulWidget { - @override - _NotificationSettingPageState createState() => - _NotificationSettingPageState(); -} - -class _NotificationSettingPageState extends State { - // initialize reusable widget - final _reusableWidget = ReusableWidget(); - - bool _valChat = true; - bool _valPromotion = true; - bool _valOrderStatus = true; - - @override - void initState() { - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: GlobalStyle.appBarIconThemeColor, - ), - elevation: GlobalStyle.appBarElevation, - title: Text( - 'Notification Setting', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - bottom: _reusableWidget.bottomAppBar(), - ), - body: ListView( - children: [ - _buildSwitchPromotion(), - Divider(height: 0, color: Colors.grey[400]), - _buildSwitchChat(), - Divider(height: 0, color: Colors.grey[400]), - _buildSwitchOrderStatus(), - Divider(height: 0, color: Colors.grey[400]), - ], - )); - } - - Widget _buildSwitchPromotion() { - return SwitchListTile( - contentPadding: EdgeInsets.only(left: 16, right: 4), - title: Text( - 'Promotion', - style: TextStyle(fontSize: 15, color: CHARCOAL), - ), - value: _valPromotion, - activeColor: PRIMARY_COLOR, - onChanged: (bool value) { - setState(() { - _valPromotion = value; - }); - }, - ); - } - - Widget _buildSwitchChat() { - return SwitchListTile( - contentPadding: EdgeInsets.only(left: 16, right: 4), - title: Text( - 'Chat', - style: TextStyle(fontSize: 15, color: CHARCOAL), - ), - value: _valChat, - activeColor: PRIMARY_COLOR, - onChanged: (bool value) { - setState(() { - _valChat = value; - }); - }, - ); - } - - Widget _buildSwitchOrderStatus() { - return SwitchListTile( - contentPadding: EdgeInsets.only(left: 16, right: 4), - title: Text( - 'New Order Status', - style: TextStyle(fontSize: 15, color: CHARCOAL), - ), - value: _valOrderStatus, - activeColor: PRIMARY_COLOR, - onChanged: (bool value) { - setState(() { - _valOrderStatus = value; - }); - }, - ); - } -} diff --git a/lib/ui/account/settings.dart b/lib/ui/account/settings.dart new file mode 100644 index 0000000..ffaedd5 --- /dev/null +++ b/lib/ui/account/settings.dart @@ -0,0 +1,338 @@ +import 'package:flutter/material.dart'; + +import 'package:mobdr/config/constant.dart'; +import 'package:mobdr/config/global_style.dart'; +import 'package:mobdr/ui/reusable/reusable_widget.dart'; +import 'package:mobdr/service/shared_prefs.dart'; + +class SettingsPage extends StatefulWidget { + @override + _SettingsPageState createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State { + // initialize reusable widget + final _reusableWidget = ReusableWidget(); + + late String _photoQuality; + late bool _photoResizing; + late bool _photoSound; + late String _language; + + @override + void initState() { + super.initState(); + + setState(() { + _photoQuality = SharedPrefs().photoQuality; + _photoResizing = SharedPrefs().photoResizing; + _photoSound = SharedPrefs().photoSound; + + switch (SharedPrefs().langage) { + case 'en': + _language = 'English'; + break; + case 'fr': + _language = 'French'; + break; + default: + _language = 'French'; + break; + } + }); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + iconTheme: IconThemeData( + color: GlobalStyle.appBarIconThemeColor, + ), + elevation: GlobalStyle.appBarElevation, + title: Text( + 'Settings', + style: GlobalStyle.appBarTitle, + ), + backgroundColor: GlobalStyle.appBarBackgroundColor, + systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, + bottom: _reusableWidget.bottomAppBar(), + ), + body: ListView( + children: [ + _buildSettingsContainer(), + Divider(height: 0, color: Colors.grey[400]), + _buildLanguageContainer(), + Divider(height: 0, color: Colors.grey[400]), + ], + )); + } + + Widget _buildSettingsContainer() { + return Container( + color: Colors.white, + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return _showQualityPopup(); + }, + ); + }, + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Photo quality', + style: TextStyle(fontSize: 15, color: CHARCOAL)), + Row( + children: [ + Text( + _photoQuality, + style: TextStyle( + color: CHARCOAL, + fontWeight: FontWeight.bold, + ), + ), + Icon( + Icons.chevron_right, + size: 20, + color: SOFT_GREY, + ), + ], + ), + ], + ), + ), + Divider(height: 0, color: Colors.grey[400]), + Padding( + padding: EdgeInsets.only(left: 16, right: 4), + child: SwitchListTile( + contentPadding: EdgeInsets.zero, + title: Text( + 'Photo resizing', + style: TextStyle(fontSize: 15, color: CHARCOAL), + ), + value: _photoResizing, + activeColor: PRIMARY_COLOR, + onChanged: (bool value) { + setState(() { + _photoResizing = value; + SharedPrefs().photoResizing = value; + }); + }, + ), + ), + Divider(height: 0, color: Colors.grey[400]), + Padding( + padding: EdgeInsets.only(left: 16, right: 4), + child: SwitchListTile( + contentPadding: EdgeInsets.zero, + title: Text( + 'Play sound when taking a photo', + style: TextStyle(fontSize: 15, color: CHARCOAL), + ), + value: _photoSound, + activeColor: PRIMARY_COLOR, + onChanged: (bool value) { + setState(() { + _photoSound = value; + SharedPrefs().photoSound = value; + }); + }, + ), + ), + ], + ), + ), + ); + } + + Widget _buildLanguageContainer() { + return GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return _showLanguagePopup(); + }, + ); + }, + child: Container( + color: Colors.white, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Language', style: TextStyle(fontSize: 15, color: CHARCOAL)), + Row( + children: [ + Text( + _language, + style: TextStyle( + color: CHARCOAL, + fontWeight: FontWeight.bold, + ), + ), + Icon( + Icons.chevron_right, + size: 20, + color: SOFT_GREY, + ), + ], + ), + ], + ), + ), + ), + ); + } + + Widget _showQualityPopup() { + List qualityOptions = ['Defaut', 'High', 'Medium', 'Low']; + + return StatefulBuilder( + builder: (BuildContext context, StateSetter mystate) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + margin: EdgeInsets.only(top: 12, bottom: 12), + width: 40, + height: 4, + decoration: BoxDecoration( + color: Colors.grey[500], + borderRadius: BorderRadius.circular(10), + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + 'Choose Quality', + style: GlobalStyle.chooseCourier, + ), + ), + Flexible( + child: ListView.builder( + padding: EdgeInsets.all(16), + itemCount: qualityOptions.length, + itemBuilder: (BuildContext context, int index) { + String qualityOption = qualityOptions[index]; + return GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + setState(() { + _photoQuality = qualityOption; + SharedPrefs().photoQuality = qualityOption; + }); + Navigator.pop(context); + }, + child: Container( + margin: EdgeInsets.only(top: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + qualityOption, + style: GlobalStyle.courierType, + ), + ], + ), + ), + ); + }, + ), + ), + ], + ); + }, + ); + } + + Widget _showLanguagePopup() { + List languageOptions = ['English', 'French']; + + return StatefulBuilder( + builder: (BuildContext context, StateSetter mystate) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + margin: EdgeInsets.only(top: 12, bottom: 12), + width: 40, + height: 4, + decoration: BoxDecoration( + color: Colors.grey[500], + borderRadius: BorderRadius.circular(10), + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + 'Choose Language', + style: GlobalStyle.chooseCourier, + ), + ), + Flexible( + child: ListView.builder( + padding: EdgeInsets.all(16), + itemCount: languageOptions.length, + itemBuilder: (BuildContext context, int index) { + String languageOption = languageOptions[index]; + return GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + setState(() { + _language = languageOption; + switch (languageOption) { + case 'English': + SharedPrefs().langage = 'en'; + break; + case 'French': + SharedPrefs().langage = 'fr'; + break; + default: + _language = 'French'; + break; + } + }); + Navigator.pop(context); + }, + child: Container( + margin: EdgeInsets.only(top: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + languageOption, + style: GlobalStyle.courierType, + ), + ], + ), + ), + ); + }, + ), + ), + ], + ); + }, + ); + } +} diff --git a/lib/ui/account/tab_account.dart b/lib/ui/account/tab_account.dart index c47414c..3c319df 100644 --- a/lib/ui/account/tab_account.dart +++ b/lib/ui/account/tab_account.dart @@ -7,7 +7,7 @@ import 'package:mobdr/config/constant.dart'; import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/ui/account/about.dart'; -import 'package:mobdr/ui/account/notification_setting.dart'; +import 'package:mobdr/ui/account/settings.dart'; import 'package:mobdr/ui/account/log.dart'; import 'package:mobdr/ui/general/notification.dart'; import 'package:mobdr/ui/reusable/reusable_widget.dart'; @@ -72,7 +72,7 @@ class _TabAccountPageState extends State padding: EdgeInsets.all(16), children: [ _createAccountInformation(), - _createListMenu('Notification Setting', NotificationSettingPage()), + _createListMenu('Settings', SettingsPage()), _reusableWidget.divider1(), _createListMenu('About', AboutPage()), _reusableWidget.divider1(),