From 46f9c917b523bc5782c57e5b4f3b7267b4b9fb4d Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 23 Apr 2021 13:43:24 +0200 Subject: [PATCH] Start to update tour route --- lib/ui/dialogs/pick_file_dialog.dart | 7 +- lib/ui/routes/TourRoute.dart | 166 ++---------------- .../widgets/tour/account_image_tour_pane.dart | 19 ++ lib/ui/widgets/tour/first_pane.dart | 30 ++++ .../tour/fixed_tour_size_text_area.dart | 16 ++ lib/ui/widgets/tour/last_pane.dart | 18 ++ lib/ui/widgets/tour/presentation_pane.dart | 87 +++++++++ 7 files changed, 189 insertions(+), 154 deletions(-) create mode 100644 lib/ui/widgets/tour/account_image_tour_pane.dart create mode 100644 lib/ui/widgets/tour/first_pane.dart create mode 100644 lib/ui/widgets/tour/fixed_tour_size_text_area.dart create mode 100644 lib/ui/widgets/tour/last_pane.dart create mode 100644 lib/ui/widgets/tour/presentation_pane.dart diff --git a/lib/ui/dialogs/pick_file_dialog.dart b/lib/ui/dialogs/pick_file_dialog.dart index 677d6d5..3ff8110 100644 --- a/lib/ui/dialogs/pick_file_dialog.dart +++ b/lib/ui/dialogs/pick_file_dialog.dart @@ -1,4 +1,5 @@ import 'package:comunic/models/api_request.dart'; +import 'package:comunic/models/config.dart'; import 'package:comunic/ui/dialogs/record_audio_dialog.dart'; import 'package:comunic/ui/routes/image_editor_route.dart'; import 'package:comunic/utils/files_utils.dart'; @@ -202,6 +203,7 @@ class _BottomSheetPickOption extends StatelessWidget { @override Widget build(BuildContext context) => Container( + color: config().splashBackgroundColor, height: 255, child: Center( child: ConstrainedBox( @@ -209,8 +211,9 @@ class _BottomSheetPickOption extends StatelessWidget { child: ListView.builder( itemCount: options.length, itemBuilder: (c, i) => ListTile( - leading: Icon(options[i].icon), - title: Text(options[i].label), + leading: Icon(options[i].icon, color: Colors.white), + title: Text(options[i].label, + style: TextStyle(color: Colors.white)), onTap: () => onOptionSelected(options[i].value), ), ), diff --git a/lib/ui/routes/TourRoute.dart b/lib/ui/routes/TourRoute.dart index 86c942f..ca6edfb 100644 --- a/lib/ui/routes/TourRoute.dart +++ b/lib/ui/routes/TourRoute.dart @@ -2,10 +2,12 @@ import 'package:comunic/helpers/preferences_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/models/user.dart'; import 'package:comunic/ui/routes/push_notifications_route.dart'; -import 'package:comunic/ui/routes/settings/account_image_settings.dart'; -import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/ui/widgets/tour/account_image_tour_pane.dart'; +import 'package:comunic/ui/widgets/tour/first_pane.dart'; +import 'package:comunic/ui/widgets/tour/last_pane.dart'; +import 'package:comunic/ui/widgets/tour/presentation_pane.dart'; import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; @@ -39,24 +41,13 @@ class _TourRouteState extends State { } List get _list => [ - _FirstPane(), + FirstTourPane(), // Account image - _PresentationPane( - iconWidget: AccountImageWidget(user: currUser, width: 50), - title: tr("Account image"), - text: tr( - "Account image allow to quickly recognize people.\n\nYou can decide to define one now!"), - actionTitle: tr("Upload an account image"), - onActionTap: (ctx) async { - await uploadNewAccountImage(context); - _defaultIndex = DefaultTabController.of(ctx).index; - await key.currentState.refresh(); - }, - ), + AccountImageTourPane(user: currUser), // Notifications - _PresentationPane( + PresentationPane( icon: Icons.notifications, title: tr("Push notifications"), child: (c) => PushNotificationsConfigurationWidget( @@ -68,31 +59,31 @@ class _TourRouteState extends State { onTapNext: (c) => _pushNotificationsKey.currentState.submit(), ), - _PresentationPane( + PresentationPane( icon: Icons.group_add, title: tr("Friends"), text: tr( "You can search the people you know and ask them to become your friends!\n\nThis will help you to reach them to exchange information!"), ), - _PresentationPane( + PresentationPane( icon: Icons.question_answer, title: tr("Conversations"), text: tr( "With Comunic, you can have conversations with all your friends.\n\nIt is also possible to make video calls!"), ), - _PresentationPane( + PresentationPane( icon: Icons.group, title: tr("Groups"), text: tr( "You can join groups where people share the same interests as you!\n\nIt is also easy to create your own groups!"), ), - _PresentationPane( + PresentationPane( icon: Icons.lock, title: tr("Privacy"), text: tr( "Your data is YOUR DATA. We will never use it or sell it.\n\nIf you do not trust us, you can always check out our source code to verify it!"), ), - _LastPane(), + LastTourPane(), ]; @override @@ -130,8 +121,8 @@ class __RouteBodyState extends State<_RouteBody> { bool get _isLastPane => _controller.index >= widget.panes.length - 1; - _PresentationPane get _currPane => - widget.panes[_controller.index] is _PresentationPane + PresentationPane get _currPane => + widget.panes[_controller.index] is PresentationPane ? widget.panes[_controller.index] : null; @@ -195,132 +186,3 @@ class __RouteBodyState extends State<_RouteBody> { } } } - -class _PresentationPane extends StatelessWidget { - final IconData icon; - final Widget iconWidget; - final String title; - final String text; - final Function(BuildContext) child; - final String actionTitle; - final Function(BuildContext) onActionTap; - final bool canGoNext; - final Future Function(BuildContext) onTapNext; - - const _PresentationPane({ - Key key, - this.icon, - this.iconWidget, - @required this.title, - this.text, - this.child, - this.actionTitle, - this.onActionTap, - this.canGoNext = true, - this.onTapNext, - }) : assert(icon != null || iconWidget != null), - assert(title != null), - assert(text != null || child != null), - super(key: key); - - bool get _hasAction => actionTitle != null && onActionTap != null; - - @override - Widget build(BuildContext context) { - if (text != null) - return Column( - children: [ - Spacer(flex: 3), - icon != null ? Icon(icon, color: Colors.white, size: 50) : iconWidget, - Spacer(flex: 1), - Text( - title, - style: TextStyle(fontSize: 20), - ), - Spacer(flex: 1), - _FixedSizeTextArea(text), - Spacer(flex: 1), - _hasAction - ? OutlinedButton( - onPressed: () => onActionTap(context), - child: Text( - actionTitle, - style: TextStyle(color: Colors.white), - ), - ) - : Opacity( - opacity: 0, - child: OutlinedButton( - onPressed: null, - child: Text(""), - ), - ), - Spacer(flex: 3), - ], - ); - - return Column( - children: [ - Spacer(flex: 1), - icon != null ? Icon(icon, color: Colors.white, size: 50) : iconWidget, - Spacer(flex: 1), - Text( - title, - style: TextStyle(fontSize: 20), - ), - Spacer(flex: 1), - ConstrainedBox( - constraints: BoxConstraints(maxHeight: 300), - child: SingleChildScrollView(child: child(context))), - Spacer(flex: 1), - ], - ); - } -} - -class _FirstPane extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Spacer(flex: 3), - Text( - "Comunic", - style: TextStyle(fontSize: 25), - ), - Spacer(flex: 2), - _FixedSizeTextArea(tr( - "Welcome to Comunic, the social network that respect your privacy !")), - Spacer(flex: 1), - _FixedSizeTextArea(tr( - "Let's configure a few things and present you some features of the network...")), - Spacer(flex: 3), - ], - ); - } -} - -class _LastPane extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Center( - child: Text( - tr("The application is yours"), - style: TextStyle(fontSize: 25), - ), - ); - } -} - -class _FixedSizeTextArea extends StatelessWidget { - final String text; - - const _FixedSizeTextArea(this.text); - - @override - Widget build(BuildContext context) => ConstrainedBox( - constraints: BoxConstraints(maxWidth: 300), - child: Text(text, textAlign: TextAlign.justify), - ); -} diff --git a/lib/ui/widgets/tour/account_image_tour_pane.dart b/lib/ui/widgets/tour/account_image_tour_pane.dart new file mode 100644 index 0000000..fcccb15 --- /dev/null +++ b/lib/ui/widgets/tour/account_image_tour_pane.dart @@ -0,0 +1,19 @@ +import 'package:comunic/models/user.dart'; +import 'package:comunic/ui/routes/settings/account_image_settings.dart'; +import 'package:comunic/ui/widgets/account_image_widget.dart'; +import 'package:comunic/ui/widgets/tour/presentation_pane.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +class AccountImageTourPane extends PresentationPane { + AccountImageTourPane({@required User user}) + : super( + iconWidget: AccountImageWidget(user: user, width: 50), + title: tr("Account image"), + text: tr( + "Account image allow to quickly recognize people.\n\nYou can decide to define one now!"), + actionTitle: tr("Upload an account image"), + onActionTap: (ctx) async { + await uploadNewAccountImage(ctx); + }); +} diff --git a/lib/ui/widgets/tour/first_pane.dart b/lib/ui/widgets/tour/first_pane.dart new file mode 100644 index 0000000..989ca9b --- /dev/null +++ b/lib/ui/widgets/tour/first_pane.dart @@ -0,0 +1,30 @@ +import 'package:comunic/ui/widgets/tour/fixed_tour_size_text_area.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +/// First tour pane +/// +/// @author Pierre Hubert + +class FirstTourPane extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Spacer(flex: 3), + Text( + "Comunic", + style: TextStyle(fontSize: 25), + ), + Spacer(flex: 2), + FixedTourSizeTextArea(tr( + "Welcome to Comunic, the social network that respect your privacy!")), + Spacer(flex: 1), + FixedTourSizeTextArea(tr( + "Let's configure a few things and present you some features of the network...")), + Spacer(flex: 3), + ], + ); + } +} diff --git a/lib/ui/widgets/tour/fixed_tour_size_text_area.dart b/lib/ui/widgets/tour/fixed_tour_size_text_area.dart new file mode 100644 index 0000000..c7d34bb --- /dev/null +++ b/lib/ui/widgets/tour/fixed_tour_size_text_area.dart @@ -0,0 +1,16 @@ +/// Fixed tour size text area +/// +/// @author Pierre Hubert +import 'package:flutter/material.dart'; + +class FixedTourSizeTextArea extends StatelessWidget { + final String text; + + const FixedTourSizeTextArea(this.text); + + @override + Widget build(BuildContext context) => ConstrainedBox( + constraints: BoxConstraints(maxWidth: 300), + child: Text(text, textAlign: TextAlign.justify), + ); +} diff --git a/lib/ui/widgets/tour/last_pane.dart b/lib/ui/widgets/tour/last_pane.dart new file mode 100644 index 0000000..54e3ea8 --- /dev/null +++ b/lib/ui/widgets/tour/last_pane.dart @@ -0,0 +1,18 @@ +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +/// Last tour pane +/// +/// @author Pierre Hubert + +class LastTourPane extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Center( + child: Text( + tr("The application is yours"), + style: TextStyle(fontSize: 25), + ), + ); + } +} diff --git a/lib/ui/widgets/tour/presentation_pane.dart b/lib/ui/widgets/tour/presentation_pane.dart new file mode 100644 index 0000000..0dc60eb --- /dev/null +++ b/lib/ui/widgets/tour/presentation_pane.dart @@ -0,0 +1,87 @@ +/// Application presentation tour pane +/// +/// @author Pierre Hubert +import 'package:comunic/ui/widgets/tour/fixed_tour_size_text_area.dart'; +import 'package:flutter/material.dart'; + +class PresentationPane extends StatelessWidget { + final IconData icon; + final Widget iconWidget; + final String title; + final String text; + final Function(BuildContext) child; + final String actionTitle; + final Function(BuildContext) onActionTap; + final bool canGoNext; + final Future Function(BuildContext) onTapNext; + + const PresentationPane({ + Key key, + this.icon, + this.iconWidget, + @required this.title, + this.text, + this.child, + this.actionTitle, + this.onActionTap, + this.canGoNext = true, + this.onTapNext, + }) : assert(icon != null || iconWidget != null), + assert(title != null), + assert(text != null || child != null), + super(key: key); + + bool get _hasAction => actionTitle != null && onActionTap != null; + + @override + Widget build(BuildContext context) { + if (text != null) + return Column( + children: [ + Spacer(flex: 3), + icon != null ? Icon(icon, color: Colors.white, size: 50) : iconWidget, + Spacer(flex: 1), + Text( + title, + style: TextStyle(fontSize: 20), + ), + Spacer(flex: 1), + FixedTourSizeTextArea(text), + Spacer(flex: 1), + _hasAction + ? OutlinedButton( + onPressed: () => onActionTap(context), + child: Text( + actionTitle, + style: TextStyle(color: Colors.white), + ), + ) + : Opacity( + opacity: 0, + child: OutlinedButton( + onPressed: null, + child: Text(""), + ), + ), + Spacer(flex: 3), + ], + ); + + return Column( + children: [ + Spacer(flex: 1), + icon != null ? Icon(icon, color: Colors.white, size: 50) : iconWidget, + Spacer(flex: 1), + Text( + title, + style: TextStyle(fontSize: 20), + ), + Spacer(flex: 1), + ConstrainedBox( + constraints: BoxConstraints(maxHeight: 300), + child: SingleChildScrollView(child: child(context))), + Spacer(flex: 1), + ], + ); + } +}