mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
logs
This commit is contained in:
80
lib/pages/logs.dart
Normal file
80
lib/pages/logs.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/log.dart';
|
||||
|
||||
class LogsPage extends StatefulWidget {
|
||||
const LogsPage({super.key});
|
||||
|
||||
@override
|
||||
State<LogsPage> createState() => _LogsPageState();
|
||||
}
|
||||
|
||||
class _LogsPageState extends State<LogsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
const TitleBar(title: "Logs"),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
reverse: true,
|
||||
controller: ScrollController(),
|
||||
itemCount: Log.logs.length,
|
||||
itemBuilder: (context, index){
|
||||
index = Log.logs.length - index - 1;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
|
||||
child: SelectionArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).surfaceVariant,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 5, 1),
|
||||
child: Text(Log.logs[index].title),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 3,),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: [
|
||||
ColorScheme.of(context).error,
|
||||
ColorScheme.of(context).errorContainer,
|
||||
ColorScheme.of(context).primaryContainer
|
||||
][Log.logs[index].level.index],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 5, 1),
|
||||
child: Text(
|
||||
Log.logs[index].level.name,
|
||||
style: TextStyle(color: Log.logs[index].level.index==0?Colors.white:Colors.black),),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(Log.logs[index].content),
|
||||
Text(Log.logs[index].time.toString().replaceAll(RegExp(r"\.\w+"), "")),
|
||||
Button(onPressed: (){
|
||||
Clipboard.setData(ClipboardData(text: Log.logs[index].content));
|
||||
}, child: const Text("复制")),
|
||||
const Divider(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@@ -12,6 +12,8 @@ import 'package:pixes/utils/io.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'logs.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@@ -177,6 +179,12 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
onPressed: () =>
|
||||
launchUrlString("https://t.me/pica_group"),
|
||||
)),
|
||||
buildItem(
|
||||
title: "Logs",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () => context.to(() => const LogsPage())
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user