mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-18 16:16:14 +08:00
custom emoji tooltip
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_tooltip.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
@@ -37,6 +38,9 @@ class _EmotePanelState extends State<EmotePanel>
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<List<Package>?> loadingState) {
|
||||
late final color = Get.currentRoute.startsWith('/whisperDetail')
|
||||
? theme.colorScheme.surface
|
||||
: theme.colorScheme.onInverseSurface;
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
@@ -62,6 +66,60 @@ class _EmotePanelState extends State<EmotePanel>
|
||||
itemCount: e.emote!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = e.emote![index];
|
||||
Widget child = Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: isTextEmote
|
||||
? Center(
|
||||
child: Text(
|
||||
item.text!,
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 1,
|
||||
),
|
||||
)
|
||||
: NetworkImgLayer(
|
||||
src: item.url!,
|
||||
width: size,
|
||||
height: size,
|
||||
type: ImageType.emote,
|
||||
boxFit: BoxFit.contain,
|
||||
),
|
||||
);
|
||||
if (!isTextEmote) {
|
||||
child = CustomTooltip(
|
||||
indicator: () => CustomPaint(
|
||||
size: const Size(14, 8),
|
||||
painter: TrianglePainter(color),
|
||||
),
|
||||
overlayWidget: () => Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: item.url!,
|
||||
width: 65,
|
||||
height: 65,
|
||||
type: ImageType.emote,
|
||||
boxFit: BoxFit.contain,
|
||||
),
|
||||
Text(
|
||||
item.meta?.alias ??
|
||||
item.text!.substring(
|
||||
1, item.text!.length - 1),
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
@@ -75,25 +133,7 @@ class _EmotePanelState extends State<EmotePanel>
|
||||
? 24
|
||||
: 42,
|
||||
null),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: isTextEmote
|
||||
? Center(
|
||||
child: Text(
|
||||
item.text!,
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 1,
|
||||
),
|
||||
)
|
||||
: NetworkImgLayer(
|
||||
src: item.url!,
|
||||
width: size,
|
||||
height: size,
|
||||
semanticsLabel: item.text!,
|
||||
type: ImageType.emote,
|
||||
boxFit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/custom_tooltip.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
@@ -44,6 +45,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<LiveEmoteDatum>?> loadingState) {
|
||||
late final color = Theme.of(context).colorScheme.onInverseSurface;
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
@@ -88,15 +90,49 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
||||
widget.onSendEmoticonUnique(e);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: NetworkImgLayer(
|
||||
boxFit: BoxFit.contain,
|
||||
src: e.url!,
|
||||
width: width,
|
||||
height: height,
|
||||
type: ImageType.emote,
|
||||
quality: item.pkgType == 3 ? null : 80,
|
||||
child: CustomTooltip(
|
||||
indicator: () => CustomPaint(
|
||||
size: const Size(14, 8),
|
||||
painter: TrianglePainter(color),
|
||||
),
|
||||
overlayWidget: () => Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: e.url!,
|
||||
width: 65,
|
||||
height: 65,
|
||||
type: ImageType.emote,
|
||||
boxFit: BoxFit.contain,
|
||||
),
|
||||
Text(
|
||||
e.emoji!.startsWith('[')
|
||||
? e.emoji!.substring(
|
||||
1, e.emoji!.length - 1)
|
||||
: e.emoji!,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: NetworkImgLayer(
|
||||
boxFit: BoxFit.contain,
|
||||
src: e.url!,
|
||||
width: width,
|
||||
height: height,
|
||||
type: ImageType.emote,
|
||||
quality: item.pkgType == 3 ? null : 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user