Skip to content

Commit

Permalink
Fix share behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
EwuUwe committed Feb 27, 2024
1 parent 00fab76 commit 75c2e18
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
6 changes: 3 additions & 3 deletions lib/pages/SendPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ class _SendPageState extends State<SendPage> {
}
}

Route _createSendingRoute(List<String> files, {bool folder = false}) {
Route _createSendingRoute(List<String> files, {bool folder = false, bool causedByIntent = false}) {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
SendingPage(files: files, folder: folder),
SendingPage(files: files, folder: folder, causedByIntent: causedByIntent),
transitionDuration: const Duration(milliseconds: 0),
reverseTransitionDuration: const Duration(milliseconds: 380),
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
Expand Down Expand Up @@ -191,6 +191,6 @@ class _SendPageState extends State<SendPage> {
return;
}

Navigator.push(context, _createSendingRoute(paths));
Navigator.push(context, _createSendingRoute(paths, causedByIntent: true));
}
}
16 changes: 15 additions & 1 deletion lib/pages/SendingPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ import 'package:qr_flutter/qr_flutter.dart';
import '../gen/ffi.dart';

class SendingPage extends StatefulWidget {
const SendingPage({Key? key, required this.files, this.folder=false}) : super(key: key);
const SendingPage(
{Key? key,
required this.files,
this.folder = false,
this.causedByIntent = false})
: super(key: key);

final List<String> files;
final bool folder;
final bool causedByIntent;

@override
State<SendingPage> createState() => _SendingPageState();
Expand Down Expand Up @@ -81,6 +87,10 @@ class _SendingPageState extends State<SendingPage> {
shareProgress = e.getValue() / totalShareSize.toDouble();
});
case Events.Finished:
if (widget.causedByIntent) {
SystemNavigator.pop();
return;
}
if (context.mounted) {
Navigator.of(context).pop();
}
Expand Down Expand Up @@ -251,6 +261,10 @@ class _SendingPageState extends State<SendingPage> {
),
child: const Text('Leave'),
onPressed: () {
if (widget.causedByIntent) {
SystemNavigator.pop();
return;
}
Navigator.pop(context);
Navigator.pop(context);
},
Expand Down
10 changes: 8 additions & 2 deletions lib/utils/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ class Settings {
static addRecentFile(String value) async {
var recentFiles = await getRecentFiles();
recentFiles.add(value);
if(recentFiles.length>5){
recentFiles = recentFiles.getRange(recentFiles.length-6, recentFiles.length-1).toList();

if(recentFiles.contains(value)){
recentFiles.removeWhere((item) => item == value);
recentFiles.add(value);
}
if(recentFiles.length>10){
recentFiles = recentFiles.getRange(recentFiles.length-11, recentFiles.length-1).toList();
}
debugPrint(recentFiles.length.toString());

await _setField(recentFiles, _recentFiles);
}
Expand Down
65 changes: 19 additions & 46 deletions lib/widgets/RecentFiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _RecentFilesState extends State<RecentFiles>
width: double.infinity,
curve: Curves.easeInOutCirc,
height: recentCollapsed ? 80 : null,
constraints: const BoxConstraints(minHeight: 80, maxHeight: 400),
constraints: const BoxConstraints(minHeight: 80, maxHeight: 340),
duration: const Duration(milliseconds: 150),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 11),
Expand Down Expand Up @@ -86,54 +86,27 @@ class _RecentFilesState extends State<RecentFiles>
future: Settings.getRecentFiles(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(children: [
for (var i in snapshot.data!)
FilledButton.tonal(
style: ButtonStyle(
padding:
MaterialStateProperty.all(EdgeInsets.zero),
shape: MaterialStateProperty.all(
LinearBorder.none),
backgroundColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.surface),
elevation: MaterialStateProperty.all(1),
shadowColor: MaterialStateProperty.all(
Colors.transparent),
surfaceTintColor: MaterialStateProperty.all(
Theme.of(context).colorScheme.surfaceTint),
textStyle: MaterialStateProperty.all(
TextStyle(
color: Theme.of(context)
.colorScheme
.primary),
),
),
onPressed: () => {
Navigator.push(context, _createSendingRoute(i))
},
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 20),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(
i.split('/').last,
style:
const TextStyle(fontSize: 16),
)
]))),
)
]);
return SizedBox(
height: 222,
child: ListView.builder(
itemCount: snapshot.data?.length,
itemBuilder: (BuildContext context, int index) {
final file = snapshot.data![snapshot.data!.length - index - 1];
return ListTile(
onTap: () => {
Navigator.push(
context, _createSendingRoute(file))
},
title: Text(
file.split('/').last,
style: const TextStyle(fontSize: 16),
));
},
),
);
}
return const Placeholder();
}),
const Gap(8)
]),
]),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: iyox_wormhole
description: Mobile Client for the magic-wormhole protocol
publish_to: 'none'

version: 0.1.2+24
version: 0.1.3+25

environment:
sdk: '>=3.0.2 <4.0.0'
Expand Down

0 comments on commit 75c2e18

Please sign in to comment.