diff --git a/lib/blocs/auth/auth_bloc.dart b/lib/blocs/auth/auth_bloc.dart index 6c8feaf..7ba5044 100644 --- a/lib/blocs/auth/auth_bloc.dart +++ b/lib/blocs/auth/auth_bloc.dart @@ -47,13 +47,14 @@ class AuthBloc extends Bloc { state.copyWith( isLoggedIn: true, user: user, + status: AuthStatus.loaded, ), ); } else { emit( state.copyWith( - status: AuthStatus.loaded, isLoggedIn: false, + status: AuthStatus.loaded, ), ); } diff --git a/lib/screens/item/widgets/reply_box.dart b/lib/screens/item/widgets/reply_box.dart index 9a484b5..630be1f 100644 --- a/lib/screens/item/widgets/reply_box.dart +++ b/lib/screens/item/widgets/reply_box.dart @@ -9,7 +9,6 @@ import 'package:hacki/models/item/item.dart'; import 'package:hacki/screens/screens.dart'; import 'package:hacki/screens/widgets/widgets.dart'; import 'package:hacki/styles/styles.dart'; -import 'package:hacki/utils/link_util.dart'; class ReplyBox extends StatefulWidget { const ReplyBox({ @@ -256,6 +255,8 @@ class _ReplyBoxState extends State { void showTextPopup() { final Item? replyingTo = context.read().state.replyingTo; + if (replyingTo == null) return; + showDialog( context: context, builder: (_) { @@ -280,37 +281,49 @@ class _ReplyBoxState extends State { child: Row( children: [ Text( - replyingTo?.by ?? '', - style: const TextStyle(color: Palette.grey), + replyingTo.by, + style: const TextStyle( + fontSize: TextDimens.pt14, + color: Palette.grey, + ), ), const Spacer(), - if (replyingTo != null) - TextButton( - child: const Text('View thread'), - onPressed: () { - HapticFeedback.lightImpact(); - setState(() { - expanded = false; - }); - Navigator.popUntil( - context, - (Route route) => - route.settings.name == ItemScreen.routeName || - route.isFirst, - ); - goToItemScreen( - args: ItemScreenArgs( - item: replyingTo, - useCommentCache: true, - ), - forceNewScreen: true, - ); - }, - ), TextButton( - child: const Text('Copy all'), + child: const Text( + 'View thread', + style: TextStyle( + fontSize: TextDimens.pt14, + ), + ), + onPressed: () { + HapticFeedback.lightImpact(); + setState(() { + expanded = false; + }); + Navigator.popUntil( + context, + (Route route) => + route.settings.name == ItemScreen.routeName || + route.isFirst, + ); + goToItemScreen( + args: ItemScreenArgs( + item: replyingTo, + useCommentCache: true, + ), + forceNewScreen: true, + ); + }, + ), + TextButton( + child: const Text( + 'Copy all', + style: TextStyle( + fontSize: TextDimens.pt14, + ), + ), onPressed: () => FlutterClipboard.copy( - replyingTo?.text ?? '', + replyingTo.text, ).then((_) => HapticFeedback.selectionClick()), ), IconButton( @@ -334,17 +347,8 @@ class _ReplyBoxState extends State { top: Dimens.pt6, ), child: SingleChildScrollView( - child: SelectableLinkify( - scrollPhysics: const NeverScrollableScrollPhysics(), - textScaleFactor: - MediaQuery.of(context).textScaleFactor, - linkStyle: const TextStyle( - fontSize: TextDimens.pt15, - color: Palette.orange, - ), - onOpen: (LinkableElement link) => - LinkUtil.launch(link.url), - text: replyingTo?.text ?? '', + child: ItemText( + item: replyingTo, ), ), ), diff --git a/lib/screens/widgets/comment_tile.dart b/lib/screens/widgets/comment_tile.dart index 0c2cbc8..aa64d21 100644 --- a/lib/screens/widgets/comment_tile.dart +++ b/lib/screens/widgets/comment_tile.dart @@ -250,7 +250,7 @@ class CommentTile extends StatelessWidget { final Color commentColor = prefState.eyeCandyEnabled ? color.withOpacity(commentBackgroundColorOpacity) : Palette.transparent; - final bool isMyComment = + final bool isMyComment = comment.deleted == false && context.read().state.username == comment.by; Widget wrapper = child; diff --git a/lib/screens/widgets/custom_linkify/custom_linkify.dart b/lib/screens/widgets/custom_linkify/custom_linkify.dart index 0ef95c3..2919aa1 100644 --- a/lib/screens/widgets/custom_linkify/custom_linkify.dart +++ b/lib/screens/widgets/custom_linkify/custom_linkify.dart @@ -181,7 +181,7 @@ class SelectableLinkify extends StatelessWidget { this.cursorHeight, this.selectionControls, this.onSelectionChanged, - this.contextMenuBuilder, + this.contextMenuBuilder = _defaultContextMenuBuilder, }); /// Text to be linkified @@ -318,6 +318,15 @@ class SelectableLinkify extends StatelessWidget { contextMenuBuilder: contextMenuBuilder, ); } + + static Widget _defaultContextMenuBuilder( + BuildContext context, + EditableTextState editableTextState, + ) { + return AdaptiveTextSelectionToolbar.editableText( + editableTextState: editableTextState, + ); + } } class LinkableSpan extends WidgetSpan { diff --git a/lib/screens/widgets/item_text.dart b/lib/screens/widgets/item_text.dart index 48b8a4b..8df2ef9 100644 --- a/lib/screens/widgets/item_text.dart +++ b/lib/screens/widgets/item_text.dart @@ -55,6 +55,7 @@ class ItemText extends StatelessWidget { style: style, linkStyle: linkStyle, onOpen: (LinkableElement link) => LinkUtil.launch(link.url), + onTap: onTap, contextMenuBuilder: ( BuildContext context, EditableTextState editableTextState,