mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 19:28:27 +08:00
@@ -48,138 +48,154 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
||||
late final color = Theme.of(context).colorScheme.onInverseSurface;
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
controller: _emotePanelController.tabController,
|
||||
children: response!.map(
|
||||
(item) {
|
||||
if (item.emoticons.isNullOrEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
double widthFac =
|
||||
max(1, item.emoticons!.first.width! / 80);
|
||||
double heightFac =
|
||||
max(1, item.emoticons!.first.height! / 80);
|
||||
final width = widthFac * 38;
|
||||
final height = heightFac * 38;
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12, right: 12, bottom: 12),
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: widthFac * 40,
|
||||
mainAxisExtent: heightFac * 40,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
),
|
||||
itemCount: item.emoticons!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final e = item.emoticons![index];
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(6)),
|
||||
onTap: () {
|
||||
if (item.pkgType == 3) {
|
||||
widget.onChoose(e, width, height);
|
||||
} else {
|
||||
widget.onSendEmoticonUnique(e);
|
||||
}
|
||||
},
|
||||
child: CustomTooltip(
|
||||
indicator: () => CustomPaint(
|
||||
size: const Size(14, 8),
|
||||
painter: TrianglePainter(color),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
controller: _emotePanelController.tabController,
|
||||
children: response!.map(
|
||||
(item) {
|
||||
if (item.emoticons.isNullOrEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
double widthFac = max(
|
||||
1,
|
||||
item.emoticons!.first.width! / 80,
|
||||
);
|
||||
double heightFac = max(
|
||||
1,
|
||||
item.emoticons!.first.height! / 80,
|
||||
);
|
||||
final width = widthFac * 38;
|
||||
final height = heightFac * 38;
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12,
|
||||
right: 12,
|
||||
bottom: 12,
|
||||
),
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: widthFac * 40,
|
||||
mainAxisExtent: heightFac * 40,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
),
|
||||
itemCount: item.emoticons!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final e = item.emoticons![index];
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(6),
|
||||
),
|
||||
overlayWidget: () => Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8)),
|
||||
onTap: () {
|
||||
if (item.pkgType == 3) {
|
||||
widget.onChoose(e, width, height);
|
||||
} else {
|
||||
widget.onSendEmoticonUnique(e);
|
||||
}
|
||||
},
|
||||
child: CustomTooltip(
|
||||
indicator: () => CustomPaint(
|
||||
size: const Size(14, 8),
|
||||
painter: TrianglePainter(color),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: e.url!,
|
||||
width: 65,
|
||||
height: 65,
|
||||
type: ImageType.emote,
|
||||
boxFit: BoxFit.contain,
|
||||
overlayWidget: () => Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
Text(
|
||||
e.emoji!.startsWith('[')
|
||||
? e.emoji!.substring(
|
||||
1, e.emoji!.length - 1)
|
||||
: e.emoji!,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
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,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).dividerColor.withValues(alpha: 0.1),
|
||||
),
|
||||
TabBar(
|
||||
controller: _emotePanelController.tabController,
|
||||
padding: const EdgeInsets.only(right: 60),
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
isScrollable: true,
|
||||
tabs: response
|
||||
.map(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: NetworkImgLayer(
|
||||
width: 24,
|
||||
height: 24,
|
||||
type: ImageType.emote,
|
||||
src: item.currentCover,
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).dividerColor.withValues(alpha: 0.1),
|
||||
),
|
||||
TabBar(
|
||||
controller: _emotePanelController.tabController,
|
||||
padding: const EdgeInsets.only(right: 60),
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
isScrollable: true,
|
||||
tabs: response
|
||||
.map(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: NetworkImgLayer(
|
||||
width: 24,
|
||||
height: 24,
|
||||
type: ImageType.emote,
|
||||
src: item.currentCover,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
||||
],
|
||||
)
|
||||
: _errorWidget(),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
||||
],
|
||||
)
|
||||
: _errorWidget(),
|
||||
Error(:var errMsg) => _errorWidget(errMsg),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _errorWidget([String? errMsg]) => Center(
|
||||
child: TextButton.icon(
|
||||
onPressed: _emotePanelController.onReload,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: Text(errMsg ?? '没有数据'),
|
||||
),
|
||||
);
|
||||
child: TextButton.icon(
|
||||
onPressed: _emotePanelController.onReload,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: Text(errMsg ?? '没有数据'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user