diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index f7a53a7..c516261 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -1,8 +1,10 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:solian/models/pagination.dart'; import 'package:solian/models/post.dart'; +import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; import 'package:solian/utils/service_url.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; @@ -54,13 +56,24 @@ class _ExploreScreenState extends State { @override Widget build(BuildContext context) { + final auth = context.read(); + return IndentWrapper( noSafeArea: true, - floatingActionButton: FloatingActionButton( - child: const Icon(Icons.edit), - onPressed: () async { - final did = await router.pushNamed("posts.moments.editor"); - if (did == true) _pagingController.refresh(); + floatingActionButton: FutureBuilder( + future: auth.isAuthorized(), + builder: (context, snapshot) { + if (snapshot.hasData && snapshot.data!) { + return FloatingActionButton( + child: const Icon(Icons.edit), + onPressed: () async { + final did = await router.pushNamed("posts.moments.editor"); + if (did == true) _pagingController.refresh(); + }, + ); + } else { + return Container(); + } }, ), title: AppLocalizations.of(context)!.explore, @@ -71,9 +84,8 @@ class _ExploreScreenState extends State { child: Center( child: Container( constraints: const BoxConstraints(maxWidth: 640), - child: PagedListView.separated( + child: PagedListView( pagingController: _pagingController, - separatorBuilder: (context, index) => const Divider(thickness: 0.3), builderDelegate: PagedChildBuilderDelegate( itemBuilder: (context, item, index) => PostItem( item: item, diff --git a/lib/widgets/chat/content.dart b/lib/widgets/chat/content.dart index fd8ed38..0a4b076 100644 --- a/lib/widgets/chat/content.dart +++ b/lib/widgets/chat/content.dart @@ -11,7 +11,6 @@ class ChatMessageContent extends StatelessWidget { @override Widget build(BuildContext context) { return Markdown( - selectable: true, data: item.content, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), diff --git a/lib/widgets/chat/message.dart b/lib/widgets/chat/message.dart index 6e03d9e..cc2d458 100644 --- a/lib/widgets/chat/message.dart +++ b/lib/widgets/chat/message.dart @@ -1,8 +1,11 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:solian/models/message.dart'; import 'package:solian/widgets/chat/content.dart'; import 'package:solian/widgets/posts/content/attachment.dart'; import 'package:timeago/timeago.dart' as timeago; +import 'dart:math' as math; class ChatMessage extends StatelessWidget { final Message item; @@ -21,6 +24,49 @@ class ChatMessage extends StatelessWidget { } } + Widget renderReply() { + final padding = + underMerged ? const EdgeInsets.only(left: 14, right: 8, top: 4) : const EdgeInsets.only(left: 8, right: 8); + + if (item.replyTo != null) { + return Row( + children: [ + Container( + padding: padding, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY(math.pi), + child: const Icon(Icons.reply, size: 16), + ), + const SizedBox(width: 8), + CircleAvatar( + radius: 10, + backgroundImage: NetworkImage(item.replyTo!.sender.account.avatar), + ), + ]), + ), + Expanded( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only(right: 12, top: 2), + child: ChatMessageContent(item: item.replyTo!), + ), + renderAttachment() + ], + ), + ), + ], + ); + } else { + return Container(); + } + } + @override Widget build(BuildContext context) { final contentPart = Padding( @@ -48,27 +94,32 @@ class ChatMessage extends StatelessWidget { const SizedBox(width: 40), Expanded( child: Column( - children: [contentPart, renderAttachment()], + children: [renderReply(), contentPart, renderAttachment()], ), ), ], ); } else { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, + return Column( children: [ - CircleAvatar( - backgroundImage: NetworkImage(item.sender.account.avatar), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - userinfoPart, - contentPart, - renderAttachment(), - ], - ), + renderReply(), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + backgroundImage: NetworkImage(item.sender.account.avatar), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + userinfoPart, + contentPart, + renderAttachment(), + ], + ), + ), + ], ), ], ); diff --git a/lib/widgets/chat/message_action.dart b/lib/widgets/chat/message_action.dart index 1bf8c82..f4bcb6d 100644 --- a/lib/widgets/chat/message_action.dart +++ b/lib/widgets/chat/message_action.dart @@ -1,13 +1,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:solian/models/message.dart'; -import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; -import 'package:solian/router.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:solian/screens/posts/comment_editor.dart'; import 'package:solian/widgets/chat/message_deletion.dart'; -import 'package:solian/widgets/posts/item_deletion.dart'; class ChatMessageAction extends StatelessWidget { final String channel; diff --git a/lib/widgets/chat/message_deletion.dart b/lib/widgets/chat/message_deletion.dart index 4ab5811..cfcb1b7 100644 --- a/lib/widgets/chat/message_deletion.dart +++ b/lib/widgets/chat/message_deletion.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:solian/models/message.dart'; -import 'package:solian/models/post.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/utils/service_url.dart';