mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: article: show code
Closes #759 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
|
||||
show SourceModel;
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
@@ -9,6 +10,9 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:re_highlight/languages/all.dart';
|
||||
import 'package:re_highlight/re_highlight.dart';
|
||||
import 'package:re_highlight/styles/all.dart';
|
||||
|
||||
Widget opusContent({
|
||||
required BuildContext context,
|
||||
@@ -95,7 +99,7 @@ Widget opusContent({
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text?.nodes!.map<TextSpan>((item) {
|
||||
children: element.text?.nodes?.map<TextSpan>((item) {
|
||||
if (item.rich != null) {
|
||||
return TextSpan(
|
||||
text: '\u{1F517}${item.rich?.text}',
|
||||
@@ -149,10 +153,7 @@ Widget opusContent({
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (callback != null) {
|
||||
callback(
|
||||
[element.pic!.pics!.first.url!],
|
||||
0,
|
||||
);
|
||||
callback([element.pic!.pics!.first.url!], 0);
|
||||
} else {
|
||||
context.imageView(
|
||||
initialPage: 0,
|
||||
@@ -183,8 +184,7 @@ Widget opusContent({
|
||||
|
||||
if (element.paraType == 6) {
|
||||
if (element.linkCard?.card?.ugc != null) {
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
return Material(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8)),
|
||||
@@ -207,7 +207,7 @@ Widget opusContent({
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
radius: 6,
|
||||
width: 65 * 16 / 10,
|
||||
width: 65 * StyleString.aspectRatio,
|
||||
height: 65,
|
||||
src: element.linkCard!.card!.ugc!.cover,
|
||||
),
|
||||
@@ -237,6 +237,32 @@ Widget opusContent({
|
||||
}
|
||||
}
|
||||
|
||||
if (element.paraType == 7) {
|
||||
final Highlight highlight = Highlight()
|
||||
..registerLanguages(builtinAllLanguages);
|
||||
final HighlightResult result = highlight.highlightAuto(
|
||||
element.code!.content!,
|
||||
element.code!.lang == 'language-clike'
|
||||
? ['c', 'java']
|
||||
: [
|
||||
element.code!.lang!
|
||||
.replaceAll('language-', '')
|
||||
.replaceAll('like', ''),
|
||||
]);
|
||||
final TextSpanRenderer renderer = TextSpanRenderer(
|
||||
const TextStyle(), builtinAllThemes['github']!);
|
||||
result.render(renderer);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: SelectableText.rich(renderer.span!),
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
|
||||
@@ -118,7 +118,7 @@ class FavNoteItem extends StatelessWidget {
|
||||
width: constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
|
||||
@@ -534,7 +534,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
width: constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
|
||||
@@ -182,7 +182,7 @@ class HistoryItem extends StatelessWidget {
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic_badge_mode.dart';
|
||||
import 'package:PiliPlus/pages/main/index.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
@@ -52,7 +53,7 @@ class _HomePageState extends State<HomePage>
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
enableFeedback: true,
|
||||
splashBorderRadius: BorderRadius.circular(10),
|
||||
splashBorderRadius: StyleString.mdRadius,
|
||||
tabAlignment: TabAlignment.center,
|
||||
onTap: (value) {
|
||||
feedBack();
|
||||
|
||||
@@ -132,7 +132,7 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
width: constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/avatar.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
|
||||
show SourceModel;
|
||||
@@ -145,8 +146,9 @@ class UserInfoCard extends StatelessWidget {
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
color: context.vipColor),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: context.vipColor,
|
||||
),
|
||||
child: Text(
|
||||
card.vip?.label?.text ?? '大会员',
|
||||
strutStyle: const StrutStyle(
|
||||
|
||||
@@ -564,7 +564,7 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
|
||||
}
|
||||
} else {
|
||||
if (const [301, 302, 303, 307, 308].contains(res.statusCode)) {
|
||||
String? redirectUrl = res.headers['location']?.first;
|
||||
String? redirectUrl = res.headers['location']?.firstOrNull;
|
||||
if (redirectUrl != null) {
|
||||
_onPost(url: redirectUrl);
|
||||
return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/pages/webdav/webdav.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -83,7 +84,7 @@ class _WebDavSettingPageState extends State<WebDavSettingPage> {
|
||||
child: FilledButton.tonal(
|
||||
style: FilledButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
),
|
||||
),
|
||||
onPressed: WebDav().backup,
|
||||
@@ -95,7 +96,7 @@ class _WebDavSettingPageState extends State<WebDavSettingPage> {
|
||||
child: FilledButton.tonal(
|
||||
style: FilledButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
),
|
||||
),
|
||||
onPressed: WebDav().restore,
|
||||
|
||||
Reference in New Issue
Block a user