feat: cross row select (#2437)

* feat(wip): cross row select

* fix patch

Signed-off-by: dom <githubaccount56556@proton.me>

* update

Signed-off-by: dom <githubaccount56556@proton.me>

---------

Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
My-Responsitories
2026-07-03 13:37:45 +00:00
committed by GitHub
parent 204715266f
commit b540647222
6 changed files with 472 additions and 226 deletions

View File

@@ -74,21 +74,27 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
if (isPortrait) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: padding),
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
_buildContent(
maxWidth - this.padding.horizontal - 2 * padding - 24,
),
SliverToBoxAdapter(
child: Divider(
thickness: 8,
color: theme.dividerColor.withValues(alpha: 0.05),
child: SelectionArea(
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
_buildContent(
maxWidth - this.padding.horizontal - 2 * padding - 24,
),
),
buildReplyHeader(),
Obx(() => replyList(controller.loadingState.value)),
],
SelectionContainer.disabled(
child: SliverToBoxAdapter(
child: Divider(
thickness: 8,
color: theme.dividerColor.withValues(alpha: 0.05),
),
),
),
SelectionContainer.disabled(child: buildReplyHeader()),
SelectionContainer.disabled(
child: Obx(() => replyList(controller.loadingState.value)),
),
],
),
),
);
}
@@ -101,21 +107,25 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
children: [
Expanded(
flex: flex,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
left: padding,
bottom: this.padding.bottom + 100,
child: SelectionArea(
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
left: padding,
bottom: this.padding.bottom + 100,
),
sliver: _buildContent(
(maxWidth - this.padding.horizontal) *
flex /
(flex + flex1) -
padding -
32,
),
),
sliver: _buildContent(
(maxWidth - this.padding.horizontal) * flex / (flex + flex1) -
padding -
32,
),
),
],
],
),
),
),
VerticalDivider(
@@ -151,7 +161,7 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
sliver: Obx(
() {
if (controller.isLoaded.value) {
late Widget content;
final Widget content;
if (controller.opus != null) {
// if (kDebugMode) debugPrint('json page');
content = OpusContent(
@@ -159,9 +169,9 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
images: controller.images,
maxWidth: maxWidth,
);
} else if (controller.opusData?.modules.moduleBlocked != null) {
} else if (controller.opusData?.modules.moduleBlocked
case final moduleBlocked?) {
// if (kDebugMode) debugPrint('moduleBlocked');
final moduleBlocked = controller.opusData!.modules.moduleBlocked!;
content = SliverToBoxAdapter(
child: moduleBlockedItem(context, theme, moduleBlocked),
);
@@ -201,128 +211,119 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
content = const SliverToBoxAdapter(child: Text('NULL'));
}
int? pubTime =
final pubTime =
controller.opusData?.modules.moduleAuthor?.pubTs ??
controller.articleData?.publishTime;
return SliverMainAxisGroup(
slivers: [
if (controller.type != 'read' &&
controller
.opusData
?.modules
.moduleTop
?.display
?.album
?.pics
?.isNotEmpty ==
true)
SliverToBoxAdapter(
child: Builder(
builder: (context) {
final pics = controller
.opusData!
.modules
.moduleTop!
.display!
.album!
.pics!;
final length = pics.length;
final first = pics.first;
double height;
if (first.height != null && first.width != null) {
final ratio = first.height! / first.width!;
height = min(maxWidth * ratio, maxHeight * 0.55);
} else {
height = maxHeight * 0.55;
}
return Stack(
clipBehavior: Clip.none,
children: [
Container(
height: height,
width: maxWidth,
margin: const EdgeInsets.only(bottom: 10),
child: PageView.builder(
physics: clampingScrollPhysics,
onPageChanged: (value) =>
controller.topIndex.value = value,
itemCount: length,
itemBuilder: (context, index) {
final pic = pics[index];
int? memCacheWidth, memCacheHeight;
if (pic.isLongPic ?? false) {
memCacheWidth = maxWidth.cacheSize(context);
} else if (pic.width != null &&
pic.height != null) {
if (pic.width! > pic.height!) {
if (controller.type != 'read')
if (controller.opusData?.modules.moduleTop?.display?.album?.pics
case final pics? when pics.isNotEmpty)
SliverToBoxAdapter(
child: Builder(
builder: (context) {
final length = pics.length;
final first = pics.first;
double height;
if (first.height != null && first.width != null) {
final ratio = first.height! / first.width!;
height = min(maxWidth * ratio, maxHeight * 0.55);
} else {
height = maxHeight * 0.55;
}
return Stack(
clipBehavior: Clip.none,
children: [
Container(
height: height,
width: maxWidth,
margin: const EdgeInsets.only(bottom: 10),
child: PageView.builder(
physics: clampingScrollPhysics,
onPageChanged: (value) =>
controller.topIndex.value = value,
itemCount: length,
itemBuilder: (context, index) {
final pic = pics[index];
int? memCacheWidth, memCacheHeight;
if (pic.isLongPic ?? false) {
memCacheWidth = maxWidth.cacheSize(context);
} else {
memCacheHeight = height.cacheSize(context);
} else if (pic.width != null &&
pic.height != null) {
if (pic.width! > pic.height!) {
memCacheWidth = maxWidth.cacheSize(
context,
);
} else {
memCacheHeight = height.cacheSize(
context,
);
}
}
}
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => PageUtils.imageView(
quality: 60,
imgList: pics
.map((e) => SourceModel(url: e.url!))
.toList(),
initialPage: index,
),
child: Hero(
tag: pic.url!,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
CachedNetworkImage(
height: height,
width: maxWidth,
memCacheWidth: memCacheWidth,
memCacheHeight: memCacheHeight,
fit: pic.isLongPic == true
? BoxFit.cover
: null,
imageUrl: ImageUtils.thumbnailUrl(
pic.url,
60,
),
fadeInDuration: const Duration(
milliseconds: 120,
),
fadeOutDuration: const Duration(
milliseconds: 120,
),
placeholder: (_, _) =>
const SizedBox.shrink(),
),
if (pic.isLongPic == true)
const PBadge(
right: 12,
bottom: 12,
text: '长图',
type: .primary,
),
],
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => PageUtils.imageView(
quality: 60,
imgList: pics
.map((e) => SourceModel(url: e.url!))
.toList(),
initialPage: index,
),
),
);
},
child: Hero(
tag: pic.url!,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
CachedNetworkImage(
height: height,
width: maxWidth,
memCacheWidth: memCacheWidth,
memCacheHeight: memCacheHeight,
fit: pic.isLongPic == true
? BoxFit.cover
: null,
imageUrl: ImageUtils.thumbnailUrl(
pic.url,
60,
),
fadeInDuration: const Duration(
milliseconds: 120,
),
fadeOutDuration: const Duration(
milliseconds: 120,
),
placeholder: (_, _) =>
const SizedBox.shrink(),
),
if (pic.isLongPic == true)
const PBadge(
right: 12,
bottom: 12,
text: '长图',
type: .primary,
),
],
),
),
);
},
),
),
),
Obx(
() => PBadge(
top: 12,
right: 12,
type: PBadgeType.gray,
text: '${controller.topIndex.value + 1}/$length',
Obx(
() => PBadge(
top: 12,
right: 12,
type: PBadgeType.gray,
text:
'${controller.topIndex.value + 1}/$length',
),
),
),
],
);
},
],
);
},
),
),
),
if (controller.summary.title != null)
SliverToBoxWithVisibilityAdapter(
onVisibilityChanged: (bool visible) =>
@@ -342,39 +343,41 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
onTap: () => Get.toNamed(
'/member?mid=${controller.summary.author?.mid}',
),
child: Row(
children: [
NetworkImgLayer(
width: 40,
height: 40,
type: ImageType.avatar,
src: controller.summary.author?.face,
),
const SizedBox(width: 10),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
controller.summary.author?.name ?? '',
style: TextStyle(
fontSize:
theme.textTheme.titleSmall!.fontSize,
),
),
if (pubTime != null)
child: SelectionContainer.disabled(
child: Row(
children: [
NetworkImgLayer(
width: 40,
height: 40,
type: ImageType.avatar,
src: controller.summary.author?.face,
),
const SizedBox(width: 10),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
DateFormatUtils.format(pubTime),
controller.summary.author?.name ?? '',
style: TextStyle(
color: theme.colorScheme.outline,
fontSize:
theme.textTheme.labelSmall!.fontSize,
theme.textTheme.titleSmall!.fontSize,
),
),
],
if (pubTime != null)
Text(
DateFormatUtils.format(pubTime),
style: TextStyle(
color: theme.colorScheme.outline,
fontSize:
theme.textTheme.labelSmall!.fontSize,
),
),
],
),
),
),
],
],
),
),
),
),
@@ -382,9 +385,11 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
if (controller.type != 'read' &&
controller.opusData?.modules.moduleCollection != null)
SliverToBoxAdapter(
child: opusCollection(
theme,
controller.opusData!.modules.moduleCollection!,
child: SelectionContainer.disabled(
child: opusCollection(
theme,
controller.opusData!.modules.moduleCollection!,
),
),
),
content,

View File

@@ -33,7 +33,7 @@ class ArticleOpus extends StatelessWidget {
final item = _ops[index];
switch (item.insert) {
case String e:
return SelectableText(e);
return Text(e);
case Insert(:final card):
if (card != null) {
if (card.url?.isNotEmpty == true) {

View File

@@ -125,17 +125,15 @@ Widget htmlRender({
margin: Margins.zero,
),
};
return SelectionArea(
child: element != null
? Html.fromElement(
documentElement: element,
extensions: extensions,
style: style,
)
: Html(
data: html,
extensions: extensions,
style: style,
),
);
return element != null
? Html.fromElement(
documentElement: element,
extensions: extensions,
style: style,
)
: Html(
data: html,
extensions: extensions,
style: style,
);
}

View File

@@ -178,7 +178,7 @@ class OpusContent extends StatelessWidget {
switch (element.paraType) {
case 1 || 4:
final isQuote = element.paraType == 4;
Widget widget = SelectableText.rich(
Widget widget = Text.rich(
textAlign: element.align == 1 ? TextAlign.center : null,
TextSpan(
children: element.text?.nodes
@@ -194,12 +194,7 @@ class OpusContent extends StatelessWidget {
);
if (isQuote) {
widget = Container(
padding: const EdgeInsets.only(
left: 8,
top: 4,
right: 4,
bottom: 4,
),
padding: const .only(left: 8, top: 4, right: 4, bottom: 4),
decoration: BoxDecoration(
border: Border(
left: BorderSide(
@@ -215,8 +210,9 @@ class OpusContent extends StatelessWidget {
}
return widget;
case 2 when (element.pic != null):
if (element.pic!.pics!.length == 1) {
final pic = element.pic!.pics!.first;
final pics = element.pic!.pics!;
if (pics.length == 1) {
final pic = pics.first;
double? width = pic.width == null
? null
: math.min(maxWidth, pic.width!);
@@ -250,7 +246,7 @@ class OpusContent extends StatelessWidget {
);
} else {
return ImageGridView(
picArr: element.pic!.pics!
picArr: pics
.map(
(e) => ImageModel(
width: e.width,
@@ -262,19 +258,20 @@ class OpusContent extends StatelessWidget {
);
}
case 3 when (element.line?.pic != null):
final height = element.line!.pic!.height?.toDouble();
final pic = element.line!.pic!;
final height = pic.height?.toDouble();
return CachedNetworkImage(
fit: .contain,
height: height,
width: maxWidth,
memCacheWidth: maxWidth.cacheSize(context),
imageUrl: ImageUtils.thumbnailUrl(element.line!.pic!.url!),
imageUrl: ImageUtils.thumbnailUrl(pic.url!),
placeholder: (_, _) => const SizedBox.shrink(),
);
case 5 when (element.list != null):
return SelectableText.rich(
case 5 when (element.list?.items?.isNotEmpty == true):
return Text.rich(
TextSpan(
children: element.list!.items?.mapIndexed((i, entry) {
children: element.list!.items!.mapIndexed((i, entry) {
return TextSpan(
children: [
const WidgetSpan(
@@ -589,39 +586,32 @@ class OpusContent extends StatelessWidget {
? null
: () {
try {
final card = element.linkCard!.card!;
if (type == 'LINK_CARD_TYPE_VOTE') {
showVoteDialog(
context,
element.linkCard!.card!.vote?.voteId ??
int.parse(element.linkCard!.card!.oid!),
card.vote?.voteId ?? int.parse(card.oid!),
);
return;
}
if (type == 'LINK_CARD_TYPE_ITEM_NULL') {
switch (element.linkCard?.card?.itemNull?.text) {
switch (card.itemNull?.text) {
case '视频':
PiliScheme.videoPush(
int.parse(element.linkCard!.card!.oid!),
int.parse(card.oid!),
null,
);
default:
PageUtils.pushDynFromId(
id: element.linkCard!.card!.oid!,
);
PageUtils.pushDynFromId(id: card.oid!);
}
return;
}
String? url = switch (type) {
'LINK_CARD_TYPE_UGC' =>
element.linkCard!.card!.ugc!.jumpUrl,
'LINK_CARD_TYPE_COMMON' =>
element.linkCard!.card!.common!.jumpUrl,
'LINK_CARD_TYPE_LIVE' =>
element.linkCard!.card!.live!.jumpUrl,
'LINK_CARD_TYPE_OPUS' =>
element.linkCard!.card!.opus!.jumpUrl,
'LINK_CARD_TYPE_MUSIC' =>
element.linkCard!.card!.music!.jumpUrl,
final url = switch (type) {
'LINK_CARD_TYPE_UGC' => card.ugc!.jumpUrl,
'LINK_CARD_TYPE_COMMON' => card.common!.jumpUrl,
'LINK_CARD_TYPE_LIVE' => card.live!.jumpUrl,
'LINK_CARD_TYPE_OPUS' => card.opus!.jumpUrl,
'LINK_CARD_TYPE_MUSIC' => card.music!.jumpUrl,
_ => null,
};
if (url != null && url.isNotEmpty) {
@@ -660,10 +650,10 @@ class OpusContent extends StatelessWidget {
color: colorScheme.onInverseSurface,
),
width: .infinity,
child: SelectableText.rich(renderer.span!),
child: Text.rich(renderer.span!),
);
case 8 when (element.heading?.nodes?.isNotEmpty == true):
return SelectableText.rich(
return Text.rich(
TextSpan(
children: element.heading!.nodes!
.map(
@@ -679,7 +669,7 @@ class OpusContent extends StatelessWidget {
default:
if (kDebugMode) debugPrint('unknown type ${element.paraType}');
if (element.text?.nodes?.isNotEmpty == true) {
return SelectableText.rich(
return Text.rich(
textAlign: element.align == 1 ? TextAlign.center : null,
TextSpan(
children: element.text!.nodes!
@@ -694,7 +684,7 @@ class OpusContent extends StatelessWidget {
);
}
return SelectableText(
return Text(
'不支持的类型 (${element.paraType})',
style: const TextStyle(
fontWeight: .bold,
@@ -703,7 +693,7 @@ class OpusContent extends StatelessWidget {
);
}
} catch (e, s) {
return SelectableText(
return Text(
'错误的类型 $e${kDebugMode ? '\n$s' : ''}',
style: const TextStyle(
fontWeight: .bold,