mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
feat: also show add files dialog when selecting device without files
This commit is contained in:
@@ -36,7 +36,7 @@ import 'package:refena_flutter/refena_flutter.dart';
|
||||
import 'package:routerino/routerino.dart';
|
||||
|
||||
const _horizontalPadding = 15.0;
|
||||
final _options = FilePickerOption.getOptionsForPlatform();
|
||||
final pickerOptions = FilePickerOption.getOptionsForPlatform();
|
||||
|
||||
class SendTab extends StatelessWidget {
|
||||
const SendTab();
|
||||
@@ -67,7 +67,7 @@ class SendTab extends StatelessWidget {
|
||||
outerVerticalPadding: 10,
|
||||
childPadding: 10,
|
||||
minChildWidth: buttonWidth,
|
||||
children: _options.map((option) {
|
||||
children: pickerOptions.map((option) {
|
||||
return BigButton(
|
||||
icon: option.icon,
|
||||
label: option.label,
|
||||
@@ -141,11 +141,11 @@ class SendTab extends StatelessWidget {
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
if (_options.length == 1) {
|
||||
if (pickerOptions.length == 1) {
|
||||
// open directly
|
||||
await ref.global.dispatchAsync(
|
||||
PickFileAction(
|
||||
option: _options.first,
|
||||
option: pickerOptions.first,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
@@ -153,7 +153,7 @@ class SendTab extends StatelessWidget {
|
||||
}
|
||||
await AddFileDialog.open(
|
||||
context: context,
|
||||
options: _options,
|
||||
options: pickerOptions,
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:localsend_app/model/persistence/favorite_device.dart';
|
||||
import 'package:localsend_app/model/send_mode.dart';
|
||||
import 'package:localsend_app/pages/progress_page.dart';
|
||||
import 'package:localsend_app/pages/send_page.dart';
|
||||
import 'package:localsend_app/pages/tabs/send_tab.dart';
|
||||
import 'package:localsend_app/pages/web_share_page.dart';
|
||||
import 'package:localsend_app/provider/favorites_provider.dart';
|
||||
import 'package:localsend_app/provider/local_ip_provider.dart';
|
||||
@@ -13,6 +14,7 @@ import 'package:localsend_app/provider/network/scan_facade.dart';
|
||||
import 'package:localsend_app/provider/network/send_provider.dart';
|
||||
import 'package:localsend_app/provider/selection/selected_sending_files_provider.dart';
|
||||
import 'package:localsend_app/provider/settings_provider.dart';
|
||||
import 'package:localsend_app/widget/dialogs/add_file_dialog.dart';
|
||||
import 'package:localsend_app/widget/dialogs/address_input_dialog.dart';
|
||||
import 'package:localsend_app/widget/dialogs/favorite_dialog.dart';
|
||||
import 'package:localsend_app/widget/dialogs/no_files_dialog.dart';
|
||||
@@ -118,8 +120,17 @@ final sendTabVmProvider = ViewProvider((ref) {
|
||||
}
|
||||
},
|
||||
onTapDevice: (context, device) async {
|
||||
if (selectedFiles.isEmpty) {
|
||||
await context.pushBottomSheet(() => const NoFilesDialog());
|
||||
var files = selectedFiles;
|
||||
if (files.isEmpty) {
|
||||
await AddFileDialog.open(
|
||||
context: context,
|
||||
options: pickerOptions,
|
||||
);
|
||||
}
|
||||
|
||||
files = ref.read(selectedSendingFilesProvider);
|
||||
|
||||
if (files.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +138,7 @@ final sendTabVmProvider = ViewProvider((ref) {
|
||||
.notifier(sendProvider)
|
||||
.startSession(
|
||||
target: device,
|
||||
files: selectedFiles,
|
||||
files: files,
|
||||
background: false,
|
||||
);
|
||||
},
|
||||
@@ -155,9 +166,18 @@ final sendTabVmProvider = ViewProvider((ref) {
|
||||
}
|
||||
}
|
||||
|
||||
final files = ref.read(selectedSendingFilesProvider);
|
||||
var files = ref.read(selectedSendingFilesProvider);
|
||||
|
||||
if (files.isEmpty) {
|
||||
await AddFileDialog.open(
|
||||
context: context,
|
||||
options: pickerOptions,
|
||||
);
|
||||
}
|
||||
|
||||
files = ref.read(selectedSendingFilesProvider);
|
||||
|
||||
if (files.isEmpty) {
|
||||
await context.pushBottomSheet(() => const NoFilesDialog());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:localsend_app/util/native/file_picker.dart';
|
||||
import 'package:localsend_app/util/native/platform_check.dart';
|
||||
import 'package:localsend_app/widget/big_button.dart';
|
||||
import 'package:localsend_app/widget/dialogs/custom_bottom_sheet.dart';
|
||||
import 'package:refena_flutter/addons.dart';
|
||||
import 'package:refena_flutter/refena_flutter.dart';
|
||||
import 'package:routerino/routerino.dart';
|
||||
|
||||
@@ -63,8 +64,9 @@ class AddFileDialog extends StatelessWidget {
|
||||
label: option.label,
|
||||
filled: true,
|
||||
onTap: () async {
|
||||
context.popUntilRoot();
|
||||
await context.global.dispatchAsync(PickFileAction(option: option, context: context));
|
||||
final ref = context.ref;
|
||||
await ref.global.dispatchAsync(PickFileAction(option: option, context: context));
|
||||
ref.global.dispatch(NavigateAction.popUntilRoot());
|
||||
},
|
||||
);
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user