mirror of
https://github.com/localsend/localsend.git
synced 2026-06-23 04:10:07 +00:00
feat: add debug page
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
analyzer:
|
||||
exclude:
|
||||
- lib/**.g.dart
|
||||
|
||||
linter:
|
||||
rules:
|
||||
avoid_print: false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localsend_app/gen/strings.g.dart';
|
||||
import 'package:localsend_app/pages/debug_page.dart';
|
||||
import 'package:localsend_app/widget/local_send_logo.dart';
|
||||
import 'package:routerino/routerino.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
@@ -57,8 +58,15 @@ class AboutPage extends StatelessWidget {
|
||||
},
|
||||
child: const Text('License Notices'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.push(() => const DebugPage());
|
||||
},
|
||||
child: const Text('Debugging'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 50),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:localsend_app/util/snackbar.dart';
|
||||
|
||||
const _headerStyle = TextStyle(fontWeight: FontWeight.bold);
|
||||
|
||||
class DebugPage extends ConsumerWidget {
|
||||
const DebugPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Debugging'),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30),
|
||||
children: [
|
||||
const Text('Debug Mode', style: _headerStyle),
|
||||
Text(kDebugMode.toString()),
|
||||
const SizedBox(height: 20),
|
||||
const Text('Dart SDK', style: _headerStyle),
|
||||
_CopyableText(
|
||||
name: 'Dart SDK',
|
||||
value: Platform.version,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CopyableText extends StatelessWidget {
|
||||
final String name;
|
||||
final String? value;
|
||||
|
||||
const _CopyableText({
|
||||
required this.name,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: value));
|
||||
context.showSnackBar('Copied $name to clipboard!');
|
||||
},
|
||||
child: Text(value ?? '-'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -191,30 +191,32 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
context.push(() => const AboutPage());
|
||||
},
|
||||
icon: const Icon(Icons.info),
|
||||
label: Text(t.aboutPage.title),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
onPressed: () {
|
||||
context.push(() => const ChangelogPage());
|
||||
},
|
||||
icon: const Icon(Icons.history),
|
||||
label: Text(t.changelogPage.title),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
context.push(() => const AboutPage());
|
||||
},
|
||||
icon: const Icon(Icons.info),
|
||||
label: Text(t.aboutPage.title),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
context.push(() => const ChangelogPage());
|
||||
},
|
||||
icon: const Icon(Icons.history),
|
||||
label: Text(t.changelogPage.title),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension SnackbarExt on BuildContext {
|
||||
void showSnackBar(String text) {
|
||||
final scaffold = ScaffoldMessenger.of(this);
|
||||
scaffold.removeCurrentSnackBar();
|
||||
scaffold.showSnackBar(SnackBar(
|
||||
content: Text(text),
|
||||
backgroundColor: Colors.lightGreen.shade900),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user