chore: enhance stories

This commit is contained in:
Christian Pauly 2021-12-28 19:30:19 +01:00
parent 888bb91d9d
commit b8dc6c1e14
7 changed files with 100 additions and 8 deletions

View File

@ -2684,5 +2684,6 @@
"date": {},
"body": {}
}
}
},
"whoCanSeeMyStoriesDesc": "Please note that people can see and contact each other in your story."
}

View File

@ -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',

View File

@ -142,7 +142,7 @@ class AddStoryController extends State<AddStoryPage> {
},
);
if (postResult.error == null) {
VRouter.of(context).to('/rooms');
VRouter.of(context).pop();
}
}

View File

@ -73,6 +73,17 @@ class _InviteStoryPageState extends State<InviteStoryPage> {
onPressed: () => Navigator.of(context).pop<bool>(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<List<User>>(
future: loadContacts,

View File

@ -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) {

View File

@ -112,6 +112,12 @@ class StoryPageController extends State<StoryPage> {
[];
}
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<StoryPage> {
final Map<String, Future<MatrixFile>> _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<StoryPage> {
}
}
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<Event> {
enum PopupStoryAction {
report,
message,
delete,
}

View File

@ -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<bool>(
onSelected: controller.report,
child: PopupMenuButton<PopupStoryAction>(
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),
),
],