An open-source cross-platform alternative to AirDrop
feat: add debug page
Tien Do Nam78f11fb97144
diff --git a/analysis_options.yaml b/analysis_options.yamlindex f8fd8fb2..c5d673b5 100644--- a/analysis_options.yaml+++ b/analysis_options.yaml@@ -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: falsediff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dartindex 0d09edd8..466c2555 100644--- a/lib/pages/about_page.dart+++ b/lib/pages/about_page.dart@@ -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),],),);diff --git a/lib/pages/debug_page.dart b/lib/pages/debug_page.dartnew file mode 100644index 00000000..9301179d--- /dev/null+++ b/lib/pages/debug_page.dart@@ -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 ?? '-'),+ );+ }+}diff --git a/lib/pages/tabs/settings_tab.dart b/lib/pages/tabs/settings_tab.dartindex 2f10df75..cedb8c31 100644--- a/lib/pages/tabs/settings_tab.dart+++ b/lib/pages/tabs/settings_tab.dart@@ -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),diff --git a/lib/util/snackbar.dart b/lib/util/snackbar.dartnew file mode 100644index 00000000..50cd94c1--- /dev/null+++ b/lib/util/snackbar.dart@@ -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),+ );+ }+}