mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: show dyn blocked item
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -166,6 +166,7 @@ class ModuleBlocked {
|
||||
BgImg? bgImg;
|
||||
int? blockedType;
|
||||
Button? button;
|
||||
String? title;
|
||||
String? hintMessage;
|
||||
BgImg? icon;
|
||||
|
||||
@@ -173,6 +174,7 @@ class ModuleBlocked {
|
||||
bgImg = json['bg_img'] == null ? null : BgImg.fromJson(json['bg_img']);
|
||||
blockedType = json['blocked_type'];
|
||||
button = json['button'] == null ? null : Button.fromJson(json['button']);
|
||||
title = json['title'];
|
||||
hintMessage = json['hint_message'];
|
||||
icon = json['icon'] == null ? null : BgImg.fromJson(json['icon']);
|
||||
}
|
||||
@@ -533,7 +535,7 @@ class DynamicMajorModel {
|
||||
Map? courses;
|
||||
Map? common;
|
||||
Map? music;
|
||||
Map? blocked;
|
||||
ModuleBlocked? blocked;
|
||||
Map? medialist;
|
||||
|
||||
DynamicMajorModel.fromJson(Map<String, dynamic> json) {
|
||||
@@ -560,7 +562,9 @@ class DynamicMajorModel {
|
||||
courses = json['courses'] ?? {};
|
||||
common = json['common'] ?? {};
|
||||
music = json['music'] ?? {};
|
||||
blocked = json['blocked'];
|
||||
blocked = json['blocked'] == null
|
||||
? null
|
||||
: ModuleBlocked.fromJson(json['blocked']);
|
||||
medialist = json['medialist'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,8 +349,9 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
debugPrint('moduleBlocked');
|
||||
final moduleBlocked =
|
||||
_articleCtr.opusData!.modules.moduleBlocked!;
|
||||
final width = maxWidth * 0.8;
|
||||
content = moduleBlockedItem(moduleBlocked, width);
|
||||
content = SliverToBoxAdapter(
|
||||
child: moduleBlockedItem(theme, moduleBlocked, maxWidth),
|
||||
);
|
||||
} else if (_articleCtr.articleData?.content != null) {
|
||||
debugPrint('html page');
|
||||
final res = parser.parse(_articleCtr.articleData!.content!);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
|
||||
show SourceModel;
|
||||
@@ -286,14 +288,16 @@ class OpusContent extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget moduleBlockedItem(ModuleBlocked moduleBlocked, double width) {
|
||||
return SliverToBoxAdapter(
|
||||
child: Stack(
|
||||
Widget moduleBlockedItem(
|
||||
ThemeData theme, ModuleBlocked moduleBlocked, double maxWidth) {
|
||||
if (moduleBlocked.blockedType == 1) {
|
||||
maxWidth = min(400, maxWidth * 0.8);
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
if (moduleBlocked.bgImg != null)
|
||||
CachedNetworkImage(
|
||||
width: width,
|
||||
width: maxWidth,
|
||||
fit: BoxFit.cover,
|
||||
imageUrl: Utils.thumbnailImgUrl(
|
||||
Get.isDarkMode
|
||||
@@ -302,15 +306,15 @@ Widget moduleBlockedItem(ModuleBlocked moduleBlocked, double width) {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: width,
|
||||
height: width,
|
||||
width: maxWidth,
|
||||
height: maxWidth,
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (moduleBlocked.icon != null)
|
||||
CachedNetworkImage(
|
||||
width: width / 7,
|
||||
width: maxWidth / 7,
|
||||
fit: BoxFit.contain,
|
||||
imageUrl: Utils.thumbnailImgUrl(
|
||||
Get.isDarkMode
|
||||
@@ -323,6 +327,9 @@ Widget moduleBlockedItem(ModuleBlocked moduleBlocked, double width) {
|
||||
Text(
|
||||
moduleBlocked.hintMessage!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (moduleBlocked.button != null) ...[
|
||||
@@ -359,6 +366,98 @@ Widget moduleBlockedItem(ModuleBlocked moduleBlocked, double width) {
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
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,
|
||||
imageUrl: Utils.thumbnailImgUrl(
|
||||
Get.isDarkMode
|
||||
? moduleBlocked.icon!.imgDark
|
||||
: moduleBlocked.icon!.imgDay,
|
||||
),
|
||||
),
|
||||
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),
|
||||
FilledButton.tonal(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity:
|
||||
const VisualDensity(vertical: -3, horizontal: -4),
|
||||
backgroundColor: Get.isDarkMode
|
||||
? const Color(0xFF8F0030)
|
||||
: const Color(0xFFFF6699),
|
||||
foregroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6))),
|
||||
),
|
||||
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 ?? ''),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image_view.dart';
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/opus_content.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -43,31 +44,13 @@ InlineSpan picsNodes(
|
||||
);
|
||||
}
|
||||
|
||||
Widget _blockedItem(ThemeData theme, DynamicItemModel item, String? source) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(
|
||||
left: 12, right: 12, bottom: source == 'detail' ? 8 : 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item.modules.moduleDynamic!.major!.blocked!['title'] != null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!.blocked!['title'],
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
if (item.modules.moduleDynamic!.major!.blocked!['hint_message'] != null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!.blocked!['hint_message'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
Widget _blockedItem(ThemeData theme, ModuleBlocked moduleBlocked) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 13, vertical: 1),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return moduleBlockedItem(theme, moduleBlocked, constraints.maxWidth);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -153,7 +136,7 @@ Widget forWard(
|
||||
floor: floor,
|
||||
),
|
||||
if (item.modules.moduleDynamic?.major?.blocked != null)
|
||||
_blockedItem(theme, item, source),
|
||||
_blockedItem(theme, item.modules.moduleDynamic!.major!.blocked!),
|
||||
],
|
||||
);
|
||||
// 视频
|
||||
@@ -165,35 +148,7 @@ Widget forWard(
|
||||
return item.isForwarded == true
|
||||
? articlePanel(theme, source, item, context, callback, floor: floor)
|
||||
: item.modules.moduleDynamic?.major?.blocked != null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['title'] !=
|
||||
null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!.blocked!['title'],
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['hint_message'] !=
|
||||
null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!
|
||||
.blocked!['hint_message'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
? _blockedItem(theme, item.modules.moduleDynamic!.major!.blocked!)
|
||||
: const SizedBox.shrink();
|
||||
// 转发
|
||||
case 'DYNAMIC_TYPE_FORWARD':
|
||||
@@ -307,7 +262,8 @@ Widget forWard(
|
||||
floor: floor,
|
||||
)
|
||||
: item.modules.moduleDynamic?.major?.blocked != null
|
||||
? _blockedItem(theme, item, source)
|
||||
? _blockedItem(
|
||||
theme, item.modules.moduleDynamic!.major!.blocked!)
|
||||
: const SizedBox(height: 0);
|
||||
case 'DYNAMIC_TYPE_PGC':
|
||||
return videoSeasonWidget(theme, source, item, context, 'pgc',
|
||||
|
||||
Reference in New Issue
Block a user