diff --git a/lib/main.dart b/lib/main.dart index 4f41abd..af06c5a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:dynamic_color/dynamic_color.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_displaymode/flutter_displaymode.dart'; @@ -71,6 +72,10 @@ class WormholeAppState extends State with WidgetsBindingObserver { systemNavigationBarColor: Colors.transparent, ); SystemChrome.setSystemUIOverlayStyle(overlayStyle); + + // Clear Cache + await FilePicker.platform.clearTemporaryFiles(); + await Settings.setRecentFiles([]); } @override @@ -95,9 +100,9 @@ class WormholeAppState extends State with WidgetsBindingObserver { } @override - void dispose() { - super.dispose(); + Future dispose() async { WidgetsBinding.instance.removeObserver(this); + super.dispose(); } @override @@ -119,7 +124,7 @@ class WormholeAppState extends State with WidgetsBindingObserver { setState(() { if (value == ThemeMode.system) { themeMode = - brightness == Brightness.dark ? ThemeMode.dark : ThemeMode.light; + brightness == Brightness.dark ? ThemeMode.dark : ThemeMode.light; } else { themeMode = value; } @@ -135,8 +140,12 @@ class WormholeAppState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { return DynamicColorBuilder(builder: (lightColorScheme, darkColorScheme) { - var lightScheme = lightColorScheme ?? ColorScheme.fromSeed(seedColor:Colors.indigo, brightness: Brightness.light); - var darkScheme = darkColorScheme ?? ColorScheme.fromSeed(seedColor:Colors.indigo, brightness: Brightness.dark); + var lightScheme = lightColorScheme ?? + ColorScheme.fromSeed( + seedColor: Colors.indigo, brightness: Brightness.light); + var darkScheme = darkColorScheme ?? + ColorScheme.fromSeed( + seedColor: Colors.indigo, brightness: Brightness.dark); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( statusBarColor: themeMode == ThemeMode.dark ? darkScheme.background diff --git a/lib/pages/router.dart b/lib/pages/router.dart index 0a3f45d..820462f 100644 --- a/lib/pages/router.dart +++ b/lib/pages/router.dart @@ -13,9 +13,6 @@ class BasePage extends StatefulWidget { class _BasePageState extends State { final GlobalKey scaffoldKey = GlobalKey(); - final pageController = PageController( - initialPage: 0, - ); int selectedPageIndex = 0; @@ -43,9 +40,6 @@ class _BasePageState extends State { setState(() { selectedPageIndex = index; }); - pageController.animateToPage(index, - duration: const Duration(milliseconds: 2000), - curve: Curves.ease); }, destinations: const [ NavigationDestination( diff --git a/lib/pages/sending_page.dart b/lib/pages/sending_page.dart index 8714176..205023c 100644 --- a/lib/pages/sending_page.dart +++ b/lib/pages/sending_page.dart @@ -58,7 +58,9 @@ class _SendingPageState extends State { } for (var file in widget.files) { - await Settings.addRecentFile(file); + setState(() { + Settings.addRecentFile(file); + }); } stream.listen((e) { @@ -181,65 +183,63 @@ class _SendingPageState extends State { return Center( child: codeText == '' ? Padding( - padding: const EdgeInsets.all(10), + padding: const EdgeInsets.all(14), child: LinearProgressIndicator( value: shareProgress, minHeight: 10, borderRadius: BorderRadius.circular(18), )) - : Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Card( - margin: const EdgeInsets.all(20), - child: Padding( - padding: const EdgeInsets.all(15), - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: QrImageView( - data: "wormhole-transfer:$codeText", - backgroundColor: Colors.white), - ))), - const Gap(10), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - child: InkWell( - borderRadius: BorderRadius.circular(20), - onTap: () { - Clipboard.setData(ClipboardData(text: codeText)); - ScaffoldMessenger.of(context) - .showSnackBar(const SnackBar( - content: Text("Copied code to clipboard"), - )); - }, - child: Padding( - padding: const EdgeInsets.fromLTRB(15, 15, 15, 15), - child: Text( - codeText, - style: TextStyle( - height: 1.6, - fontSize: Theme.of(context) - .textTheme - .titleMedium! - .fontSize! + - 1.5, - fontWeight: Theme.of(context) - .textTheme - .titleMedium - ?.fontWeight), - ) - ), - ), + : Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Card( + child: Padding( + padding: const EdgeInsets.all(15), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: QrImageView( + data: "wormhole-transfer:$codeText", + backgroundColor: Colors.white), + ))), + const Gap(10), + Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(26), ), - ]), - ), - ], - ), + child: InkWell( + borderRadius: BorderRadius.circular(26), + onTap: () { + Clipboard.setData(ClipboardData(text: codeText)); + ScaffoldMessenger.of(context) + .showSnackBar(const SnackBar( + content: Text("Copied code to clipboard"), + )); + }, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 13, vertical: 9), + child: Text( + codeText, + textAlign: TextAlign.center, + style: TextStyle( + height: 1.6, + fontSize: Theme.of(context) + .textTheme + .titleMedium! + .fontSize! + + 1.5, + fontWeight: Theme.of(context) + .textTheme + .titleMedium + ?.fontWeight), + )), + ), + ), + ], + ), + ), ); } diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index de862cb..ebc46ea 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -22,8 +22,8 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: Column( + return ListView( + children:[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( @@ -249,6 +249,6 @@ class _SettingsPageState extends State { ); }), ], - )); + )]); } } diff --git a/lib/widgets/recent_files.dart b/lib/widgets/recent_files.dart index 43c9c02..321416c 100644 --- a/lib/widgets/recent_files.dart +++ b/lib/widgets/recent_files.dart @@ -13,7 +13,7 @@ class RecentFiles extends StatefulWidget { class _RecentFilesState extends State with SingleTickerProviderStateMixin { - bool recentCollapsed = false; + bool recentCollapsed = true; late final AnimationController _controller; @override @@ -60,7 +60,7 @@ class _RecentFilesState extends State ), const Spacer(), RotationTransition( - turns: Tween(begin: 0.0, end: 1.0).animate(_controller), + turns: Tween(begin: 1.0, end: 0.0).animate(_controller), child: IconButton.filledTonal( iconSize: 23, padding: const EdgeInsets.all(0), @@ -69,9 +69,9 @@ class _RecentFilesState extends State onPressed: () => { setState(() { if (recentCollapsed) { - _controller.reverse(from: 0.5); - } else { _controller.forward(from: 0.0); + } else { + _controller.reverse(from: 0.5); } recentCollapsed = !recentCollapsed; })