An open-source cross-platform alternative to AirDrop
feat: reorder possible options
Tien Do Nam9369232383b1
diff --git a/lib/pages/tabs/send_tab.dart b/lib/pages/tabs/send_tab.dartindex 9de4340f..729feb4b 100644--- a/lib/pages/tabs/send_tab.dart+++ b/lib/pages/tabs/send_tab.dart@@ -47,6 +47,7 @@ class SendTab extends ConsumerStatefulWidget {class _SendTabState extends ConsumerState<SendTab> {static const iosCall = MethodChannel('localsend.localsend_app/iosCall');+ final options = FilePickerOption.getOptionsForPlatform();@overridevoid initState() {@@ -82,13 +83,6 @@ class _SendTabState extends ConsumerState<SendTab> {final selectedFiles = ref.watch(selectedSendingFilesProvider);final networkInfo = ref.watch(networkStateProvider);final nearbyDevicesState = ref.watch(nearbyDevicesProvider);- final addOptions = [- FilePickerOption.file,- if (checkPlatformWithFolderSelect()) FilePickerOption.folder,- if (checkPlatformWithGallery()) FilePickerOption.media,- FilePickerOption.text,- if (checkPlatform([TargetPlatform.android])) FilePickerOption.app,- ];return ResponsiveListView(padding: EdgeInsets.zero,@@ -107,7 +101,7 @@ class _SendTabState extends ConsumerState<SendTab> {child: Row(children: [const SizedBox(width: 10),- ...addOptions.map((option) {+ ...options.map((option) {return Padding(padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5),child: BigButton(@@ -174,14 +168,14 @@ class _SendTabState extends ConsumerState<SendTab> {foregroundColor: Theme.of(context).colorScheme.onPrimary,),onPressed: () async {- if (addOptions.length == 1) {- await addOptions.first.select(context: context, ref: ref); // open directly+ if (options.length == 1) {+ await options.first.select(context: context, ref: ref); // open directlyreturn;}await AddFileDialog.open(context: context,parentRef: ref,- options: addOptions,+ options: options,);},icon: const Icon(Icons.add),diff --git a/lib/util/native/file_picker.dart b/lib/util/native/file_picker.dartindex 4a969cbd..730db478 100644--- a/lib/util/native/file_picker.dart+++ b/lib/util/native/file_picker.dart@@ -42,6 +42,28 @@ enum FilePickerOption {}}+ /// Returns the options for the current platform.+ static List<FilePickerOption> getOptionsForPlatform() {+ if (checkPlatform([TargetPlatform.iOS])) {+ // On iOS, picking from media is most common.+ // The file app is very limited.+ return [+ FilePickerOption.media,+ FilePickerOption.text,+ FilePickerOption.file,+ FilePickerOption.folder,+ ];+ }++ return [+ FilePickerOption.file,+ if (checkPlatformWithFolderSelect()) FilePickerOption.folder,+ if (checkPlatformWithGallery()) FilePickerOption.media,+ FilePickerOption.text,+ if (checkPlatform([TargetPlatform.android])) FilePickerOption.app,+ ];+ }+Future<void> select({required BuildContext context,required WidgetRef ref,