An open-source cross-platform alternative to AirDrop
feat: improve text button theme padding
Tien Do Nam6e647ceca4fb
diff --git a/lib/pages/progress_page.dart b/lib/pages/progress_page.dartindex f07b64c3..4995a232 100644--- a/lib/pages/progress_page.dart+++ b/lib/pages/progress_page.dart@@ -165,7 +165,8 @@ class _ProgressPageState extends ConsumerState<ProgressPage> {fileName,style: const TextStyle(fontSize: 16),maxLines: 1,- overflow: TextOverflow.ellipsis,+ overflow: TextOverflow.fade,+ softWrap: false,),),Text(' (${file.size.asReadableFileSize})', style: const TextStyle(fontSize: 16)),diff --git a/lib/pages/receive_options_page.dart b/lib/pages/receive_options_page.dartindex d4edef45..78c1b76a 100644--- a/lib/pages/receive_options_page.dart+++ b/lib/pages/receive_options_page.dart@@ -5,6 +5,7 @@ import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/provider/network/server_provider.dart';import 'package:localsend_app/provider/selection/selected_receiving_files_provider.dart';import 'package:localsend_app/util/file_size_helper.dart';+import 'package:localsend_app/widget/custom_icon_button.dart';import 'package:localsend_app/widget/dialogs/file_name_input_dialog.dart';import 'package:localsend_app/widget/dialogs/quick_actions_dialog.dart';import 'package:localsend_app/widget/responsive_list_view.dart';@@ -38,13 +39,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {children: [Text(t.receiveOptionsPage.destination, style: Theme.of(context).textTheme.headline6),const SizedBox(width: 10),- TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ CustomIconButton(onPressed: () async {final directory = await FilePicker.platform.getDirectoryPath();if (directory != null) {@@ -64,13 +59,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {const SizedBox(width: 10),Tooltip(message: t.dialogs.quickActions.title,- child: TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ child: CustomIconButton(onPressed: () {showDialog(context: context, builder: (_) => const QuickActionsDialog());},@@ -80,13 +69,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {const SizedBox(width: 10),Tooltip(message: t.general.reset,- child: TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ child: CustomIconButton(onPressed: () async {ref.read(selectedReceivingFilesProvider.notifier).init(receiveState.files.values.map((f) => f.file).toList());},@@ -112,7 +95,8 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {selectState[file.file.id] ?? file.file.fileName,style: const TextStyle(fontSize: 16),maxLines: 1,- overflow: TextOverflow.ellipsis,+ overflow: TextOverflow.fade,+ softWrap: false,),Text('${!selectState.containsKey(file.file.id)@@ -131,13 +115,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {Row(mainAxisSize: MainAxisSize.min,children: [- TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ CustomIconButton(onPressed: selectState[file.file.id] == null ? null : () async {final result = await showDialog<String>(context: context,@@ -155,6 +133,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {Checkbox(value: selectState.containsKey(file.file.id),activeColor: Theme.of(context).colorScheme.onSurface,+ checkColor: Theme.of(context).colorScheme.surface,onChanged: (selected) {if (selected == true) {ref.read(selectedReceivingFilesProvider.notifier).select(file.file);diff --git a/lib/pages/receive_page.dart b/lib/pages/receive_page.dartindex d04adaf0..9de0ad08 100644--- a/lib/pages/receive_page.dart+++ b/lib/pages/receive_page.dart@@ -188,14 +188,15 @@ class _ReceivePageState extends ConsumerState<ReceivePage> {if (receiveState.status == SessionStatus.waiting && _message == null)Padding(padding: const EdgeInsets.only(bottom: 20),- child: TextButton(+ child: TextButton.icon(style: TextButton.styleFrom(foregroundColor: Theme.of(context).colorScheme.onSurface,),onPressed: () {context.push(() => const ReceiveOptionsPage());},- child: Text(t.receiveOptionsPage.title),+ icon: const Icon(Icons.settings),+ label: Text(t.receiveOptionsPage.title),),),if (receiveState.status == SessionStatus.canceledBySender)diff --git a/lib/pages/selected_files_page.dart b/lib/pages/selected_files_page.dartindex 8b1bd9f8..9b1f7a26 100644--- a/lib/pages/selected_files_page.dart+++ b/lib/pages/selected_files_page.dart@@ -67,7 +67,8 @@ class SelectedFilesPage extends ConsumerWidget {? '"${utf8.decode(file.bytes!).replaceAll('\n', ' ')}"': file.name,maxLines: 1,- overflow: TextOverflow.ellipsis,+ overflow: TextOverflow.fade,+ softWrap: false,),Text(file.size.asReadableFileSize, style: Theme.of(context).textTheme.caption),],diff --git a/lib/pages/tabs/send_tab.dart b/lib/pages/tabs/send_tab.dartindex 24d9756d..6365b116 100644--- a/lib/pages/tabs/send_tab.dart+++ b/lib/pages/tabs/send_tab.dart@@ -13,6 +13,7 @@ import 'package:localsend_app/provider/settings_provider.dart';import 'package:localsend_app/util/file_picker.dart';import 'package:localsend_app/util/file_size_helper.dart';import 'package:localsend_app/util/platform_check.dart';+import 'package:localsend_app/widget/custom_icon_button.dart';import 'package:localsend_app/widget/opacity_slideshow.dart';import 'package:localsend_app/widget/big_button.dart';import 'package:localsend_app/widget/dialogs/add_file_dialog.dart';@@ -156,7 +157,7 @@ class _SendTabState extends ConsumerState<SendTab> {child: Text(t.general.edit),),const SizedBox(width: 15),- ElevatedButton(+ ElevatedButton.icon(style: ElevatedButton.styleFrom(backgroundColor: Theme.of(context).colorScheme.primary,foregroundColor: Theme.of(context).colorScheme.onPrimary,@@ -171,7 +172,8 @@ class _SendTabState extends ConsumerState<SendTab> {options: addOptions,));},- child: Text(t.general.add),+ icon: const Icon(Icons.add),+ label: Text(t.general.add),),const SizedBox(width: 15),],@@ -193,13 +195,7 @@ class _SendTabState extends ConsumerState<SendTab> {duration: const Duration(seconds: 2),spinning: nearbyDevicesState.runningIps.isNotEmpty,reverse: true,- child: TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ child: CustomIconButton(onPressed: () => _scan(null),child: const Icon(Icons.sync),),@@ -207,13 +203,7 @@ class _SendTabState extends ConsumerState<SendTab> {),Tooltip(message: t.dialogs.addressInput.title,- child: TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ child: CustomIconButton(onPressed: () async {final files = ref.read(selectedSendingFilesProvider);if (files.isEmpty) {@@ -256,13 +246,7 @@ class _SendTabState extends ConsumerState<SendTab> {duration: const Duration(seconds: 2),spinning: nearbyDevicesState.runningIps.contains(ip),reverse: true,- child: TextButton(- style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- minimumSize: Size.zero,- shape: const CircleBorder(),- ),+ child: CustomIconButton(onPressed: () => _scan(ip),child: const Icon(Icons.sync),),@@ -309,7 +293,7 @@ class _SendTabState extends ConsumerState<SendTab> {}),const SizedBox(height: 20),OpacitySlideshow(- durationMillis: 7000,+ durationMillis: 6000,children: [Text(t.sendTab.help, style: const TextStyle(color: Colors.grey), textAlign: TextAlign.center),if (checkPlatformCanReceiveShareIntent())diff --git a/lib/theme.dart b/lib/theme.dartindex f00b614e..66587511 100644--- a/lib/theme.dart+++ b/lib/theme.dart@@ -44,7 +44,7 @@ ThemeData getTheme(Brightness brightness) {),textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(- padding: checkPlatformIsDesktop() ? const EdgeInsets.symmetric(horizontal: 8, vertical: 16) : const EdgeInsets.all(8),+ padding: checkPlatformIsDesktop() ? const EdgeInsets.all(16) : const EdgeInsets.symmetric(horizontal: 16, vertical: 8),),),);diff --git a/lib/widget/custom_icon_button.dart b/lib/widget/custom_icon_button.dartnew file mode 100644index 00000000..c8997655--- /dev/null+++ b/lib/widget/custom_icon_button.dart@@ -0,0 +1,28 @@+import 'package:flutter/material.dart';+import 'package:localsend_app/util/platform_check.dart';++class CustomIconButton extends StatelessWidget {+ final VoidCallback? onPressed;+ final Widget child;++ const CustomIconButton({+ required this.onPressed,+ required this.child,+ super.key,+ });++ @override+ Widget build(BuildContext context) {+ return TextButton(+ style: TextButton.styleFrom(+ foregroundColor: Theme.of(context).colorScheme.onSurface,+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,+ minimumSize: Size.zero,+ shape: const CircleBorder(),+ padding: checkPlatformIsDesktop() ? const EdgeInsets.symmetric(horizontal: 8, vertical: 16) : const EdgeInsets.all(8),+ ),+ onPressed: onPressed,+ child: child,+ );+ }+}