feat: add debug page

This commit is contained in:
Tien Do Nam
2022-12-28 17:49:55 +01:00
parent 6b9553dbe7
commit 78f11fb971
5 changed files with 104 additions and 22 deletions
+4
View File
@@ -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
+8
View File
@@ -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),
],
),
);
+56
View File
@@ -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 ?? '-'),
);
}
}
+24 -22
View File
@@ -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),
+12
View File
@@ -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),
);
}
}