mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 17:16:29 +08:00
@@ -56,10 +56,13 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
controller: _emotePanelController.tabController,
|
controller: _emotePanelController.tabController,
|
||||||
children: response!.map(
|
children: response!.map(
|
||||||
(e) {
|
(e) {
|
||||||
double size = e.emote!.first.meta!.size == 1
|
final emote = e.emote;
|
||||||
? 40
|
if (emote == null || emote.isEmpty) {
|
||||||
: 60;
|
return const SizedBox.shrink();
|
||||||
bool isTextEmote = e.type == 4;
|
}
|
||||||
|
final flag = emote.first.meta?.size == 1;
|
||||||
|
final size = flag ? 40.0 : 60.0;
|
||||||
|
final isTextEmote = e.type == 4;
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 12,
|
left: 12,
|
||||||
@@ -73,21 +76,21 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
mainAxisSpacing: 8,
|
mainAxisSpacing: 8,
|
||||||
mainAxisExtent: size,
|
mainAxisExtent: size,
|
||||||
),
|
),
|
||||||
itemCount: e.emote!.length,
|
itemCount: emote.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = e.emote![index];
|
final item = emote[index];
|
||||||
Widget child = Padding(
|
Widget child = Padding(
|
||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
child: isTextEmote
|
child: isTextEmote
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
item.text!,
|
item.text ?? '',
|
||||||
overflow: TextOverflow.clip,
|
overflow: TextOverflow.clip,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: NetworkImgLayer(
|
: NetworkImgLayer(
|
||||||
src: item.url!,
|
src: item.url,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
type: ImageType.emote,
|
type: ImageType.emote,
|
||||||
@@ -113,7 +116,7 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
NetworkImgLayer(
|
||||||
src: item.url!,
|
src: item.url,
|
||||||
width: 65,
|
width: 65,
|
||||||
height: 65,
|
height: 65,
|
||||||
type: ImageType.emote,
|
type: ImageType.emote,
|
||||||
@@ -121,10 +124,11 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
item.meta?.alias ??
|
item.meta?.alias ??
|
||||||
item.text!.substring(
|
item.text?.substring(
|
||||||
1,
|
1,
|
||||||
item.text!.length - 1,
|
item.text!.length - 1,
|
||||||
),
|
) ??
|
||||||
|
'',
|
||||||
style: const TextStyle(fontSize: 12),
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -143,7 +147,7 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
item,
|
item,
|
||||||
isTextEmote
|
isTextEmote
|
||||||
? null
|
? null
|
||||||
: e.emote!.first.meta!.size == 1
|
: flag
|
||||||
? 24
|
? 24
|
||||||
: 42,
|
: 42,
|
||||||
null,
|
null,
|
||||||
@@ -211,9 +215,7 @@ class _EmotePanelState extends State<EmotePanel>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(height: MediaQuery.viewPaddingOf(context).bottom),
|
||||||
height: MediaQuery.viewPaddingOf(context).bottom,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: _errorWidget(),
|
: _errorWidget(),
|
||||||
|
|||||||
@@ -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/datum.dart';
|
||||||
import 'package:PiliPlus/models_new/live/live_emote/emoticon.dart';
|
import 'package:PiliPlus/models_new/live/live_emote/emoticon.dart';
|
||||||
import 'package:PiliPlus/pages/live_emote/controller.dart';
|
import 'package:PiliPlus/pages/live_emote/controller.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@@ -45,7 +44,8 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState<List<LiveEmoteDatum>?> loadingState) {
|
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) {
|
return switch (loadingState) {
|
||||||
Loading() => loadingWidget,
|
Loading() => loadingWidget,
|
||||||
Success(:var response) =>
|
Success(:var response) =>
|
||||||
@@ -57,17 +57,17 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
controller: _emotePanelController.tabController,
|
controller: _emotePanelController.tabController,
|
||||||
children: response!.map(
|
children: response!.map(
|
||||||
(item) {
|
(item) {
|
||||||
if (item.emoticons.isNullOrEmpty) {
|
final emote = item.emoticons;
|
||||||
|
if (emote == null || emote.isEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
double widthFac = max(
|
final first = emote.first;
|
||||||
1,
|
final widthFac = first.width == null
|
||||||
item.emoticons!.first.width! / 80,
|
? 1.0
|
||||||
);
|
: max(1.0, first.width! / 80);
|
||||||
double heightFac = max(
|
final heightFac = first.height == null
|
||||||
1,
|
? 1.0
|
||||||
item.emoticons!.first.height! / 80,
|
: max(1.0, first.height! / 80);
|
||||||
);
|
|
||||||
final width = widthFac * 38;
|
final width = widthFac * 38;
|
||||||
final height = heightFac * 38;
|
final height = heightFac * 38;
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
@@ -83,9 +83,9 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
crossAxisSpacing: 8,
|
crossAxisSpacing: 8,
|
||||||
mainAxisSpacing: 8,
|
mainAxisSpacing: 8,
|
||||||
),
|
),
|
||||||
itemCount: item.emoticons!.length,
|
itemCount: emote.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final e = item.emoticons![index];
|
final e = emote[index];
|
||||||
return Material(
|
return Material(
|
||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@@ -117,14 +117,16 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
NetworkImgLayer(
|
||||||
src: e.url!,
|
src: e.url,
|
||||||
width: 65,
|
width: 65,
|
||||||
height: 65,
|
height: 65,
|
||||||
type: ImageType.emote,
|
type: ImageType.emote,
|
||||||
boxFit: BoxFit.contain,
|
boxFit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
e.emoji!.startsWith('[')
|
e.emoji == null
|
||||||
|
? ''
|
||||||
|
: e.emoji!.startsWith('[')
|
||||||
? e.emoji!.substring(
|
? e.emoji!.substring(
|
||||||
1,
|
1,
|
||||||
e.emoji!.length - 1,
|
e.emoji!.length - 1,
|
||||||
@@ -141,7 +143,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
boxFit: BoxFit.contain,
|
boxFit: BoxFit.contain,
|
||||||
src: e.url!,
|
src: e.url,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
type: ImageType.emote,
|
type: ImageType.emote,
|
||||||
@@ -159,9 +161,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
height: 1,
|
height: 1,
|
||||||
color: Theme.of(
|
color: theme.dividerColor.withValues(alpha: 0.1),
|
||||||
context,
|
|
||||||
).dividerColor.withValues(alpha: 0.1),
|
|
||||||
),
|
),
|
||||||
TabBar(
|
TabBar(
|
||||||
controller: _emotePanelController.tabController,
|
controller: _emotePanelController.tabController,
|
||||||
@@ -183,9 +183,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
|||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(height: MediaQuery.viewPaddingOf(context).bottom),
|
||||||
height: MediaQuery.viewPaddingOf(context).bottom,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: _errorWidget(),
|
: _errorWidget(),
|
||||||
|
|||||||
Reference in New Issue
Block a user