这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/provider/pinned_emojis_notifier_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class PinnedEmojisNotifier extends _$PinnedEmojisNotifier {
await _save(items);
}

Future<void> delete(int index) async {
await _save([...state.sublist(0, index), ...state.sublist(index + 1)]);
Future<void> remove(int index) async {
await _save([...state.take(index), ...state.skip(index + 1)]);
}

Future<void> reset() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/pinned_emojis_notifier_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/view/widget/custom_emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CustomEmoji extends ConsumerWidget {
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.onTap,
this.onLongPress,
this.disableTooltip = false,
this.fallbackTextStyle,
this.fallbackToImage = true,
Expand All @@ -40,6 +41,7 @@ class CustomEmoji extends ConsumerWidget {
final BoxFit fit;
final Alignment alignment;
final void Function()? onTap;
final void Function()? onLongPress;
final bool disableTooltip;
final TextStyle? fallbackTextStyle;
final bool fallbackToImage;
Expand Down Expand Up @@ -101,8 +103,9 @@ class CustomEmoji extends ConsumerWidget {

return InkWell(
onTap: onTap,
onLongPress: onLongPress,
child: TooltipVisibility(
visible: !disableTooltip,
visible: onLongPress == null && !disableTooltip,
child: Tooltip(
message: emoji.replaceFirst('@.', ''),
child: RepaintBoundary(
Expand Down
96 changes: 94 additions & 2 deletions lib/view/widget/emoji_picker.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
Expand All @@ -22,6 +23,7 @@ import '../../provider/search_unicode_emojis_provider.dart';
import '../../util/check_reaction_permissions.dart';
import '../page/emoji_page.dart';
import 'custom_emoji.dart';
import 'emoji_sheet.dart';
import 'unicode_emoji.dart';

Future<String?> pickEmoji(
Expand Down Expand Up @@ -228,6 +230,11 @@ class EmojiPicker extends HookConsumerWidget {
onTap: enabled
? () => onTapEmoji(emoji.emoji, keepOpen)
: null,
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) =>
EmojiSheet(account: account, emoji: emoji.emoji),
),
height: style.lineHeight * fontScaleFactor,
opacity: enabled ? 1.0 : 0.1,
fallbackTextStyle: style.apply(
Expand All @@ -241,6 +248,11 @@ class EmojiPicker extends HookConsumerWidget {
emoji: emoji,
style: style.apply(fontSizeFactor: fontScaleFactor),
onTap: () => onTapEmoji(emoji, keepOpen),
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) =>
EmojiSheet(account: account, emoji: emoji),
),
),
),
],
Expand All @@ -254,7 +266,7 @@ class EmojiPicker extends HookConsumerWidget {
child: Wrap(
spacing: 4.0,
runSpacing: 4.0,
children: pinnedEmojis.map((emoji) {
children: pinnedEmojis.mapIndexed((index, emoji) {
if (emoji.startsWith(':')) {
final customEmoji = ref.watch(
emojiProvider(account.host, emoji),
Expand All @@ -268,6 +280,24 @@ class EmojiPicker extends HookConsumerWidget {
account: account,
emoji: emoji,
onTap: enabled ? () => onTapEmoji(emoji, keepOpen) : null,
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiSheet(
account: account,
emoji: emoji,
remove: () {
ref
.read(
pinnedEmojisNotifierProvider(
account,
reaction: reaction,
).notifier,
)
.remove(index);
context.pop();
},
),
),
height: style.lineHeight * fontScaleFactor,
opacity: enabled ? 1.0 : 0.1,
fallbackTextStyle: style.apply(
Expand All @@ -280,6 +310,24 @@ class EmojiPicker extends HookConsumerWidget {
emoji: emoji,
style: style.apply(fontSizeFactor: fontScaleFactor),
onTap: () => onTapEmoji(emoji, keepOpen),
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiSheet(
account: account,
emoji: emoji,
remove: () {
ref
.read(
pinnedEmojisNotifierProvider(
account,
reaction: reaction,
).notifier,
)
.remove(index);
context.pop();
},
),
),
);
}
}).toList(),
Expand All @@ -298,7 +346,7 @@ class EmojiPicker extends HookConsumerWidget {
child: Wrap(
spacing: 4.0,
runSpacing: 4.0,
children: recentlyUsedEmojis.map((emoji) {
children: recentlyUsedEmojis.mapIndexed((index, emoji) {
if (emoji.startsWith(':')) {
final customEmoji = ref.watch(
emojiProvider(account.host, emoji),
Expand All @@ -312,6 +360,23 @@ class EmojiPicker extends HookConsumerWidget {
account: account,
emoji: emoji,
onTap: enabled ? () => onTapEmoji(emoji, keepOpen) : null,
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiSheet(
account: account,
emoji: emoji,
remove: () {
ref
.read(
recentlyUsedEmojisNotifierProvider(
account,
).notifier,
)
.remove(index);
context.pop();
},
),
),
height: style.lineHeight * fontScaleFactor,
opacity: enabled ? 1.0 : 0.1,
fallbackTextStyle: style.apply(
Expand All @@ -324,6 +389,23 @@ class EmojiPicker extends HookConsumerWidget {
emoji: emoji,
style: style.apply(fontSizeFactor: fontScaleFactor),
onTap: () => onTapEmoji(emoji, keepOpen),
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiSheet(
account: account,
emoji: emoji,
remove: () {
ref
.read(
recentlyUsedEmojisNotifierProvider(
account,
).notifier,
)
.remove(index);
context.pop();
},
),
),
);
}
}).toList(),
Expand Down Expand Up @@ -368,6 +450,13 @@ class EmojiPicker extends HookConsumerWidget {
onTap: enabled
? () => onTapEmoji(emoji.emoji, keepOpen)
: null,
onLongPress: () => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiSheet(
account: account,
emoji: emoji.emoji,
),
),
height: style.lineHeight * fontScaleFactor,
opacity: enabled ? 1.0 : 0.1,
fallbackTextStyle: style.apply(
Expand Down Expand Up @@ -426,6 +515,7 @@ class _CustomEmoji extends StatelessWidget {
required this.account,
required this.emoji,
required this.onTap,
required this.onLongPress,
required this.height,
this.opacity = 1.0,
required this.fallbackTextStyle,
Expand All @@ -434,6 +524,7 @@ class _CustomEmoji extends StatelessWidget {
final Account account;
final String emoji;
final void Function()? onTap;
final void Function()? onLongPress;
final double height;
final double opacity;
final TextStyle fallbackTextStyle;
Expand All @@ -446,6 +537,7 @@ class _CustomEmoji extends StatelessWidget {
account: account,
emoji: emoji,
onTap: onTap,
onLongPress: onLongPress,
height: height,
opacity: opacity,
fallbackTextStyle: fallbackTextStyle,
Expand Down
2 changes: 1 addition & 1 deletion lib/view/widget/pinned_emojis_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PinnedEmojisEditor extends HookConsumerWidget {
reaction: reaction,
).notifier,
)
.delete(index),
.remove(index),
style: style.apply(fontSizeFactor: 2.0),
disableTooltip: true,
),
Expand Down
4 changes: 4 additions & 0 deletions lib/view/widget/unicode_emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UnicodeEmoji extends ConsumerWidget {
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.onTap,
this.onLongPress,
this.inline = false,
});

Expand All @@ -41,6 +42,7 @@ class UnicodeEmoji extends ConsumerWidget {
final BoxFit fit;
final Alignment alignment;
final void Function()? onTap;
final void Function()? onLongPress;
final bool inline;

@override
Expand Down Expand Up @@ -69,12 +71,14 @@ class UnicodeEmoji extends ConsumerWidget {
case EmojiStyle.native:
return InkWell(
onTap: onTap,
onLongPress: onLongPress,
child: Text(emoji, style: style),
);
case EmojiStyle.twemoji:
final padding = style.fontSize! * ((style.height ?? 1.0) - 1.0) / 2;
return InkWell(
onTap: onTap,
onLongPress: onLongPress,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: padding,
Expand Down
Loading