Skip to content

An open-source cross-platform alternative to AirDrop

feat: show dialog on desktop

Tien Do Namd6b357725634
diff --git a/assets/i18n/strings.i18n.json b/assets/i18n/strings.i18n.json
index 913f7058..76b456f9 100644
--- a/assets/i18n/strings.i18n.json
+++ b/assets/i18n/strings.i18n.json
@@ -210,6 +210,9 @@
]
},
"dialogs": {
+ "addFile": {
+ "content": "What do you want to add?"
+ },
"addressInput": {
"title": "Enter address",
"hashtag": "Hashtag",
diff --git a/assets/i18n/strings_de.i18n.json b/assets/i18n/strings_de.i18n.json
index 3835a932..6ed896ee 100644
--- a/assets/i18n/strings_de.i18n.json
+++ b/assets/i18n/strings_de.i18n.json
@@ -142,6 +142,9 @@
"@info": "Uses English version"
},
"dialogs": {
+ "addFile": {
+ "content": "Was möchtest du zum Senden hinzufügen?"
+ },
"addressInput": {
"title": "Adresse eingeben",
"hashtag": "Hashtag",
diff --git a/lib/pages/tabs/send_tab.dart b/lib/pages/tabs/send_tab.dart
index 6365b116..3d96a0a6 100644
--- a/lib/pages/tabs/send_tab.dart
+++ b/lib/pages/tabs/send_tab.dart
@@ -91,6 +91,7 @@ class _SendTabState extends ConsumerState<SendTab> {
: BigButton(
icon: option.icon,
label: option.label,
+ filled: false,
onTap: () => option.select(
context: context,
ref: ref,
@@ -167,10 +168,11 @@ class _SendTabState extends ConsumerState<SendTab> {
addOptions.first.select(context: context, ref: ref); // open directly
return;
}
- context.pushBottomSheet(() => AddFileDialog(
- parentRef: ref,
- options: addOptions,
- ));
+ AddFileDialog.open(
+ context: context,
+ parentRef: ref,
+ options: addOptions,
+ );
},
icon: const Icon(Icons.add),
label: Text(t.general.add),
diff --git a/lib/widget/big_button.dart b/lib/widget/big_button.dart
index d116e3a5..1acbf1ea 100644
--- a/lib/widget/big_button.dart
+++ b/lib/widget/big_button.dart
@@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
class BigButton extends StatelessWidget {
final IconData icon;
final String label;
+ final bool filled;
final VoidCallback onTap;
const BigButton({
required this.icon,
required this.label,
+ required this.filled,
required this.onTap,
});
@@ -15,6 +17,8 @@ class BigButton extends StatelessWidget {
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
+ backgroundColor: filled ? Theme.of(context).colorScheme.primary : null,
+ foregroundColor: filled ? Theme.of(context).colorScheme.onPrimary : null,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
diff --git a/lib/widget/dialogs/add_file_dialog.dart b/lib/widget/dialogs/add_file_dialog.dart
index 312e4d98..5ba7e52e 100644
--- a/lib/widget/dialogs/add_file_dialog.dart
+++ b/lib/widget/dialogs/add_file_dialog.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:localsend_app/gen/strings.g.dart';
import 'package:localsend_app/util/file_picker.dart';
+import 'package:localsend_app/util/platform_check.dart';
import 'package:localsend_app/widget/big_button.dart';
import 'package:localsend_app/widget/dialogs/custom_bottom_sheet.dart';
import 'package:routerino/routerino.dart';
@@ -12,45 +13,76 @@ class AddFileDialog extends StatelessWidget {
const AddFileDialog({required this.parentRef, required this.options});
+ static void open({required BuildContext context, required WidgetRef parentRef, required List<FilePickerOption> options}) {
+ if (checkPlatformIsDesktop()) {
+ showDialog(
+ context: context,
+ builder: (_) => AlertDialog(
+ title: Text(t.general.add),
+ content: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.dialogs.addFile.content),
+ const SizedBox(height: 20),
+ AddFileDialog(parentRef: parentRef, options: options),
+ ],
+ ),
+ actions: [
+ TextButton(
+ onPressed: () {
+ context.pop();
+ },
+ child: Text(t.general.close),
+ )
+ ],
+ ),
+ );
+ } else {
+ context.pushBottomSheet(() => CustomBottomSheet(
+ title: t.general.add,
+ description: t.dialogs.addFile.content,
+ child: AddFileDialog(parentRef: parentRef, options: options),
+ ));
+ }
+ }
+
@override
Widget build(BuildContext context) {
- return CustomBottomSheet(
- title: t.general.add,
- description: null,
- child: Column(
- children: [
- const SizedBox(height: 20),
- IntrinsicHeight(
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- ...List.generate(3, (index) {
- final option = index < options.length ? options[index] : null;
- return [
- Expanded(
- child: option == null
- ? Container()
- : BigButton(
- icon: option.icon,
- label: option.label,
- onTap: () {
- context.popUntilRoot();
- option.select(
- context: context,
- ref: parentRef,
- );
- },
- ),
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ ...List.generate(3, (index) {
+ final option = index < options.length ? options[index] : null;
+ return [
+ Expanded(
+ child: option == null
+ ? Container()
+ : BigButton(
+ icon: option.icon,
+ label: option.label,
+ filled: true,
+ onTap: () {
+ context.popUntilRoot();
+ option.select(
+ context: context,
+ ref: parentRef,
+ );
+ },
),
- const SizedBox(width: 15),
- ];
- }).expand((e) => e).toList()
- ..removeLast(),
- ],
- ),
+ ),
+ const SizedBox(width: 15),
+ ];
+ }).expand((e) => e).toList()
+ ..removeLast(),
+ ],
),
- ],
- ),
+ ),
+ ],
);
}
}