bugfixes. (#169)

This commit is contained in:
Jiaqi Feng
2023-02-26 12:12:11 -08:00
committed by GitHub
parent 3469543c7b
commit c375def289
5 changed files with 57 additions and 42 deletions

View File

@ -47,13 +47,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
state.copyWith( state.copyWith(
isLoggedIn: true, isLoggedIn: true,
user: user, user: user,
status: AuthStatus.loaded,
), ),
); );
} else { } else {
emit( emit(
state.copyWith( state.copyWith(
status: AuthStatus.loaded,
isLoggedIn: false, isLoggedIn: false,
status: AuthStatus.loaded,
), ),
); );
} }

View File

@ -9,7 +9,6 @@ import 'package:hacki/models/item/item.dart';
import 'package:hacki/screens/screens.dart'; import 'package:hacki/screens/screens.dart';
import 'package:hacki/screens/widgets/widgets.dart'; import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/styles/styles.dart'; import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/link_util.dart';
class ReplyBox extends StatefulWidget { class ReplyBox extends StatefulWidget {
const ReplyBox({ const ReplyBox({
@ -256,6 +255,8 @@ class _ReplyBoxState extends State<ReplyBox> {
void showTextPopup() { void showTextPopup() {
final Item? replyingTo = context.read<EditCubit>().state.replyingTo; final Item? replyingTo = context.read<EditCubit>().state.replyingTo;
if (replyingTo == null) return;
showDialog<void>( showDialog<void>(
context: context, context: context,
builder: (_) { builder: (_) {
@ -280,37 +281,49 @@ class _ReplyBoxState extends State<ReplyBox> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text( Text(
replyingTo?.by ?? '', replyingTo.by,
style: const TextStyle(color: Palette.grey), style: const TextStyle(
fontSize: TextDimens.pt14,
color: Palette.grey,
),
), ),
const Spacer(), const Spacer(),
if (replyingTo != null)
TextButton(
child: const Text('View thread'),
onPressed: () {
HapticFeedback.lightImpact();
setState(() {
expanded = false;
});
Navigator.popUntil(
context,
(Route<dynamic> route) =>
route.settings.name == ItemScreen.routeName ||
route.isFirst,
);
goToItemScreen(
args: ItemScreenArgs(
item: replyingTo,
useCommentCache: true,
),
forceNewScreen: true,
);
},
),
TextButton( 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<dynamic> 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( onPressed: () => FlutterClipboard.copy(
replyingTo?.text ?? '', replyingTo.text,
).then((_) => HapticFeedback.selectionClick()), ).then((_) => HapticFeedback.selectionClick()),
), ),
IconButton( IconButton(
@ -334,17 +347,8 @@ class _ReplyBoxState extends State<ReplyBox> {
top: Dimens.pt6, top: Dimens.pt6,
), ),
child: SingleChildScrollView( child: SingleChildScrollView(
child: SelectableLinkify( child: ItemText(
scrollPhysics: const NeverScrollableScrollPhysics(), item: replyingTo,
textScaleFactor:
MediaQuery.of(context).textScaleFactor,
linkStyle: const TextStyle(
fontSize: TextDimens.pt15,
color: Palette.orange,
),
onOpen: (LinkableElement link) =>
LinkUtil.launch(link.url),
text: replyingTo?.text ?? '',
), ),
), ),
), ),

View File

@ -250,7 +250,7 @@ class CommentTile extends StatelessWidget {
final Color commentColor = prefState.eyeCandyEnabled final Color commentColor = prefState.eyeCandyEnabled
? color.withOpacity(commentBackgroundColorOpacity) ? color.withOpacity(commentBackgroundColorOpacity)
: Palette.transparent; : Palette.transparent;
final bool isMyComment = final bool isMyComment = comment.deleted == false &&
context.read<AuthBloc>().state.username == comment.by; context.read<AuthBloc>().state.username == comment.by;
Widget wrapper = child; Widget wrapper = child;

View File

@ -181,7 +181,7 @@ class SelectableLinkify extends StatelessWidget {
this.cursorHeight, this.cursorHeight,
this.selectionControls, this.selectionControls,
this.onSelectionChanged, this.onSelectionChanged,
this.contextMenuBuilder, this.contextMenuBuilder = _defaultContextMenuBuilder,
}); });
/// Text to be linkified /// Text to be linkified
@ -318,6 +318,15 @@ class SelectableLinkify extends StatelessWidget {
contextMenuBuilder: contextMenuBuilder, contextMenuBuilder: contextMenuBuilder,
); );
} }
static Widget _defaultContextMenuBuilder(
BuildContext context,
EditableTextState editableTextState,
) {
return AdaptiveTextSelectionToolbar.editableText(
editableTextState: editableTextState,
);
}
} }
class LinkableSpan extends WidgetSpan { class LinkableSpan extends WidgetSpan {

View File

@ -55,6 +55,7 @@ class ItemText extends StatelessWidget {
style: style, style: style,
linkStyle: linkStyle, linkStyle: linkStyle,
onOpen: (LinkableElement link) => LinkUtil.launch(link.url), onOpen: (LinkableElement link) => LinkUtil.launch(link.url),
onTap: onTap,
contextMenuBuilder: ( contextMenuBuilder: (
BuildContext context, BuildContext context,
EditableTextState editableTextState, EditableTextState editableTextState,