mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 09:37:02 +08:00
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user