diff --git a/lib/ui/routes/account_settings/account_image_settings.dart b/lib/ui/routes/account_settings/account_image_settings.dart new file mode 100644 index 0000000..5fdcb15 --- /dev/null +++ b/lib/ui/routes/account_settings/account_image_settings.dart @@ -0,0 +1,31 @@ +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +/// Account image settings section +/// +/// @author Pierre Hubert + +class AccountImageSettings extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(tr("Account image settings")), + ), + body: _AccountImageSettingsBody(), + ); + } +} + + +class _AccountImageSettingsBody extends StatefulWidget { + @override + __AccountImageSettingsBodyState createState() => __AccountImageSettingsBodyState(); +} + +class __AccountImageSettingsBodyState extends State<_AccountImageSettingsBody> { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/ui/routes/account_settings/account_settings_route.dart b/lib/ui/routes/account_settings/account_settings_route.dart new file mode 100644 index 0000000..2396372 --- /dev/null +++ b/lib/ui/routes/account_settings/account_settings_route.dart @@ -0,0 +1,51 @@ +import 'package:comunic/ui/routes/account_settings/account_image_settings.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:settings_ui/settings_ui.dart'; + +/// Account settings route +/// +/// @author Pierre HUBERT + +class AccountSettingsRoute extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(tr("Account settings")), + ), + body: _AccountSettingsBody(), + ); + } +} + +class _AccountSettingsBody extends StatefulWidget { + @override + __AccountSettingsBodyState createState() => __AccountSettingsBodyState(); +} + +class __AccountSettingsBodyState extends State<_AccountSettingsBody> { + @override + Widget build(BuildContext context) { + return SettingsList( + sections: [ + SettingsSection( + title: tr("Account settings"), + tiles: [ + SettingsTile( + title: tr("Account image"), + subtitle: tr("Customize your account image"), + leading: Icon(Icons.account_circle), + onTap: () => _openSection(AccountImageSettings()), + ) + ], + ) + ], + ); + } + + /// Open a settings setings + void _openSection(Widget w) { + Navigator.of(context).push(MaterialPageRoute(builder: (c) => w)); + } +} diff --git a/lib/ui/routes/home_route.dart b/lib/ui/routes/home_route.dart index 3d91e11..be727b3 100644 --- a/lib/ui/routes/home_route.dart +++ b/lib/ui/routes/home_route.dart @@ -1,4 +1,5 @@ import 'package:comunic/helpers/account_helper.dart'; +import 'package:comunic/ui/routes/account_settings/account_settings_route.dart'; import 'package:comunic/ui/routes/app_settings_route.dart'; import 'package:comunic/ui/routes/conversation_route.dart'; import 'package:comunic/ui/screens/conversations_list_screen.dart'; @@ -116,6 +117,10 @@ class _HomeRouteState extends HomeController { _openAppSettings(); break; + case BarCallbackActions.OPEN_ACCOUNT_SETTINGS: + _openAccountsSettings(); + break; + /// Show about dialog case BarCallbackActions.OPEN_ABOUT_DIALOG: showAboutAppDialog(context); @@ -218,6 +223,11 @@ class _HomeRouteState extends HomeController { .push(MaterialPageRoute(builder: (c) => AppSettingsRoute())); } + void _openAccountsSettings() { + Navigator.of(context) + .push(MaterialPageRoute(builder: (c) => AccountSettingsRoute())); + } + /// Handle logout requests from user Future _logoutRequested() async { if (!await showConfirmDialog( diff --git a/lib/ui/widgets/navbar_widget.dart b/lib/ui/widgets/navbar_widget.dart index bab0b30..4fa6176 100644 --- a/lib/ui/widgets/navbar_widget.dart +++ b/lib/ui/widgets/navbar_widget.dart @@ -20,6 +20,7 @@ enum BarCallbackActions { OPEN_GROUP_PAGE, OPEN_USER_PAGE, OPEN_USER_ACCESS_DENIED_PAGE, + OPEN_ACCOUNT_SETTINGS, OPEN_APP_SETTINGS, OPEN_USER_FRIENDS_LIST, OPEN_ABOUT_DIALOG, @@ -90,6 +91,7 @@ final _menuActionsItem = <_ActionMenuItem>[ _ActionMenuItem( label: tr("My Page"), action: BarCallbackActions.OPEN_MY_PAGE), _ActionMenuItem(label: tr("Groups"), action: BarCallbackActions.OPEN_GROUPS), + _ActionMenuItem(label: tr("Account settings"), action: BarCallbackActions.OPEN_ACCOUNT_SETTINGS), _ActionMenuItem( label: tr("App settings"), action: BarCallbackActions.OPEN_APP_SETTINGS), _ActionMenuItem( diff --git a/pubspec.lock b/pubspec.lock index b109512..fd3e2f0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -233,6 +233,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + settings_ui: + dependency: "direct main" + description: + name: settings_ui + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 7a83d79..8ed09cb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,9 @@ dependencies: # Parse emojies flutter_emoji: ^2.2.1+1 + # Build settings UI + settings_ui: ^0.2.0 + dev_dependencies: flutter_test: sdk: flutter