diff --git a/lib/main.dart b/lib/main.dart index f9a694ae..48f9d14b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -223,9 +223,9 @@ class FlwtchState extends State with WindowListener { Provider.of(navKey.currentContext!, listen: false).selectedConversation = convoId; Navigator.of(navKey.currentContext!).push( - MaterialPageRoute( + PageRouteBuilder( settings: RouteSettings(name: "conversations"), - builder: (BuildContext buildcontext) { + pageBuilder: (c, a1, a2) { return OrientationBuilder(builder: (orientationBuilderContext, orientation) { return MultiProvider( providers: [ChangeNotifierProvider.value(value: profile), ChangeNotifierProvider.value(value: profile.contactList)], @@ -236,6 +236,8 @@ class FlwtchState extends State with WindowListener { }); }); }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), ), ); } diff --git a/lib/notification_manager.dart b/lib/notification_manager.dart index 2761d457..248b3012 100644 --- a/lib/notification_manager.dart +++ b/lib/notification_manager.dart @@ -12,7 +12,6 @@ import 'package:flutter_local_notifications_linux/flutter_local_notifications_li import 'package:flutter_local_notifications_linux/src/model/hint.dart'; import 'package:flutter_local_notifications_linux/src/model/icon.dart'; - import 'package:path/path.dart' as path; import 'config.dart'; @@ -83,7 +82,6 @@ class NixNotificationManager implements NotificationsManager { late Future Function(String, int) notificationSelectConvo; late String linuxAssetsPath; - // Cwtch can install in non flutter supported ways on linux, this code detects where the assets are on Linux Future detectLinuxAssetsPath() async { var devStat = FileStat.stat("assets"); @@ -108,7 +106,6 @@ class NixNotificationManager implements NotificationsManager { flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); scheduleMicrotask(() async { - if (Platform.isLinux) { linuxAssetsPath = await detectLinuxAssetsPath(); } else { @@ -116,10 +113,9 @@ class NixNotificationManager implements NotificationsManager { } final MacOSInitializationSettings initializationSettingsMacOS = MacOSInitializationSettings(defaultPresentSound: false); - var linuxIcon = FilePathLinuxIcon( path.join(linuxAssetsPath, 'assets/knott.png')); + var linuxIcon = FilePathLinuxIcon(path.join(linuxAssetsPath, 'assets/knott.png')); - final LinuxInitializationSettings initializationSettingsLinux = - LinuxInitializationSettings(defaultActionName: 'Open notification', defaultIcon: linuxIcon, defaultSuppressSound: true); + final LinuxInitializationSettings initializationSettingsLinux = LinuxInitializationSettings(defaultActionName: 'Open notification', defaultIcon: linuxIcon, defaultSuppressSound: true); final InitializationSettings initializationSettings = InitializationSettings(android: null, iOS: null, macOS: initializationSettingsMacOS, linux: initializationSettingsLinux); @@ -136,8 +132,12 @@ class NixNotificationManager implements NotificationsManager { Future notify(String message, String profile, int conversationId) async { if (!globalAppState.focus) { // Warning: Only use title field on Linux, body field will render links as clickable - await flutterLocalNotificationsPlugin.show(0, message, '', - NotificationDetails(linux: LinuxNotificationDetails(suppressSound: true, category: LinuxNotificationCategory.imReceived(), icon: FilePathLinuxIcon(path.join(linuxAssetsPath, 'assets/knott.png')))), + await flutterLocalNotificationsPlugin.show( + 0, + message, + '', + NotificationDetails( + linux: LinuxNotificationDetails(suppressSound: true, category: LinuxNotificationCategory.imReceived(), icon: FilePathLinuxIcon(path.join(linuxAssetsPath, 'assets/knott.png')))), payload: jsonEncode(NotificationPayload(profile, conversationId))); } } diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index 8723cbad..d09ea57b 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -54,11 +54,11 @@ void selectConversation(BuildContext context, int handle) { void _pushMessageView(BuildContext context, int handle) { var profileOnion = Provider.of(context, listen: false).onion; + Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext builderContext) { - // assert we have an actual profile... - // We need to listen for updates to the profile in order to update things like invitation message bubbles. + PageRouteBuilder( + settings: RouteSettings(name: "messages"), + pageBuilder: (builderContext, a1, a2) { var profile = Provider.of(builderContext).profs.getProfile(profileOnion)!; return MultiProvider( providers: [ @@ -68,6 +68,8 @@ void _pushMessageView(BuildContext context, int handle) { builder: (context, child) => MessageView(), ); }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), ), ); } @@ -243,29 +245,37 @@ class _ContactsViewState extends State { // close modal Navigator.popUntil(context, (route) => route.settings.name == "conversations"); - // open add contact / create group pane - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext bcontext) { - return MultiProvider( - providers: [ - ChangeNotifierProvider.value(value: Provider.of(context)), - ], - child: AddContactView(newGroup: newGroup), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + settings: RouteSettings(name: "addcontact"), + pageBuilder: (builderContext, a1, a2) { + return MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: Provider.of(context)), + ], + child: AddContactView(newGroup: newGroup), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _pushServers() { var profile = Provider.of(context); - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) { - return MultiProvider( - providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of(context))], - child: ProfileServersView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (bcontext, a1, a2) { + return MultiProvider( + providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of(context))], + child: ProfileServersView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _modalAddImportChoice() { diff --git a/lib/views/groupsettingsview.dart b/lib/views/groupsettingsview.dart index 8acfda68..032ed800 100644 --- a/lib/views/groupsettingsview.dart +++ b/lib/views/groupsettingsview.dart @@ -91,22 +91,6 @@ class _GroupSettingsViewState extends State { tooltip: AppLocalizations.of(context)!.saveBtn, ) ]), - - // Address Copy Button - Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - height: 20, - ), - CwtchLabel(label: AppLocalizations.of(context)!.groupAddr), - SizedBox( - height: 20, - ), - CwtchTextField( - controller: ctrlrGroupAddr, - hintText: '', - validator: (value) {}, - ) - ]), Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 20, diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 75c43ba3..b2d616f5 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -205,19 +205,31 @@ class _MessageViewState extends State { var contactInfoState = Provider.of(context, listen: false); if (Provider.of(context, listen: false).isGroup == true) { - Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext bcontext) { - return MultiProvider( - providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)], - child: GroupSettingsView(), - ); - })); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (builderContext, a1, a2) { + return MultiProvider( + providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)], + child: GroupSettingsView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } else { - Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext bcontext) { - return MultiProvider( - providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)], - child: PeerSettingsView(), - ); - })); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (builderContext, a1, a2) { + return MultiProvider( + providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)], + child: PeerSettingsView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } } diff --git a/lib/views/profilemgrview.dart b/lib/views/profilemgrview.dart index 0212d72e..9324432d 100644 --- a/lib/views/profilemgrview.dart +++ b/lib/views/profilemgrview.dart @@ -130,53 +130,71 @@ class _ProfileMgrViewState extends State { } void _pushGlobalSettings() { - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) { - return Provider( - create: (_) => Provider.of(context, listen: false), - child: GlobalSettingsView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (bcontext, a1, a2) { + return Provider( + create: (_) => Provider.of(bcontext, listen: false), + child: GlobalSettingsView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _pushServers() { - Navigator.of(context).push(MaterialPageRoute( - settings: RouteSettings(name: "servers"), - builder: (BuildContext context) { - return MultiProvider( - providers: [Provider.value(value: Provider.of(context))], - child: ServersView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + settings: RouteSettings(name: "servers"), + pageBuilder: (bcontext, a1, a2) { + return MultiProvider( + providers: [Provider.value(value: Provider.of(context))], + child: ServersView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _pushTorStatus() { - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) { - return MultiProvider( - providers: [Provider.value(value: Provider.of(context))], - child: TorStatusView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + settings: RouteSettings(name: "torconfig"), + pageBuilder: (bcontext, a1, a2) { + return MultiProvider( + providers: [Provider.value(value: Provider.of(context))], + child: TorStatusView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _pushAddProfile(bcontext, {onion: ""}) { Navigator.popUntil(bcontext, (route) => route.isFirst); - Navigator.of(bcontext).push(MaterialPageRoute( - builder: (BuildContext context) { - return MultiProvider( - providers: [ - ChangeNotifierProvider( - create: (_) => ProfileInfoState(onion: onion), - ), - ], - builder: (context, widget) => AddEditProfileView(key: Key('addprofile')), - ); - }, - )); + + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (bcontext, a1, a2) { + return MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => ProfileInfoState(onion: onion), + ), + ], + builder: (context, widget) => AddEditProfileView(key: Key('addprofile')), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } void _modalAddImportProfiles() { diff --git a/lib/views/serversview.dart b/lib/views/serversview.dart index cb7608e6..d96d6603 100644 --- a/lib/views/serversview.dart +++ b/lib/views/serversview.dart @@ -141,17 +141,21 @@ class _ServersView extends State { } void _pushAddServer() { - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) { - return MultiProvider( - providers: [ - ChangeNotifierProvider( - create: (_) => ServerInfoState(onion: "", serverBundle: "", description: "", autoStart: true, running: false, isEncrypted: true), - ) - ], - child: AddEditServerView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (bcontext, a1, a2) { + return MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => ServerInfoState(onion: "", serverBundle: "", description: "", autoStart: true, running: false, isEncrypted: true), + ) + ], + child: AddEditServerView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } } diff --git a/lib/widgets/profilerow.dart b/lib/widgets/profilerow.dart index 9c2a576b..b017ec2a 100644 --- a/lib/widgets/profilerow.dart +++ b/lib/widgets/profilerow.dart @@ -85,9 +85,9 @@ class _ProfileRowState extends State { void _pushContactList(ProfileInfoState profile, bool isLandscape) { Navigator.of(context).push( - MaterialPageRoute( + PageRouteBuilder( settings: RouteSettings(name: "conversations"), - builder: (BuildContext buildcontext) { + pageBuilder: (c, a1, a2) { return OrientationBuilder(builder: (orientationBuilderContext, orientation) { return MultiProvider( providers: [ChangeNotifierProvider.value(value: profile), ChangeNotifierProvider.value(value: profile.contactList)], @@ -98,24 +98,29 @@ class _ProfileRowState extends State { }); }); }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), ), ); } void _pushEditProfile({onion: "", displayName: "", profileImage: "", encrypted: true}) { - Provider.of(context, listen: false).reset(); - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext bcontext) { - var profile = Provider.of(bcontext).profs.getProfile(onion)!; - return MultiProvider( - providers: [ - ChangeNotifierProvider.value( - value: profile, - ), - ], - builder: (context, widget) => AddEditProfileView(), - ); - }, - )); + Navigator.of(context).push( + PageRouteBuilder( + pageBuilder: (bcontext, a1, a2) { + var profile = Provider.of(bcontext).profs.getProfile(onion)!; + return MultiProvider( + providers: [ + ChangeNotifierProvider.value( + value: profile, + ), + ], + builder: (context, widget) => AddEditProfileView(), + ); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); } } diff --git a/lib/widgets/remoteserverrow.dart b/lib/widgets/remoteserverrow.dart index 90df461c..02252dfd 100644 --- a/lib/widgets/remoteserverrow.dart +++ b/lib/widgets/remoteserverrow.dart @@ -68,14 +68,19 @@ class _RemoteServerRowState extends State { )), ]), onTap: () { - Navigator.of(context).push(MaterialPageRoute( + Navigator.of(context).push( + PageRouteBuilder( settings: RouteSettings(name: "remoteserverview"), - builder: (BuildContext context) { + pageBuilder: (bcontext, a1, a2) { return MultiProvider( providers: [Provider.value(value: profile), ChangeNotifierProvider(create: (context) => server), Provider.value(value: Provider.of(context))], child: RemoteServerView(), ); - })); + }, + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: Duration(milliseconds: 200), + ), + ); })); }); }