From b8dc6c1e1477bff3418f1c6dc628b6d525b04e96 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 28 Dec 2021 19:30:19 +0100 Subject: [PATCH] chore: enhance stories --- assets/l10n/intl_en.arb | 3 +- lib/config/routes.dart | 12 +++++ lib/pages/add_story/add_story.dart | 2 +- lib/pages/add_story/invite_story_page.dart | 11 +++++ .../settings_stories_view.dart | 17 ++++++- lib/pages/story/story_page.dart | 44 ++++++++++++++++++- lib/pages/story/story_view.dart | 19 ++++++-- 7 files changed, 100 insertions(+), 8 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index beb6e378..28737638 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2684,5 +2684,6 @@ "date": {}, "body": {} } - } + }, + "whoCanSeeMyStoriesDesc": "Please note that people can see and contact each other in your story." } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 86e9a12c..b6a456f2 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -61,6 +61,12 @@ class AppRoutes { VWidget( path: '/stories/:roomid', widget: const StoryPage(), + stackedRoutes: [ + VWidget( + path: 'share', + widget: const AddStoryPage(), + ), + ], ), VWidget( path: '/spaces/:roomid', @@ -133,6 +139,12 @@ class AppRoutes { path: '/stories/:roomid', buildTransition: _fadeTransition, widget: const StoryPage(), + stackedRoutes: [ + VWidget( + path: 'share', + widget: const AddStoryPage(), + ), + ], ), VWidget( path: '/spaces/:roomid', diff --git a/lib/pages/add_story/add_story.dart b/lib/pages/add_story/add_story.dart index ceb33fae..cf4c15ec 100644 --- a/lib/pages/add_story/add_story.dart +++ b/lib/pages/add_story/add_story.dart @@ -142,7 +142,7 @@ class AddStoryController extends State { }, ); if (postResult.error == null) { - VRouter.of(context).to('/rooms'); + VRouter.of(context).pop(); } } diff --git a/lib/pages/add_story/invite_story_page.dart b/lib/pages/add_story/invite_story_page.dart index 5852b66f..01273eae 100644 --- a/lib/pages/add_story/invite_story_page.dart +++ b/lib/pages/add_story/invite_story_page.dart @@ -73,6 +73,17 @@ class _InviteStoryPageState extends State { onPressed: () => Navigator.of(context).pop(false), ), title: Text(L10n.of(context)!.whoCanSeeMyStories), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(56), + child: ListTile( + title: Text(L10n.of(context)!.whoCanSeeMyStoriesDesc), + leading: CircleAvatar( + backgroundColor: Theme.of(context).secondaryHeaderColor, + foregroundColor: Theme.of(context).colorScheme.secondary, + child: const Icon(Icons.lock), + ), + ), + ), ), body: FutureBuilder>( future: loadContacts, diff --git a/lib/pages/settings_stories/settings_stories_view.dart b/lib/pages/settings_stories/settings_stories_view.dart index b77008ba..ff287b3e 100644 --- a/lib/pages/settings_stories/settings_stories_view.dart +++ b/lib/pages/settings_stories/settings_stories_view.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; + import 'package:fluffychat/pages/settings_stories/settings_stories.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/widgets/avatar.dart'; @@ -13,7 +15,20 @@ class SettingsStoriesView extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(), + appBar: AppBar( + title: Text(L10n.of(context)!.whoCanSeeMyStories), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(56), + child: ListTile( + title: Text(L10n.of(context)!.whoCanSeeMyStoriesDesc), + leading: CircleAvatar( + backgroundColor: Theme.of(context).secondaryHeaderColor, + foregroundColor: Theme.of(context).colorScheme.secondary, + child: const Icon(Icons.lock), + ), + ), + ), + ), body: FutureBuilder( future: controller.loadUsers, builder: (context, snapshot) { diff --git a/lib/pages/story/story_page.dart b/lib/pages/story/story_page.dart index 6e45f4d8..fcaf1ca0 100644 --- a/lib/pages/story/story_page.dart +++ b/lib/pages/story/story_page.dart @@ -112,6 +112,12 @@ class StoryPageController extends State { []; } + void share() async { + Matrix.of(context).shareContent = currentEvent?.content; + hold(); + VRouter.of(context).to('share'); + } + void displaySeenByUsers() async { _modalOpened = true; await showModalBottomSheet( @@ -241,7 +247,30 @@ class StoryPageController extends State { final Map> _fileCache = {}; - void report(_) async { + void _delete() async { + final event = currentEvent; + if (event == null) return; + _modalOpened = true; + if (await showOkCancelAlertDialog( + context: context, + title: L10n.of(context)!.deleteMessage, + message: L10n.of(context)!.areYouSure, + okLabel: L10n.of(context)!.yes, + cancelLabel: L10n.of(context)!.cancel, + ) != + OkCancelResult.ok) { + return; + } + await showFutureLoadingDialog( + context: context, + future: event.redactEvent, + ); + setState(() { + _modalOpened = false; + }); + } + + void _report() async { _modalOpened = true; final event = currentEvent; if (event == null) return; @@ -406,6 +435,17 @@ class StoryPageController extends State { } } + void onPopupStoryAction(PopupStoryAction action) async { + switch (action) { + case PopupStoryAction.report: + _report(); + break; + case PopupStoryAction.delete: + _delete(); + break; + } + } + @override Widget build(BuildContext context) { loadStory ??= _loadStory(); @@ -428,5 +468,5 @@ extension on List { enum PopupStoryAction { report, - message, + delete, } diff --git a/lib/pages/story/story_view.dart b/lib/pages/story/story_view.dart index 5f839c26..6226cb71 100644 --- a/lib/pages/story/story_view.dart +++ b/lib/pages/story/story_view.dart @@ -72,14 +72,27 @@ class StoryView extends StatelessWidget { ), ), actions: [ + if (!controller.isOwnStory) + AnimatedOpacity( + duration: const Duration(seconds: 1), + opacity: controller.isHold ? 0 : 1, + child: IconButton( + icon: Icon(Icons.adaptive.share_outlined), + onPressed: controller.share, + ), + ), AnimatedOpacity( duration: const Duration(seconds: 1), opacity: controller.isHold ? 0 : 1, - child: PopupMenuButton( - onSelected: controller.report, + child: PopupMenuButton( + onSelected: controller.onPopupStoryAction, itemBuilder: (context) => [ PopupMenuItem( - value: true, + value: PopupStoryAction.delete, + child: Text(L10n.of(context)!.delete), + ), + PopupMenuItem( + value: PopupStoryAction.report, child: Text(L10n.of(context)!.reportMessage), ), ],