Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-23 09:04:18 +08:00
parent a9f1e3cf09
commit faaffd0f30
2 changed files with 37 additions and 37 deletions

View File

@@ -56,10 +56,13 @@ class _EmotePanelState extends State<EmotePanel>
controller: _emotePanelController.tabController,
children: response!.map(
(e) {
double size = e.emote!.first.meta!.size == 1
? 40
: 60;
bool isTextEmote = e.type == 4;
final emote = e.emote;
if (emote == null || emote.isEmpty) {
return const SizedBox.shrink();
}
final flag = emote.first.meta?.size == 1;
final size = flag ? 40.0 : 60.0;
final isTextEmote = e.type == 4;
return GridView.builder(
padding: const EdgeInsets.only(
left: 12,
@@ -73,21 +76,21 @@ class _EmotePanelState extends State<EmotePanel>
mainAxisSpacing: 8,
mainAxisExtent: size,
),
itemCount: e.emote!.length,
itemCount: emote.length,
itemBuilder: (context, index) {
final item = e.emote![index];
final item = emote[index];
Widget child = Padding(
padding: const EdgeInsets.all(6),
child: isTextEmote
? Center(
child: Text(
item.text!,
item.text ?? '',
overflow: TextOverflow.clip,
maxLines: 1,
),
)
: NetworkImgLayer(
src: item.url!,
src: item.url,
width: size,
height: size,
type: ImageType.emote,
@@ -113,7 +116,7 @@ class _EmotePanelState extends State<EmotePanel>
mainAxisSize: MainAxisSize.min,
children: [
NetworkImgLayer(
src: item.url!,
src: item.url,
width: 65,
height: 65,
type: ImageType.emote,
@@ -121,10 +124,11 @@ class _EmotePanelState extends State<EmotePanel>
),
Text(
item.meta?.alias ??
item.text!.substring(
item.text?.substring(
1,
item.text!.length - 1,
),
) ??
'',
style: const TextStyle(fontSize: 12),
),
],
@@ -143,7 +147,7 @@ class _EmotePanelState extends State<EmotePanel>
item,
isTextEmote
? null
: e.emote!.first.meta!.size == 1
: flag
? 24
: 42,
null,
@@ -211,9 +215,7 @@ class _EmotePanelState extends State<EmotePanel>
),
],
),
SizedBox(
height: MediaQuery.viewPaddingOf(context).bottom,
),
SizedBox(height: MediaQuery.viewPaddingOf(context).bottom),
],
)
: _errorWidget(),

View File

@@ -9,7 +9,6 @@ import 'package:PiliPlus/models/common/image_type.dart';
import 'package:PiliPlus/models_new/live/live_emote/datum.dart';
import 'package:PiliPlus/models_new/live/live_emote/emoticon.dart';
import 'package:PiliPlus/pages/live_emote/controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -45,7 +44,8 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
}
Widget _buildBody(LoadingState<List<LiveEmoteDatum>?> loadingState) {
late final color = Theme.of(context).colorScheme.onInverseSurface;
late final theme = Theme.of(context);
late final color = theme.colorScheme.onInverseSurface;
return switch (loadingState) {
Loading() => loadingWidget,
Success(:var response) =>
@@ -57,17 +57,17 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
controller: _emotePanelController.tabController,
children: response!.map(
(item) {
if (item.emoticons.isNullOrEmpty) {
final emote = item.emoticons;
if (emote == null || emote.isEmpty) {
return const SizedBox.shrink();
}
double widthFac = max(
1,
item.emoticons!.first.width! / 80,
);
double heightFac = max(
1,
item.emoticons!.first.height! / 80,
);
final first = emote.first;
final widthFac = first.width == null
? 1.0
: max(1.0, first.width! / 80);
final heightFac = first.height == null
? 1.0
: max(1.0, first.height! / 80);
final width = widthFac * 38;
final height = heightFac * 38;
return GridView.builder(
@@ -83,9 +83,9 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemCount: item.emoticons!.length,
itemCount: emote.length,
itemBuilder: (context, index) {
final e = item.emoticons![index];
final e = emote[index];
return Material(
type: MaterialType.transparency,
child: InkWell(
@@ -117,14 +117,16 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
mainAxisSize: MainAxisSize.min,
children: [
NetworkImgLayer(
src: e.url!,
src: e.url,
width: 65,
height: 65,
type: ImageType.emote,
boxFit: BoxFit.contain,
),
Text(
e.emoji!.startsWith('[')
e.emoji == null
? ''
: e.emoji!.startsWith('[')
? e.emoji!.substring(
1,
e.emoji!.length - 1,
@@ -141,7 +143,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
padding: const EdgeInsets.all(6),
child: NetworkImgLayer(
boxFit: BoxFit.contain,
src: e.url!,
src: e.url,
width: width,
height: height,
type: ImageType.emote,
@@ -159,9 +161,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
),
Divider(
height: 1,
color: Theme.of(
context,
).dividerColor.withValues(alpha: 0.1),
color: theme.dividerColor.withValues(alpha: 0.1),
),
TabBar(
controller: _emotePanelController.tabController,
@@ -183,9 +183,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
)
.toList(),
),
SizedBox(
height: MediaQuery.viewPaddingOf(context).bottom,
),
SizedBox(height: MediaQuery.viewPaddingOf(context).bottom),
],
)
: _errorWidget(),