mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
优化使用体验
This commit is contained in:
@@ -219,7 +219,7 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage>
|
||||
? const Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
)
|
||||
: CodeWidget(
|
||||
: ScriptCodeWidget(
|
||||
content: content ?? "",
|
||||
),
|
||||
);
|
||||
@@ -265,3 +265,40 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage>
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ScriptCodeWidget extends StatefulWidget {
|
||||
final String content;
|
||||
|
||||
const ScriptCodeWidget({
|
||||
Key? key,
|
||||
required this.content,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ScriptCodeWidget> createState() => _ScriptCodeWidgetState();
|
||||
}
|
||||
|
||||
class _ScriptCodeWidgetState extends State<ScriptCodeWidget>{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SelectableText.rich(
|
||||
TextSpan(
|
||||
style: GoogleFonts.droidSansMono(fontSize: 14).apply(
|
||||
fontSizeFactor: 1,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
DartSyntaxHighlighter(SyntaxHighlighterStyle.lightThemeStyle())
|
||||
.format(widget.content)
|
||||
],
|
||||
),
|
||||
style: DefaultTextStyle.of(context).style.apply(
|
||||
fontSizeFactor: 1,
|
||||
),
|
||||
selectionWidthStyle: BoxWidthStyle.max,
|
||||
selectionHeightStyle: BoxHeightStyle.max,
|
||||
autofocus: true,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user