Skip to content

An open-source cross-platform alternative to AirDrop

feat: show separate troubleshoot page on mobile

Tien Do Namb42520b591c5
diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart
index 3bd7767a..fd8c9574 100644
--- a/lib/pages/home_page.dart
+++ b/lib/pages/home_page.dart
@@ -8,7 +8,7 @@ import 'package:localsend_app/init.dart';
import 'package:localsend_app/pages/tabs/receive_tab.dart';
import 'package:localsend_app/pages/tabs/send_tab.dart';
import 'package:localsend_app/pages/tabs/settings_tab.dart';
-import 'package:localsend_app/pages/tabs/troubleshooting_tab.dart';
+import 'package:localsend_app/pages/tabs/troubleshoot_tab.dart';
import 'package:localsend_app/provider/selection/selected_sending_files_provider.dart';
import 'package:localsend_app/theme.dart';
import 'package:localsend_app/widget/responsive_builder.dart';
@@ -133,7 +133,7 @@ class _HomePageState extends ConsumerState<HomePage> {
ReceiveTab(),
SendTab(),
SettingsTab(),
- TroubleshootingTab(),
+ TroubleshootTab(showTitle: true),
],
),
if (_dragAndDropIndicator)
@@ -165,7 +165,7 @@ class _HomePageState extends ConsumerState<HomePage> {
HomeTab.receive,
HomeTab.send,
HomeTab.settings,
- if (sizingInformation.isTablet)
+ if (sizingInformation.isTabletOrDesktop)
HomeTab.troubleshoot,
].map((tab) {
return NavigationDestination(icon: Icon(tab.icon), label: tab.label);
diff --git a/lib/pages/tabs/send_tab.dart b/lib/pages/tabs/send_tab.dart
index 8f43b336..db4f2769 100644
--- a/lib/pages/tabs/send_tab.dart
+++ b/lib/pages/tabs/send_tab.dart
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:localsend_app/gen/strings.g.dart';
import 'package:localsend_app/model/device.dart';
import 'package:localsend_app/pages/selected_files_page.dart';
+import 'package:localsend_app/pages/troubleshoot_page.dart';
import 'package:localsend_app/provider/device_info_provider.dart';
import 'package:localsend_app/provider/network/nearby_devices_provider.dart';
import 'package:localsend_app/provider/network/scan_provider.dart';
@@ -20,6 +21,7 @@ import 'package:localsend_app/widget/dialogs/address_input_dialog.dart';
import 'package:localsend_app/widget/dialogs/no_files_dialog.dart';
import 'package:localsend_app/widget/file_thumbnail.dart';
import 'package:localsend_app/widget/list_tile/device_list_tile.dart';
+import 'package:localsend_app/widget/responsive_builder.dart';
import 'package:localsend_app/widget/responsive_list_view.dart';
import 'package:localsend_app/widget/rotating_widget.dart';
import 'package:routerino/routerino.dart';
@@ -278,6 +280,25 @@ class _SendTabState extends ConsumerState<SendTab> {
),
);
}),
+ ResponsiveBuilder(
+ builder: (sizingInformation) {
+ if (sizingInformation.isMobile) {
+ return Padding(
+ padding: const EdgeInsets.only(top: 10),
+ child: Center(
+ child: ElevatedButton(
+ onPressed: () {
+ context.push(() => const TroubleshootPage());
+ },
+ child: Text(t.troubleshootTab.title),
+ ),
+ ),
+ );
+ } else {
+ return Container();
+ }
+ },
+ ),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: _horizontalPadding),
diff --git a/lib/pages/tabs/troubleshooting_tab.dart b/lib/pages/tabs/troubleshoot_tab.dart
similarity index 94%
rename from lib/pages/tabs/troubleshooting_tab.dart
rename to lib/pages/tabs/troubleshoot_tab.dart
index 8572d58a..157e5f13 100644
--- a/lib/pages/tabs/troubleshooting_tab.dart
+++ b/lib/pages/tabs/troubleshoot_tab.dart
@@ -11,8 +11,10 @@ import 'package:localsend_app/widget/custom_icon_button.dart';
import 'package:localsend_app/widget/dialogs/not_available_on_platform_dialog.dart';
import 'package:localsend_app/widget/responsive_list_view.dart';
-class TroubleshootingTab extends ConsumerWidget {
- const TroubleshootingTab({Key? key}) : super(key: key);
+class TroubleshootTab extends ConsumerWidget {
+ final bool showTitle;
+
+ const TroubleshootTab({required this.showTitle});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -20,8 +22,11 @@ class TroubleshootingTab extends ConsumerWidget {
return ResponsiveListView(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 30),
children: [
- Text(t.troubleshootTab.title, style: Theme.of(context).textTheme.titleLarge, textAlign: TextAlign.center),
- const SizedBox(height: 20),
+ if (showTitle)
+ ...[
+ Text(t.troubleshootTab.title, style: Theme.of(context).textTheme.titleLarge, textAlign: TextAlign.center),
+ const SizedBox(height: 20),
+ ],
Text(t.troubleshootTab.subTitle, textAlign: TextAlign.center),
const SizedBox(height: 5),
_TroubleshootItem(
@@ -46,10 +51,6 @@ class TroubleshootingTab extends ConsumerWidget {
adminPrivileges: false,
commands: ['wf'],
),
- TargetPlatform.macOS: _CommandFixAction(
- adminPrivileges: false,
- commands: ['wf'],
- ),
},
),
),
@@ -100,6 +101,7 @@ class _TroubleshootItemState extends State<_TroubleshootItem> {
...[
const SizedBox(height: 10),
Wrap(
+ runSpacing: 10,
children: [
widget.primaryButton!,
if (widget.secondaryButton != null)
diff --git a/lib/pages/troubleshoot_page.dart b/lib/pages/troubleshoot_page.dart
new file mode 100644
index 00000000..782722f9
--- /dev/null
+++ b/lib/pages/troubleshoot_page.dart
@@ -0,0 +1,18 @@
+import 'package:flutter/material.dart';
+import 'package:localsend_app/gen/strings.g.dart';
+import 'package:localsend_app/pages/tabs/troubleshoot_tab.dart';
+
+/// This is just a wrapper around [TroubleshootTab].
+class TroubleshootPage extends StatelessWidget {
+ const TroubleshootPage({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(t.troubleshootTab.title),
+ ),
+ body: const TroubleshootTab(showTitle: false),
+ );
+ }
+}
diff --git a/lib/widget/responsive_builder.dart b/lib/widget/responsive_builder.dart
index ab09c7c4..3e840365 100644
--- a/lib/widget/responsive_builder.dart
+++ b/lib/widget/responsive_builder.dart
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
class SizingInformation {
final bool isMobile;
- final bool isTablet;
+ final bool isTabletOrDesktop;
final bool isDesktop;
- const SizingInformation(double width) : isMobile = width < 700, isTablet = width >= 700, isDesktop = width >= 800;
+ const SizingInformation(double width) : isMobile = width < 700, isTabletOrDesktop = width >= 700, isDesktop = width >= 800;
}
class ResponsiveBuilder extends StatelessWidget {