Skip to content

Commit 26e4a64

Browse files
committed
UI changes: Receiver was moved from the bottom bar to the top of the home page (Closes #82)
1 parent 4a43e3a commit 26e4a64

File tree

7 files changed

+207
-101
lines changed

7 files changed

+207
-101
lines changed

lib/components/buttons.dart

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ class TransparentButton extends StatelessWidget {
121121
final Widget child;
122122
final Function() onClick;
123123
final TransparentButtonBackground background;
124+
final bool border;
124125

125-
const TransparentButton(this.child, this.onClick, this.background);
126+
const TransparentButton(this.child, this.onClick, this.background,
127+
{this.border = false});
126128

127129
@override
128130
Widget build(BuildContext context) {
@@ -145,8 +147,13 @@ class TransparentButton extends StatelessWidget {
145147
}
146148

147149
return Material(
150+
shape: RoundedRectangleBorder(
151+
side: BorderSide(
152+
color: border
153+
? Colors.deepPurple.shade100.withOpacity(0.16)
154+
: Colors.transparent),
155+
borderRadius: BorderRadius.circular(8)),
148156
color: Colors.transparent,
149-
borderRadius: BorderRadius.circular(8),
150157
child: InkWell(
151158
borderRadius: BorderRadius.circular(8),
152159
splashColor: splashColor,
File renamed without changes.

lib/dialogs/send.dart

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import 'dart:io';
2+
3+
import 'package:file_picker/file_picker.dart';
4+
import 'package:file_selector/file_selector.dart';
5+
import 'package:flutter/material.dart';
6+
import 'package:google_fonts/google_fonts.dart';
7+
import 'package:lucide_icons/lucide_icons.dart';
8+
9+
import '../components/buttons.dart';
10+
import '../logic/sharing_object.dart';
11+
import '../utils/helper.dart';
12+
import 'open_dialog.dart';
13+
import 'share_app.dart';
14+
import 'share_text.dart';
15+
16+
class SendDialog extends StatelessWidget {
17+
const SendDialog({Key? key}) : super(key: key);
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
return AlertDialog(
22+
elevation: 0,
23+
insetPadding: const EdgeInsets.all(24),
24+
title: Text(
25+
context.l.homeSend,
26+
style: GoogleFonts.getFont(context.l.fontComfortaa,
27+
fontWeight: FontWeight.w700),
28+
),
29+
scrollable: true,
30+
content: Column(
31+
children: [
32+
SizedBox(
33+
width: double.infinity,
34+
child: TransparentButton(
35+
Row(
36+
children: [
37+
const Icon(
38+
LucideIcons.file,
39+
size: 20,
40+
),
41+
const SizedBox(width: 8),
42+
Text(
43+
context.l.homeFiles,
44+
style: GoogleFonts.andika(fontSize: 18),
45+
),
46+
],
47+
),
48+
() async {
49+
if (Platform.isAndroid || Platform.isIOS) {
50+
final f = await FilePicker.platform.pickFiles();
51+
52+
if (f != null) {
53+
Navigator.of(context).pop(SharingObject(
54+
data: (f.paths.first)!,
55+
type: SharingObjectType.file,
56+
name: SharingObject.getSharingName(
57+
SharingObjectType.file, (f.paths.first)!)));
58+
}
59+
} else {
60+
final f = await openFile();
61+
if (f != null) {
62+
Navigator.of(context).pop(SharingObject(
63+
data: f.path,
64+
type: SharingObjectType.file,
65+
name: SharingObject.getSharingName(
66+
SharingObjectType.file, f.path),
67+
));
68+
}
69+
}
70+
},
71+
TransparentButtonBackground.def,
72+
border: true,
73+
)),
74+
const SizedBox(height: 12),
75+
SizedBox(
76+
width: double.infinity,
77+
child: TransparentButton(
78+
Row(
79+
children: [
80+
const Icon(
81+
LucideIcons.fileText,
82+
size: 20,
83+
),
84+
const SizedBox(width: 8),
85+
Text(
86+
context.l.homeSelectText,
87+
style: GoogleFonts.andika(fontSize: 18),
88+
),
89+
],
90+
),
91+
() async {
92+
final text = await openDialog(context, ShareTextDialog());
93+
if (text != null) {
94+
Navigator.of(context).pop(text);
95+
}
96+
},
97+
TransparentButtonBackground.def,
98+
border: true,
99+
)),
100+
if (Platform.isAndroid || Platform.isIOS) const SizedBox(height: 12),
101+
if (Platform.isAndroid)
102+
SizedBox(
103+
width: double.infinity,
104+
child: TransparentButton(
105+
Row(
106+
children: [
107+
const Icon(
108+
LucideIcons.binary,
109+
size: 20,
110+
),
111+
const SizedBox(width: 8),
112+
Text(
113+
context.l.homeSelectApp,
114+
style: GoogleFonts.andika(fontSize: 18),
115+
),
116+
],
117+
),
118+
() async {
119+
final f = await openDialog(context, ShareAppDialog());
120+
if (f != null) {
121+
Navigator.of(context).pop(f);
122+
}
123+
},
124+
TransparentButtonBackground.def,
125+
border: true,
126+
)),
127+
if (Platform.isIOS)
128+
SizedBox(
129+
width: double.infinity,
130+
child: TransparentButton(
131+
Row(
132+
children: [
133+
const Icon(
134+
LucideIcons.binary,
135+
size: 20,
136+
),
137+
const SizedBox(width: 8),
138+
Text(
139+
context.l.homeSelectGallery,
140+
style: GoogleFonts.andika(fontSize: 18),
141+
),
142+
],
143+
),
144+
() async {
145+
final f = await FilePicker.platform
146+
.pickFiles(type: FileType.media);
147+
148+
if (f != null) {
149+
Navigator.of(context).pop(SharingObject(
150+
data: (f.paths.first)!,
151+
type: SharingObjectType.file,
152+
name: SharingObject.getSharingName(
153+
SharingObjectType.file, (f.names.first)!)));
154+
}
155+
},
156+
TransparentButtonBackground.def,
157+
border: true,
158+
)),
159+
],
160+
),
161+
actions: [
162+
DialogTextButton(context.l.generalClose, () {
163+
Navigator.of(context).pop();
164+
}),
165+
const SizedBox(width: 4),
166+
],
167+
);
168+
}
169+
}

lib/screens/home.dart

+21-94
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import 'dart:io' show Platform;
21
import 'dart:ui';
32

4-
import 'package:bootstrap_icons/bootstrap_icons.dart';
5-
import 'package:file_picker/file_picker.dart';
6-
import 'package:file_selector/file_selector.dart';
73
import 'package:flutter/material.dart';
84
import 'package:flutter/rendering.dart';
95
import 'package:google_fonts/google_fonts.dart';
@@ -16,9 +12,8 @@ import '../components/logo.dart';
1612
import '../components/page_router.dart';
1713
import '../conf.dart';
1814
import '../dialogs/open_dialog.dart';
19-
import '../dialogs/receiver.dart';
20-
import '../dialogs/share_app.dart';
21-
import '../dialogs/share_text.dart';
15+
import '../dialogs/receive.dart';
16+
import '../dialogs/send.dart';
2217
import '../logic/sharing_object.dart';
2318
import '../logic/theme.dart';
2419
import '../utils/helper.dart';
@@ -53,7 +48,8 @@ class _HomeScreenState extends State<HomeScreen> {
5348

5449
await saveLatest();
5550

56-
SharikRouter.navigateTo(_globalKey, Screens.sharing, RouteDirection.right, file);
51+
SharikRouter.navigateTo(
52+
_globalKey, Screens.sharing, RouteDirection.right, file);
5753
}
5854

5955
@override
@@ -134,19 +130,10 @@ class _HomeScreenState extends State<HomeScreen> {
134130
child: Icon(LucideIcons.helpCircle,
135131
color: Colors.deepPurple.shade700, size: 20)),
136132
() => SharikRouter.navigateTo(
137-
_globalKey, Screens.intro, RouteDirection.left),
133+
_globalKey, Screens.intro, RouteDirection.left),
138134
TransparentButtonBackground.purpleLight,
139135
),
140136
const SizedBox(width: 2),
141-
TransparentButton(
142-
SizedBox(
143-
height: 20,
144-
width: 20,
145-
child: Icon(LucideIcons.download,
146-
color: Colors.deepPurple.shade700, size: 20)), () {
147-
openDialog(context, ReceiverDialog());
148-
}, TransparentButtonBackground.purpleLight),
149-
const SizedBox(width: 2),
150137
TransparentButton(
151138
SizedBox(
152139
height: 20,
@@ -164,8 +151,8 @@ _globalKey, Screens.intro, RouteDirection.left),
164151
color: Colors.deepPurple.shade700,
165152
),
166153
),
167-
() => SharikRouter.navigateTo( _globalKey,
168-
Screens.about, RouteDirection.right),
154+
() => SharikRouter.navigateTo(
155+
_globalKey, Screens.about, RouteDirection.right),
169156
TransparentButtonBackground.purpleLight),
170157
],
171158
),
@@ -225,86 +212,26 @@ _globalKey, Screens.intro, RouteDirection.left),
225212
PrimaryButton(
226213
height: 110,
227214
onClick: () async {
228-
if (Platform.isAndroid || Platform.isIOS) {
229-
final f = await FilePicker.platform.pickFiles();
230-
231-
if (f != null) {
232-
shareFile(SharingObject(
233-
data: (f.paths.first)!,
234-
type: SharingObjectType.file,
235-
name: SharingObject.getSharingName(
236-
SharingObjectType.file, (f.paths.first)!)));
237-
}
238-
} else {
239-
final f = await openFile();
240-
if (f != null) {
241-
shareFile(SharingObject(
242-
data: f.path,
243-
type: SharingObjectType.file,
244-
name: SharingObject.getSharingName(
245-
SharingObjectType.file, f.path),
246-
));
247-
}
215+
final obj = await openDialog(context, const SendDialog());
216+
if (obj != null) {
217+
shareFile(obj);
248218
}
249219
},
250-
text: c.l.homeSelectFile,
220+
text: c.l.homeSend,
251221
secondaryIcon: Icon(
252-
BootstrapIcons.file_earmark,
253-
size: 48,
254-
color: Colors.deepPurple.shade200.withOpacity(0.9),
222+
LucideIcons.upload,
223+
size: 42,
224+
color: Colors.deepPurple.shade200.withOpacity(0.8),
255225
),
256226
),
257227
const SizedBox(height: 12),
258-
Row(
259-
children: [
260-
if (Platform.isAndroid)
261-
Expanded(
262-
child: PrimaryButton(
263-
height: 50,
264-
onClick: () async {
265-
final f = await openDialog(context, ShareAppDialog());
266-
if (f != null) {
267-
shareFile(f);
268-
}
269-
},
270-
text: c.l.homeSelectApp,
271-
),
272-
),
273-
if (Platform.isIOS)
274-
Expanded(
275-
child: PrimaryButton(
276-
height: 50,
277-
onClick: () async {
278-
279-
final f = await FilePicker.platform
280-
.pickFiles(type: FileType.media);
281-
282-
if (f != null) {
283-
shareFile(SharingObject(
284-
data: (f.paths.first)!,
285-
type: SharingObjectType.file,
286-
name: SharingObject.getSharingName(
287-
SharingObjectType.file, (f.names.first)!)));
288-
}
289-
},
290-
text: c.l.homeSelectGallery,
291-
),
292-
),
293-
if (Platform.isIOS || Platform.isAndroid) const SizedBox(width: 12),
294-
Expanded(
295-
child: PrimaryButton(
296-
height: 50,
297-
onClick: () async {
298-
final f = await openDialog(context, ShareTextDialog());
299-
if (f != null) {
300-
shareFile(f);
301-
}
302-
},
303-
text: c.l.homeSelectText,
304-
),
305-
),
306-
],
307-
),
228+
PrimaryButton(
229+
height: 60,
230+
onClick: () async {
231+
openDialog(context, ReceiverDialog());
232+
},
233+
text: c.l.homeReceive,
234+
)
308235
],
309236
);
310237
}

locales/en.arb

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@
5959

6060

6161
"fontAndika": "Andika",
62-
"fontComfortaa": "Comfortaa"
62+
"fontComfortaa": "Comfortaa",
63+
64+
"homeSend": "Send",
65+
"homeReceive": "Receive",
66+
"homeFiles": "Files"
6367
}

pubspec.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ packages:
210210
name: file_picker
211211
url: "https://pub.dartlang.org"
212212
source: hosted
213-
version: "3.0.3"
213+
version: "3.0.4"
214214
file_selector:
215215
dependency: "direct main"
216216
description:
@@ -657,7 +657,7 @@ packages:
657657
name: source_helper
658658
url: "https://pub.dartlang.org"
659659
source: hosted
660-
version: "1.2.0"
660+
version: "1.2.1"
661661
source_span:
662662
dependency: transitive
663663
description:

0 commit comments

Comments
 (0)