mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-19 08:36:17 +08:00
feat: cross row select (#867)
This commit is contained in:
committed by
GitHub
parent
76a5b6221d
commit
89a077be5c
@@ -269,24 +269,28 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
final maxWidth = constraints.maxWidth - 2 * padding - 24;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: padding),
|
||||
child: SelectionArea(
|
||||
child: CustomScrollView(
|
||||
controller: _articleCtr.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
_buildContent(theme, maxWidth),
|
||||
SliverToBoxAdapter(
|
||||
SelectionContainer.disabled(
|
||||
child: SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
thickness: 8,
|
||||
color:
|
||||
theme.dividerColor.withValues(alpha: 0.05),
|
||||
color: theme.dividerColor
|
||||
.withValues(alpha: 0.05),
|
||||
),
|
||||
),
|
||||
_buildReplyHeader(theme),
|
||||
Obx(() => _buildReplyList(
|
||||
theme, _articleCtr.loadingState.value)),
|
||||
)),
|
||||
SelectionContainer.disabled(
|
||||
child: _buildReplyHeader(theme)),
|
||||
SelectionContainer.disabled(
|
||||
child: Obx(() => _buildReplyList(theme,
|
||||
_articleCtr.loadingState.value))),
|
||||
],
|
||||
),
|
||||
);
|
||||
));
|
||||
});
|
||||
} else {
|
||||
return Row(
|
||||
@@ -298,7 +302,8 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
builder: (context, constraints) {
|
||||
final maxWidth =
|
||||
constraints.maxWidth - padding / 4 - 24;
|
||||
return CustomScrollView(
|
||||
return SelectionArea(
|
||||
child: CustomScrollView(
|
||||
controller: _articleCtr.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
@@ -312,7 +317,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
sliver: _buildContent(theme, maxWidth),
|
||||
),
|
||||
],
|
||||
);
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -421,10 +426,10 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
?.pics?.isNotEmpty ==
|
||||
true)
|
||||
SliverToBoxAdapter(
|
||||
child: Builder(
|
||||
child: SelectionContainer.disabled(child: Builder(
|
||||
builder: (context) {
|
||||
final pics = _articleCtr.opusData!.modules.moduleTop!
|
||||
.display!.album!.pics!;
|
||||
final pics = _articleCtr
|
||||
.opusData!.modules.moduleTop!.display!.album!.pics!;
|
||||
final length = pics.length;
|
||||
final first = pics.first;
|
||||
double height;
|
||||
@@ -456,8 +461,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => context.imageView(
|
||||
imgList: pics
|
||||
.map(
|
||||
(e) => SourceModel(url: e.url!))
|
||||
.map((e) => SourceModel(url: e.url!))
|
||||
.toList(),
|
||||
initialPage: index,
|
||||
),
|
||||
@@ -501,10 +505,10 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
))),
|
||||
if (_articleCtr.summary.title != null)
|
||||
SliverToBoxAdapter(
|
||||
SelectionContainer.disabled(
|
||||
child: SliverToBoxAdapter(
|
||||
child: Text(
|
||||
_articleCtr.summary.title!,
|
||||
style: const TextStyle(
|
||||
@@ -512,8 +516,9 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
)),
|
||||
SelectionContainer.disabled(
|
||||
child: SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureDetector(
|
||||
@@ -554,15 +559,16 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (_articleCtr.type != 'read' &&
|
||||
_articleCtr.opusData?.modules.moduleCollection != null)
|
||||
SliverToBoxAdapter(
|
||||
SelectionContainer.disabled(
|
||||
child: SliverToBoxAdapter(
|
||||
child: opusCollection(
|
||||
theme,
|
||||
_articleCtr.opusData!.modules.moduleCollection!,
|
||||
),
|
||||
),
|
||||
)),
|
||||
content,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -126,8 +126,7 @@ Widget htmlRender({
|
||||
margin: Margins.zero,
|
||||
),
|
||||
};
|
||||
return SelectionArea(
|
||||
child: element != null
|
||||
return element != null
|
||||
? Html.fromElement(
|
||||
documentElement: element,
|
||||
extensions: extensions,
|
||||
@@ -137,6 +136,5 @@ Widget htmlRender({
|
||||
data: html,
|
||||
extensions: extensions,
|
||||
style: style,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ class OpusContent extends StatelessWidget {
|
||||
switch (element.paraType) {
|
||||
case 1 || 4:
|
||||
final isQuote = element.paraType == 4;
|
||||
Widget widget = SelectionArea(
|
||||
child: Text.rich(
|
||||
Widget widget = Text.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text?.nodes?.map((item) {
|
||||
@@ -140,7 +139,6 @@ class OpusContent extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}).toList()),
|
||||
),
|
||||
);
|
||||
if (isQuote) {
|
||||
widget = Container(
|
||||
@@ -167,7 +165,8 @@ class OpusContent extends StatelessWidget {
|
||||
final height = width == null || pic.height == null
|
||||
? null
|
||||
: width * pic.height! / pic.width!;
|
||||
return Hero(
|
||||
return SelectionContainer.disabled(
|
||||
child: Hero(
|
||||
tag: pic.url!,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
@@ -192,25 +191,26 @@ class OpusContent extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
} else {
|
||||
return imageView(
|
||||
return SelectionContainer.disabled(
|
||||
child: imageView(
|
||||
maxWidth,
|
||||
element.pic!.pics!
|
||||
.map(
|
||||
(e) => ImageModel(width: 1, height: 1, url: e.url!))
|
||||
.toList());
|
||||
.map((e) =>
|
||||
ImageModel(width: 1, height: 1, url: e.url!))
|
||||
.toList()));
|
||||
}
|
||||
case 3 when (element.line != null):
|
||||
return CachedNetworkImage(
|
||||
return SelectionContainer.disabled(
|
||||
child: CachedNetworkImage(
|
||||
width: maxWidth,
|
||||
fit: BoxFit.contain,
|
||||
height: element.line!.pic!.height?.toDouble(),
|
||||
imageUrl: Utils.thumbnailImgUrl(element.line!.pic!.url!),
|
||||
);
|
||||
));
|
||||
case 5 when (element.list != null):
|
||||
return SelectionArea(
|
||||
child: Text.rich(
|
||||
return Text.rich(
|
||||
TextSpan(
|
||||
children: element.list!.items?.indexed.map((entry) {
|
||||
return TextSpan(
|
||||
@@ -228,7 +228,6 @@ class OpusContent extends StatelessWidget {
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
case 6:
|
||||
return Material(
|
||||
@@ -528,7 +527,7 @@ class OpusContent extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
case 7 when (element.code != null):
|
||||
final Highlight highlight = Highlight()
|
||||
final highlight = Highlight()
|
||||
..registerLanguages(builtinAllLanguages);
|
||||
final HighlightResult result = highlight.highlightAuto(
|
||||
element.code!.content!,
|
||||
@@ -539,7 +538,7 @@ class OpusContent extends StatelessWidget {
|
||||
.replaceAll('language-', '')
|
||||
.replaceAll('like', ''),
|
||||
]);
|
||||
final TextSpanRenderer renderer = TextSpanRenderer(
|
||||
final renderer = TextSpanRenderer(
|
||||
const TextStyle(), builtinAllThemes['github']!);
|
||||
result.render(renderer);
|
||||
return Container(
|
||||
@@ -549,41 +548,35 @@ class OpusContent extends StatelessWidget {
|
||||
color: colorScheme.onInverseSurface,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: SelectionArea(child: Text.rich(renderer.span!)),
|
||||
child: Text.rich(renderer.span!),
|
||||
);
|
||||
default:
|
||||
debugPrint('unknown type ${element.paraType}');
|
||||
if (element.text?.nodes?.isNotEmpty == true) {
|
||||
return SelectionArea(
|
||||
child: Text.rich(
|
||||
return Text.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text!.nodes!
|
||||
.map<TextSpan>((item) => _getSpan(item.word))
|
||||
.toList()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SelectionArea(
|
||||
child: Text(
|
||||
return Text(
|
||||
'不支持的类型 (${element.paraType})',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
return SelectionArea(
|
||||
child: Text(
|
||||
return Text(
|
||||
'错误的类型 $e',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -597,7 +590,7 @@ Widget moduleBlockedItem(
|
||||
BoxDecoration? bgImg() {
|
||||
return moduleBlocked.bgImg == null
|
||||
? null
|
||||
: BoxDecoration(
|
||||
: (BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.fill,
|
||||
image: CachedNetworkImageProvider(
|
||||
@@ -608,7 +601,7 @@ Widget moduleBlockedItem(
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget icon(double width) {
|
||||
@@ -690,7 +683,8 @@ Widget moduleBlockedItem(
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
return SelectionContainer.disabled(
|
||||
child: Container(
|
||||
decoration: bgImg(),
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
@@ -726,7 +720,7 @@ Widget moduleBlockedItem(
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget opusCollection(ThemeData theme, ModuleCollection item) {
|
||||
|
||||
@@ -25,13 +25,14 @@ class ReadOpus extends StatelessWidget {
|
||||
try {
|
||||
final item = ops![index];
|
||||
if (item.insert is String) {
|
||||
return SelectableText(item.insert);
|
||||
return Text(item.insert);
|
||||
}
|
||||
|
||||
if (item.insert is Insert) {
|
||||
InsertCard card = item.insert.card;
|
||||
if (card.url?.isNotEmpty == true) {
|
||||
return GestureDetector(
|
||||
return SelectionContainer.disabled(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
switch (item.attributes?.clazz) {
|
||||
case 'article-card card':
|
||||
@@ -60,7 +61,7 @@ class ReadOpus extends StatelessWidget {
|
||||
imageUrl: Utils.thumbnailImgUrl(card.url, 60),
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user