opt: show blocked item

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-29 15:08:38 +08:00
parent a42881ba9f
commit f6b5d358e0

View File

@@ -290,151 +290,49 @@ class OpusContent extends StatelessWidget {
Widget moduleBlockedItem( Widget moduleBlockedItem(
ThemeData theme, ModuleBlocked moduleBlocked, double maxWidth) { ThemeData theme, ModuleBlocked moduleBlocked, double maxWidth) {
if (moduleBlocked.blockedType == 1) { BoxDecoration? bgImg() {
maxWidth = min(400, maxWidth * 0.8); return moduleBlocked.bgImg == null
return Stack( ? null
clipBehavior: Clip.none, : BoxDecoration(
children: [ image: DecorationImage(
if (moduleBlocked.bgImg != null) fit: BoxFit.fill,
CachedNetworkImage( image: CachedNetworkImageProvider(
width: maxWidth, Utils.thumbnailImgUrl(
fit: BoxFit.cover,
imageUrl: Utils.thumbnailImgUrl(
Get.isDarkMode Get.isDarkMode
? moduleBlocked.bgImg!.imgDark ? moduleBlocked.bgImg!.imgDark
: moduleBlocked.bgImg!.imgDay, : moduleBlocked.bgImg!.imgDay,
), ),
), ),
Container(
width: maxWidth,
height: maxWidth,
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (moduleBlocked.icon != null)
CachedNetworkImage(
width: maxWidth / 7,
fit: BoxFit.contain,
imageUrl: Utils.thumbnailImgUrl(
Get.isDarkMode
? moduleBlocked.icon!.imgDark
: moduleBlocked.icon!.imgDay,
), ),
),
if (moduleBlocked.hintMessage != null) ...[
const SizedBox(height: 5),
Text(
moduleBlocked.hintMessage!,
textAlign: TextAlign.center,
style: TextStyle(
color: theme.colorScheme.outline,
),
),
],
if (moduleBlocked.button != null) ...[
const SizedBox(height: 5),
FilledButton.tonal(
style: FilledButton.styleFrom(
visualDensity: const VisualDensity(vertical: -2.5),
backgroundColor: Get.isDarkMode
? const Color(0xFF8F0030)
: const Color(0xFFFF6699),
foregroundColor: Colors.white,
),
onPressed: () {
if (moduleBlocked.button!.jumpUrl != null) {
PiliScheme.routePushFromUrl(
moduleBlocked.button!.jumpUrl!);
}
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (moduleBlocked.button!.icon != null)
CachedNetworkImage(
height: 16,
color: Colors.white,
imageUrl: moduleBlocked.button!.icon!,
),
Text(moduleBlocked.button!.text ?? ''),
],
),
),
],
],
),
),
],
); );
} }
return Stack(
clipBehavior: Clip.none, Widget icon(double width) {
alignment: Alignment.center, return CachedNetworkImage(
children: [ width: width,
if (moduleBlocked.bgImg != null)
CachedNetworkImage(
width: maxWidth,
fit: BoxFit.cover,
imageUrl: Utils.thumbnailImgUrl(
Get.isDarkMode
? moduleBlocked.bgImg!.imgDark
: moduleBlocked.bgImg!.imgDay,
),
),
Padding(
padding: const EdgeInsets.all(12),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (moduleBlocked.icon != null) ...[
CachedNetworkImage(
width: 42,
fit: BoxFit.contain, fit: BoxFit.contain,
imageUrl: Utils.thumbnailImgUrl( imageUrl: Utils.thumbnailImgUrl(
Get.isDarkMode Get.isDarkMode
? moduleBlocked.icon!.imgDark ? moduleBlocked.icon!.imgDark
: moduleBlocked.icon!.imgDay, : moduleBlocked.icon!.imgDay,
), ),
), );
const SizedBox(width: 8), }
],
Expanded( Widget btn({
child: Column( OutlinedBorder? shape,
crossAxisAlignment: CrossAxisAlignment.start, VisualDensity? visualDensity,
mainAxisSize: MainAxisSize.min, EdgeInsetsGeometry? padding,
children: [ }) {
if (moduleBlocked.title != null) return FilledButton.tonal(
Text(
moduleBlocked.title!,
),
if (moduleBlocked.hintMessage != null) ...[
const SizedBox(height: 2),
Text(
moduleBlocked.hintMessage!,
style: TextStyle(
fontSize: 13,
color: theme.colorScheme.outline,
),
),
],
],
),
),
if (moduleBlocked.button != null) ...[
const SizedBox(width: 8),
FilledButton.tonal(
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 10), padding: padding,
tapTargetSize: MaterialTapTargetSize.shrinkWrap, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: visualDensity: visualDensity,
const VisualDensity(vertical: -3, horizontal: -4), backgroundColor:
backgroundColor: Get.isDarkMode Get.isDarkMode ? const Color(0xFF8F0030) : const Color(0xFFFF6699),
? const Color(0xFF8F0030)
: const Color(0xFFFF6699),
foregroundColor: Colors.white, foregroundColor: Colors.white,
shape: const RoundedRectangleBorder( shape: shape,
borderRadius: BorderRadius.all(Radius.circular(6))),
), ),
onPressed: () { onPressed: () {
if (moduleBlocked.button!.jumpUrl != null) { if (moduleBlocked.button!.jumpUrl != null) {
@@ -453,11 +351,77 @@ Widget moduleBlockedItem(
Text(moduleBlocked.button!.text ?? ''), Text(moduleBlocked.button!.text ?? ''),
], ],
), ),
), );
], }
],
), if (moduleBlocked.blockedType == 1) {
), maxWidth = maxWidth <= 255 ? maxWidth : min(400, maxWidth * 0.8);
], return Container(
width: maxWidth,
height: maxWidth,
decoration: bgImg(),
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (moduleBlocked.icon != null) icon(max(40, maxWidth / 7)),
if (moduleBlocked.hintMessage != null) ...[
const SizedBox(height: 5),
Text(
moduleBlocked.hintMessage!,
textAlign: TextAlign.center,
style: TextStyle(color: theme.colorScheme.outline),
),
],
if (moduleBlocked.button != null) ...[
const SizedBox(height: 8),
btn(
visualDensity: const VisualDensity(vertical: -2.5),
),
],
],
),
);
}
return Container(
decoration: bgImg(),
padding: const EdgeInsets.all(12),
child: Row(
children: [
if (moduleBlocked.icon != null) ...[
icon(42),
const SizedBox(width: 8),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (moduleBlocked.title != null) Text(moduleBlocked.title!),
if (moduleBlocked.hintMessage != null) ...[
const SizedBox(height: 2),
Text(
moduleBlocked.hintMessage!,
style: TextStyle(
fontSize: 13,
color: theme.colorScheme.outline,
),
),
],
],
),
),
if (moduleBlocked.button != null) ...[
const SizedBox(width: 8),
btn(
visualDensity: const VisualDensity(vertical: -3, horizontal: -4),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6)),
),
padding: const EdgeInsets.symmetric(horizontal: 10),
),
],
],
),
); );
} }