Merge branch 'design' into alpha
This commit is contained in:
@ -124,60 +124,62 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
|||||||
)
|
)
|
||||||
: const SizedBox();
|
: const SizedBox();
|
||||||
case 'ADDITIONAL_TYPE_GOODS':
|
case 'ADDITIONAL_TYPE_GOODS':
|
||||||
return Padding(
|
// 商品
|
||||||
padding: const EdgeInsets.only(top: 6),
|
return const SizedBox();
|
||||||
child: InkWell(
|
// return Padding(
|
||||||
onTap: () {},
|
// padding: const EdgeInsets.only(top: 6),
|
||||||
child: Container(
|
// child: InkWell(
|
||||||
padding:
|
// onTap: () {},
|
||||||
const EdgeInsets.only(left: 12, top: 8, right: 12, bottom: 8),
|
// child: Container(
|
||||||
decoration: BoxDecoration(
|
// padding:
|
||||||
color: bgColor,
|
// const EdgeInsets.only(left: 12, top: 8, right: 12, bottom: 8),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
// decoration: BoxDecoration(
|
||||||
),
|
// color: bgColor,
|
||||||
child: Row(
|
// borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||||
children: [
|
// ),
|
||||||
NetworkImgLayer(
|
// child: Row(
|
||||||
width: 75,
|
// children: [
|
||||||
height: 75,
|
// NetworkImgLayer(
|
||||||
src: dynamicProperty[type].items.first.cover,
|
// width: 75,
|
||||||
),
|
// height: 75,
|
||||||
const SizedBox(width: 10),
|
// src: dynamicProperty[type].items.first.cover,
|
||||||
Expanded(
|
// ),
|
||||||
child: Column(
|
// const SizedBox(width: 10),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// Expanded(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
// child: Column(
|
||||||
children: [
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
dynamicProperty[type].items.first.name,
|
// children: [
|
||||||
maxLines: 1,
|
// Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
// dynamicProperty[type].items.first.name,
|
||||||
),
|
// maxLines: 1,
|
||||||
Text(
|
// overflow: TextOverflow.ellipsis,
|
||||||
dynamicProperty[type].items.first.brief,
|
// ),
|
||||||
maxLines: 1,
|
// Text(
|
||||||
style: TextStyle(
|
// dynamicProperty[type].items.first.brief,
|
||||||
color: Theme.of(context).colorScheme.outline,
|
// maxLines: 1,
|
||||||
fontSize: Theme.of(context)
|
// style: TextStyle(
|
||||||
.textTheme
|
// color: Theme.of(context).colorScheme.outline,
|
||||||
.labelMedium!
|
// fontSize: Theme.of(context)
|
||||||
.fontSize,
|
// .textTheme
|
||||||
),
|
// .labelMedium!
|
||||||
),
|
// .fontSize,
|
||||||
const SizedBox(height: 2),
|
// ),
|
||||||
Text(
|
// ),
|
||||||
dynamicProperty[type].items.first.price,
|
// const SizedBox(height: 2),
|
||||||
style: TextStyle(
|
// Text(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
// dynamicProperty[type].items.first.price,
|
||||||
),
|
// style: TextStyle(
|
||||||
),
|
// color: Theme.of(context).colorScheme.primary,
|
||||||
],
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ],
|
||||||
],
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ],
|
||||||
));
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),);
|
||||||
case 'ADDITIONAL_TYPE_MATCH':
|
case 'ADDITIONAL_TYPE_MATCH':
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
case 'ADDITIONAL_TYPE_COMMON':
|
case 'ADDITIONAL_TYPE_COMMON':
|
||||||
|
|||||||
@ -1,42 +1,183 @@
|
|||||||
// 内容
|
// 内容
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
|
import 'package:pilipala/pages/preview/index.dart';
|
||||||
|
|
||||||
import 'rich_node_panel.dart';
|
import 'rich_node_panel.dart';
|
||||||
|
|
||||||
Widget content(item, context, source) {
|
// ignore: must_be_immutable
|
||||||
TextStyle authorStyle =
|
class Content extends StatefulWidget {
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
dynamic item;
|
||||||
return Container(
|
String? source;
|
||||||
width: double.infinity,
|
Content({
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
super.key,
|
||||||
child: Column(
|
this.item,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
this.source,
|
||||||
children: [
|
});
|
||||||
if (item.modules.moduleDynamic.topic != null) ...[
|
|
||||||
GestureDetector(
|
@override
|
||||||
child: Text(
|
State<Content> createState() => _ContentState();
|
||||||
'#${item.modules.moduleDynamic.topic.name}',
|
}
|
||||||
style: authorStyle,
|
|
||||||
),
|
class _ContentState extends State<Content> {
|
||||||
),
|
late bool hasPics;
|
||||||
],
|
List<OpusPicsModel> pics = [];
|
||||||
IgnorePointer(
|
|
||||||
// 禁用SelectableRegion的触摸交互功能
|
@override
|
||||||
ignoring: source == 'detail' ? false : true,
|
void initState() {
|
||||||
child: SelectableRegion(
|
super.initState();
|
||||||
magnifierConfiguration: const TextMagnifierConfiguration(),
|
hasPics = widget.item.modules.moduleDynamic.major != null &&
|
||||||
focusNode: FocusNode(),
|
widget.item.modules.moduleDynamic.major.opus != null &&
|
||||||
selectionControls: MaterialTextSelectionControls(),
|
widget.item.modules.moduleDynamic.major.opus.pics.isNotEmpty;
|
||||||
child: Text.rich(
|
if (hasPics) {
|
||||||
/// fix 默认20px高度
|
pics = widget.item.modules.moduleDynamic.major.opus.pics;
|
||||||
style: const TextStyle(height: 0),
|
}
|
||||||
richNode(item, context),
|
}
|
||||||
maxLines: source == 'detail' ? 999 : 3,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
InlineSpan picsNodes() {
|
||||||
),
|
List<InlineSpan> spanChilds = [];
|
||||||
|
int len = pics.length;
|
||||||
|
List<String> picList = [];
|
||||||
|
|
||||||
|
if (len == 1) {
|
||||||
|
OpusPicsModel pictureItem = pics.first;
|
||||||
|
picList.add(pictureItem.url!);
|
||||||
|
spanChilds.add(const TextSpan(text: '\n'));
|
||||||
|
spanChilds.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, BoxConstraints box) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
useSafeArea: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return ImagePreview(initialPage: 0, imgList: picList);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
src: pictureItem.url,
|
||||||
|
width: box.maxWidth / 2,
|
||||||
|
height: box.maxWidth *
|
||||||
|
0.5 *
|
||||||
|
(pictureItem.height != null && pictureItem.width != null
|
||||||
|
? pictureItem.height! / pictureItem.width!
|
||||||
|
: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
);
|
if (len > 1) {
|
||||||
|
List<Widget> list = [];
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
picList.add(pics[i].url!);
|
||||||
|
list.add(
|
||||||
|
LayoutBuilder(
|
||||||
|
builder: (context, BoxConstraints box) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
useSafeArea: false,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return ImagePreview(initialPage: i, imgList: picList);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
src: pics[i].url,
|
||||||
|
width: box.maxWidth,
|
||||||
|
height: box.maxWidth,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
spanChilds.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, BoxConstraints box) {
|
||||||
|
double maxWidth = box.maxWidth;
|
||||||
|
double crossCount = len < 3 ? 2 : 3;
|
||||||
|
double height = maxWidth /
|
||||||
|
crossCount *
|
||||||
|
(len % crossCount == 0
|
||||||
|
? len ~/ crossCount
|
||||||
|
: len ~/ crossCount + 1) +
|
||||||
|
6;
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(top: 6),
|
||||||
|
height: height,
|
||||||
|
child: GridView.count(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
crossAxisCount: crossCount.toInt(),
|
||||||
|
mainAxisSpacing: 4.0,
|
||||||
|
crossAxisSpacing: 4.0,
|
||||||
|
childAspectRatio: 1,
|
||||||
|
children: list,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return TextSpan(
|
||||||
|
children: spanChilds,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
TextStyle authorStyle =
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (widget.item.modules.moduleDynamic.topic != null) ...[
|
||||||
|
GestureDetector(
|
||||||
|
child: Text(
|
||||||
|
'#${widget.item.modules.moduleDynamic.topic.name}',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
IgnorePointer(
|
||||||
|
// 禁用SelectableRegion的触摸交互功能
|
||||||
|
ignoring: widget.source == 'detail' ? false : true,
|
||||||
|
child: SelectableRegion(
|
||||||
|
magnifierConfiguration: const TextMagnifierConfiguration(),
|
||||||
|
focusNode: FocusNode(),
|
||||||
|
selectionControls: MaterialTextSelectionControls(),
|
||||||
|
child: Text.rich(
|
||||||
|
/// fix 默认20px高度
|
||||||
|
style: const TextStyle(height: 0),
|
||||||
|
richNode(widget.item, context),
|
||||||
|
maxLines: widget.source == 'detail' ? 999 : 3,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (hasPics) ...[
|
||||||
|
Text.rich(picsNodes()),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (item!.modules!.moduleDynamic!.desc != null ||
|
if (item!.modules!.moduleDynamic!.desc != null ||
|
||||||
item!.modules!.moduleDynamic!.major != null)
|
item!.modules!.moduleDynamic!.major != null)
|
||||||
content(item, context, source),
|
Content(item: item, source: source),
|
||||||
forWard(item, context, _dynamicsController, source),
|
forWard(item, context, _dynamicsController, source),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
if (source == null) ActionPanel(item: item),
|
if (source == null) ActionPanel(item: item),
|
||||||
|
|||||||
@ -196,118 +196,118 @@ InlineSpan richNode(item, context) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contentType == 'major' &&
|
// if (contentType == 'major' &&
|
||||||
item.modules.moduleDynamic.major.opus.pics.isNotEmpty) {
|
// item.modules.moduleDynamic.major.opus.pics.isNotEmpty) {
|
||||||
// 图片可能跟其他widget重复渲染
|
// // 图片可能跟其他widget重复渲染
|
||||||
List<OpusPicsModel> pics = item.modules.moduleDynamic.major.opus.pics;
|
// List<OpusPicsModel> pics = item.modules.moduleDynamic.major.opus.pics;
|
||||||
int len = pics.length;
|
// int len = pics.length;
|
||||||
List<String> picList = [];
|
// List<String> picList = [];
|
||||||
|
|
||||||
if (len == 1) {
|
// if (len == 1) {
|
||||||
OpusPicsModel pictureItem = pics.first;
|
// OpusPicsModel pictureItem = pics.first;
|
||||||
picList.add(pictureItem.url!);
|
// picList.add(pictureItem.url!);
|
||||||
spanChilds.add(const TextSpan(text: '\n'));
|
// spanChilds.add(const TextSpan(text: '\n'));
|
||||||
spanChilds.add(
|
// spanChilds.add(
|
||||||
WidgetSpan(
|
// WidgetSpan(
|
||||||
child: LayoutBuilder(
|
// child: LayoutBuilder(
|
||||||
builder: (context, BoxConstraints box) {
|
// builder: (context, BoxConstraints box) {
|
||||||
return GestureDetector(
|
// return GestureDetector(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
showDialog(
|
// showDialog(
|
||||||
useSafeArea: false,
|
// useSafeArea: false,
|
||||||
context: context,
|
// context: context,
|
||||||
builder: (context) {
|
// builder: (context) {
|
||||||
return ImagePreview(initialPage: 0, imgList: picList);
|
// return ImagePreview(initialPage: 0, imgList: picList);
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
child: Padding(
|
// child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 4),
|
// padding: const EdgeInsets.only(top: 4),
|
||||||
child: NetworkImgLayer(
|
// child: NetworkImgLayer(
|
||||||
src: pictureItem.url,
|
// src: pictureItem.url,
|
||||||
width: box.maxWidth / 2,
|
// width: box.maxWidth / 2,
|
||||||
height: box.maxWidth *
|
// height: box.maxWidth *
|
||||||
0.5 *
|
// 0.5 *
|
||||||
(pictureItem.height != null &&
|
// (pictureItem.height != null &&
|
||||||
pictureItem.width != null
|
// pictureItem.width != null
|
||||||
? pictureItem.height! / pictureItem.width!
|
// ? pictureItem.height! / pictureItem.width!
|
||||||
: 1),
|
// : 1),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
if (len > 1) {
|
// if (len > 1) {
|
||||||
List<Widget> list = [];
|
// List<Widget> list = [];
|
||||||
for (var i = 0; i < len; i++) {
|
// for (var i = 0; i < len; i++) {
|
||||||
picList.add(pics[i].url!);
|
// picList.add(pics[i].url!);
|
||||||
list.add(
|
// list.add(
|
||||||
LayoutBuilder(
|
// LayoutBuilder(
|
||||||
builder: (context, BoxConstraints box) {
|
// builder: (context, BoxConstraints box) {
|
||||||
return GestureDetector(
|
// return GestureDetector(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
showDialog(
|
// showDialog(
|
||||||
useSafeArea: false,
|
// useSafeArea: false,
|
||||||
context: context,
|
// context: context,
|
||||||
builder: (context) {
|
// builder: (context) {
|
||||||
return ImagePreview(initialPage: i, imgList: picList);
|
// return ImagePreview(initialPage: i, imgList: picList);
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
child: NetworkImgLayer(
|
// child: NetworkImgLayer(
|
||||||
src: pics[i].url,
|
// src: pics[i].url,
|
||||||
width: box.maxWidth,
|
// width: box.maxWidth,
|
||||||
height: box.maxWidth,
|
// height: box.maxWidth,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
spanChilds.add(
|
// spanChilds.add(
|
||||||
WidgetSpan(
|
// WidgetSpan(
|
||||||
child: LayoutBuilder(
|
// child: LayoutBuilder(
|
||||||
builder: (context, BoxConstraints box) {
|
// builder: (context, BoxConstraints box) {
|
||||||
double maxWidth = box.maxWidth;
|
// double maxWidth = box.maxWidth;
|
||||||
double crossCount = len < 3 ? 2 : 3;
|
// double crossCount = len < 3 ? 2 : 3;
|
||||||
double height = maxWidth /
|
// double height = maxWidth /
|
||||||
crossCount *
|
// crossCount *
|
||||||
(len % crossCount == 0
|
// (len % crossCount == 0
|
||||||
? len ~/ crossCount
|
// ? len ~/ crossCount
|
||||||
: len ~/ crossCount + 1) +
|
// : len ~/ crossCount + 1) +
|
||||||
6;
|
// 6;
|
||||||
return Container(
|
// return Container(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
// padding: const EdgeInsets.only(top: 6),
|
||||||
height: height,
|
// height: height,
|
||||||
child: GridView.count(
|
// child: GridView.count(
|
||||||
padding: EdgeInsets.zero,
|
// padding: EdgeInsets.zero,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
// physics: const NeverScrollableScrollPhysics(),
|
||||||
crossAxisCount: crossCount.toInt(),
|
// crossAxisCount: crossCount.toInt(),
|
||||||
mainAxisSpacing: 4.0,
|
// mainAxisSpacing: 4.0,
|
||||||
crossAxisSpacing: 4.0,
|
// crossAxisSpacing: 4.0,
|
||||||
childAspectRatio: 1,
|
// childAspectRatio: 1,
|
||||||
children: list,
|
// children: list,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
// spanChilds.add(
|
// spanChilds.add(
|
||||||
// WidgetSpan(
|
// WidgetSpan(
|
||||||
// child: NetworkImgLayer(
|
// child: NetworkImgLayer(
|
||||||
// src: pics.first.url,
|
// src: pics.first.url,
|
||||||
// type: 'emote',
|
// type: 'emote',
|
||||||
// width: 100,
|
// width: 100,
|
||||||
// height: 200,
|
// height: 200,
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// );
|
// );
|
||||||
}
|
// }
|
||||||
return TextSpan(
|
return TextSpan(
|
||||||
children: spanChilds,
|
children: spanChilds,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user