Remove Awful Flutter 3 Screen Transitions
continuous-integration/drone/pr Build was killed Details

This commit is contained in:
Sarah Jamie Lewis 2022-06-21 14:58:09 -07:00
parent f71bce5b71
commit fc1f910486
8 changed files with 169 additions and 113 deletions

View File

@ -223,9 +223,9 @@ class FlwtchState extends State<Flwtch> with WindowListener {
Provider.of<AppState>(navKey.currentContext!, listen: false).selectedConversation = convoId;
Navigator.of(navKey.currentContext!).push(
MaterialPageRoute<void>(
PageRouteBuilder(
settings: RouteSettings(name: "conversations"),
builder: (BuildContext buildcontext) {
pageBuilder: (c, a1, a2) {
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
return MultiProvider(
providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
@ -236,6 +236,8 @@ class FlwtchState extends State<Flwtch> with WindowListener {
});
});
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}

View File

@ -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<void> 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<String> 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<void> 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)));
}
}

View File

@ -54,11 +54,11 @@ void selectConversation(BuildContext context, int handle) {
void _pushMessageView(BuildContext context, int handle) {
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
Navigator.of(context).push(
MaterialPageRoute<void>(
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<FlwtchState>(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<ContactsView> {
// close modal
Navigator.popUntil(context, (route) => route.settings.name == "conversations");
// open add contact / create group pane
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext bcontext) {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(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<ProfileInfoState>(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<ProfileInfoState>(context);
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {
return MultiProvider(
providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of<FlwtchState>(context))],
child: ProfileServersView(),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (bcontext, a1, a2) {
return MultiProvider(
providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of<FlwtchState>(context))],
child: ProfileServersView(),
);
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}
void _modalAddImportChoice() {

View File

@ -205,19 +205,31 @@ class _MessageViewState extends State<MessageView> {
var contactInfoState = Provider.of<ContactInfoState>(context, listen: false);
if (Provider.of<ContactInfoState>(context, listen: false).isGroup == true) {
Navigator.of(context).push(MaterialPageRoute<void>(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<void>(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),
),
);
}
}

View File

@ -130,53 +130,71 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
}
void _pushGlobalSettings() {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {
return Provider(
create: (_) => Provider.of<FlwtchState>(context, listen: false),
child: GlobalSettingsView(),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (bcontext, a1, a2) {
return Provider(
create: (_) => Provider.of<FlwtchState>(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<void>(
settings: RouteSettings(name: "servers"),
builder: (BuildContext context) {
return MultiProvider(
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
child: ServersView(),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
settings: RouteSettings(name: "servers"),
pageBuilder: (bcontext, a1, a2) {
return MultiProvider(
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
child: ServersView(),
);
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}
void _pushTorStatus() {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {
return MultiProvider(
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
child: TorStatusView(),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
settings: RouteSettings(name: "torconfig"),
pageBuilder: (bcontext, a1, a2) {
return MultiProvider(
providers: [Provider.value(value: Provider.of<FlwtchState>(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<void>(
builder: (BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider<ProfileInfoState>(
create: (_) => ProfileInfoState(onion: onion),
),
],
builder: (context, widget) => AddEditProfileView(key: Key('addprofile')),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (bcontext, a1, a2) {
return MultiProvider(
providers: [
ChangeNotifierProvider<ProfileInfoState>(
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() {

View File

@ -141,17 +141,21 @@ class _ServersView extends State<ServersView> {
}
void _pushAddServer() {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider<ServerInfoState>(
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<ServerInfoState>(
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),
),
);
}
}

View File

@ -85,9 +85,9 @@ class _ProfileRowState extends State<ProfileRow> {
void _pushContactList(ProfileInfoState profile, bool isLandscape) {
Navigator.of(context).push(
MaterialPageRoute<void>(
PageRouteBuilder(
settings: RouteSettings(name: "conversations"),
builder: (BuildContext buildcontext) {
pageBuilder: (c, a1, a2) {
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
return MultiProvider(
providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
@ -98,24 +98,29 @@ class _ProfileRowState extends State<ProfileRow> {
});
});
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}
void _pushEditProfile({onion: "", displayName: "", profileImage: "", encrypted: true}) {
Provider.of<ErrorHandler>(context, listen: false).reset();
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext bcontext) {
var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
return MultiProvider(
providers: [
ChangeNotifierProvider<ProfileInfoState>.value(
value: profile,
),
],
builder: (context, widget) => AddEditProfileView(),
);
},
));
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (bcontext, a1, a2) {
var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
return MultiProvider(
providers: [
ChangeNotifierProvider<ProfileInfoState>.value(
value: profile,
),
],
builder: (context, widget) => AddEditProfileView(),
);
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}
}

View File

@ -68,14 +68,19 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
)),
]),
onTap: () {
Navigator.of(context).push(MaterialPageRoute<void>(
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<FlwtchState>(context))],
child: RemoteServerView(),
);
}));
},
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
transitionDuration: Duration(milliseconds: 200),
),
);
}));
});
}