forked from cwtch.im/cwtch-ui
Remove Awful Flutter 3 Screen Transitions
This commit is contained in:
parent
f71bce5b71
commit
fc1f910486
|
@ -223,9 +223,9 @@ class FlwtchState extends State<Flwtch> with WindowListener {
|
||||||
Provider.of<AppState>(navKey.currentContext!, listen: false).selectedConversation = convoId;
|
Provider.of<AppState>(navKey.currentContext!, listen: false).selectedConversation = convoId;
|
||||||
|
|
||||||
Navigator.of(navKey.currentContext!).push(
|
Navigator.of(navKey.currentContext!).push(
|
||||||
MaterialPageRoute<void>(
|
PageRouteBuilder(
|
||||||
settings: RouteSettings(name: "conversations"),
|
settings: RouteSettings(name: "conversations"),
|
||||||
builder: (BuildContext buildcontext) {
|
pageBuilder: (c, a1, a2) {
|
||||||
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
|
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
|
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),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/hint.dart';
|
||||||
import 'package:flutter_local_notifications_linux/src/model/icon.dart';
|
import 'package:flutter_local_notifications_linux/src/model/icon.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import 'config.dart';
|
import 'config.dart';
|
||||||
|
@ -83,7 +82,6 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
late Future<void> Function(String, int) notificationSelectConvo;
|
late Future<void> Function(String, int) notificationSelectConvo;
|
||||||
late String linuxAssetsPath;
|
late String linuxAssetsPath;
|
||||||
|
|
||||||
|
|
||||||
// Cwtch can install in non flutter supported ways on linux, this code detects where the assets are on Linux
|
// Cwtch can install in non flutter supported ways on linux, this code detects where the assets are on Linux
|
||||||
Future<String> detectLinuxAssetsPath() async {
|
Future<String> detectLinuxAssetsPath() async {
|
||||||
var devStat = FileStat.stat("assets");
|
var devStat = FileStat.stat("assets");
|
||||||
|
@ -108,7 +106,6 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
scheduleMicrotask(() async {
|
scheduleMicrotask(() async {
|
||||||
|
|
||||||
if (Platform.isLinux) {
|
if (Platform.isLinux) {
|
||||||
linuxAssetsPath = await detectLinuxAssetsPath();
|
linuxAssetsPath = await detectLinuxAssetsPath();
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,8 +115,7 @@ class NixNotificationManager implements NotificationsManager {
|
||||||
final MacOSInitializationSettings initializationSettingsMacOS = MacOSInitializationSettings(defaultPresentSound: false);
|
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 =
|
final LinuxInitializationSettings initializationSettingsLinux = LinuxInitializationSettings(defaultActionName: 'Open notification', defaultIcon: linuxIcon, defaultSuppressSound: true);
|
||||||
LinuxInitializationSettings(defaultActionName: 'Open notification', defaultIcon: linuxIcon, defaultSuppressSound: true);
|
|
||||||
|
|
||||||
final InitializationSettings initializationSettings = InitializationSettings(android: null, iOS: null, macOS: initializationSettingsMacOS, linux: initializationSettingsLinux);
|
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 {
|
Future<void> notify(String message, String profile, int conversationId) async {
|
||||||
if (!globalAppState.focus) {
|
if (!globalAppState.focus) {
|
||||||
// Warning: Only use title field on Linux, body field will render links as clickable
|
// Warning: Only use title field on Linux, body field will render links as clickable
|
||||||
await flutterLocalNotificationsPlugin.show(0, message, '',
|
await flutterLocalNotificationsPlugin.show(
|
||||||
NotificationDetails(linux: LinuxNotificationDetails(suppressSound: true, category: LinuxNotificationCategory.imReceived(), icon: FilePathLinuxIcon(path.join(linuxAssetsPath, 'assets/knott.png')))),
|
0,
|
||||||
|
message,
|
||||||
|
'',
|
||||||
|
NotificationDetails(
|
||||||
|
linux: LinuxNotificationDetails(suppressSound: true, category: LinuxNotificationCategory.imReceived(), icon: FilePathLinuxIcon(path.join(linuxAssetsPath, 'assets/knott.png')))),
|
||||||
payload: jsonEncode(NotificationPayload(profile, conversationId)));
|
payload: jsonEncode(NotificationPayload(profile, conversationId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,11 +54,11 @@ void selectConversation(BuildContext context, int handle) {
|
||||||
|
|
||||||
void _pushMessageView(BuildContext context, int handle) {
|
void _pushMessageView(BuildContext context, int handle) {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
|
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
PageRouteBuilder(
|
||||||
builder: (BuildContext builderContext) {
|
settings: RouteSettings(name: "messages"),
|
||||||
// assert we have an actual profile...
|
pageBuilder: (builderContext, a1, a2) {
|
||||||
// We need to listen for updates to the profile in order to update things like invitation message bubbles.
|
|
||||||
var profile = Provider.of<FlwtchState>(builderContext).profs.getProfile(profileOnion)!;
|
var profile = Provider.of<FlwtchState>(builderContext).profs.getProfile(profileOnion)!;
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -68,6 +68,8 @@ void _pushMessageView(BuildContext context, int handle) {
|
||||||
builder: (context, child) => MessageView(),
|
builder: (context, child) => MessageView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -243,9 +245,10 @@ class _ContactsViewState extends State<ContactsView> {
|
||||||
// close modal
|
// close modal
|
||||||
Navigator.popUntil(context, (route) => route.settings.name == "conversations");
|
Navigator.popUntil(context, (route) => route.settings.name == "conversations");
|
||||||
|
|
||||||
// open add contact / create group pane
|
Navigator.of(context).push(
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
PageRouteBuilder(
|
||||||
builder: (BuildContext bcontext) {
|
settings: RouteSettings(name: "addcontact"),
|
||||||
|
pageBuilder: (builderContext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
||||||
|
@ -253,19 +256,26 @@ class _ContactsViewState extends State<ContactsView> {
|
||||||
child: AddContactView(newGroup: newGroup),
|
child: AddContactView(newGroup: newGroup),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushServers() {
|
void _pushServers() {
|
||||||
var profile = Provider.of<ProfileInfoState>(context);
|
var profile = Provider.of<ProfileInfoState>(context);
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
builder: (BuildContext context) {
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of<FlwtchState>(context))],
|
providers: [ChangeNotifierProvider(create: (context) => profile), Provider.value(value: Provider.of<FlwtchState>(context))],
|
||||||
child: ProfileServersView(),
|
child: ProfileServersView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _modalAddImportChoice() {
|
void _modalAddImportChoice() {
|
||||||
|
|
|
@ -205,19 +205,31 @@ class _MessageViewState extends State<MessageView> {
|
||||||
var contactInfoState = Provider.of<ContactInfoState>(context, listen: false);
|
var contactInfoState = Provider.of<ContactInfoState>(context, listen: false);
|
||||||
|
|
||||||
if (Provider.of<ContactInfoState>(context, listen: false).isGroup == true) {
|
if (Provider.of<ContactInfoState>(context, listen: false).isGroup == true) {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (BuildContext bcontext) {
|
Navigator.of(context).push(
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (builderContext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)],
|
providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)],
|
||||||
child: GroupSettingsView(),
|
child: GroupSettingsView(),
|
||||||
);
|
);
|
||||||
}));
|
},
|
||||||
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (BuildContext bcontext) {
|
Navigator.of(context).push(
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (builderContext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)],
|
providers: [ChangeNotifierProvider.value(value: profileInfoState), ChangeNotifierProvider.value(value: contactInfoState)],
|
||||||
child: PeerSettingsView(),
|
child: PeerSettingsView(),
|
||||||
);
|
);
|
||||||
}));
|
},
|
||||||
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,43 +130,58 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushGlobalSettings() {
|
void _pushGlobalSettings() {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
builder: (BuildContext context) {
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return Provider(
|
return Provider(
|
||||||
create: (_) => Provider.of<FlwtchState>(context, listen: false),
|
create: (_) => Provider.of<FlwtchState>(bcontext, listen: false),
|
||||||
child: GlobalSettingsView(),
|
child: GlobalSettingsView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushServers() {
|
void _pushServers() {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
|
PageRouteBuilder(
|
||||||
settings: RouteSettings(name: "servers"),
|
settings: RouteSettings(name: "servers"),
|
||||||
builder: (BuildContext context) {
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
||||||
child: ServersView(),
|
child: ServersView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushTorStatus() {
|
void _pushTorStatus() {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
builder: (BuildContext context) {
|
PageRouteBuilder(
|
||||||
|
settings: RouteSettings(name: "torconfig"),
|
||||||
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
providers: [Provider.value(value: Provider.of<FlwtchState>(context))],
|
||||||
child: TorStatusView(),
|
child: TorStatusView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushAddProfile(bcontext, {onion: ""}) {
|
void _pushAddProfile(bcontext, {onion: ""}) {
|
||||||
Navigator.popUntil(bcontext, (route) => route.isFirst);
|
Navigator.popUntil(bcontext, (route) => route.isFirst);
|
||||||
Navigator.of(bcontext).push(MaterialPageRoute<void>(
|
|
||||||
builder: (BuildContext context) {
|
Navigator.of(context).push(
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider<ProfileInfoState>(
|
ChangeNotifierProvider<ProfileInfoState>(
|
||||||
|
@ -176,7 +191,10 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
|
||||||
builder: (context, widget) => AddEditProfileView(key: Key('addprofile')),
|
builder: (context, widget) => AddEditProfileView(key: Key('addprofile')),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _modalAddImportProfiles() {
|
void _modalAddImportProfiles() {
|
||||||
|
|
|
@ -141,8 +141,9 @@ class _ServersView extends State<ServersView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushAddServer() {
|
void _pushAddServer() {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
builder: (BuildContext context) {
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider<ServerInfoState>(
|
ChangeNotifierProvider<ServerInfoState>(
|
||||||
|
@ -152,6 +153,9 @@ class _ServersView extends State<ServersView> {
|
||||||
child: AddEditServerView(),
|
child: AddEditServerView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,9 @@ class _ProfileRowState extends State<ProfileRow> {
|
||||||
|
|
||||||
void _pushContactList(ProfileInfoState profile, bool isLandscape) {
|
void _pushContactList(ProfileInfoState profile, bool isLandscape) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
PageRouteBuilder(
|
||||||
settings: RouteSettings(name: "conversations"),
|
settings: RouteSettings(name: "conversations"),
|
||||||
builder: (BuildContext buildcontext) {
|
pageBuilder: (c, a1, a2) {
|
||||||
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
|
return OrientationBuilder(builder: (orientationBuilderContext, orientation) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
|
providers: [ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)],
|
||||||
|
@ -98,14 +98,16 @@ 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}) {
|
void _pushEditProfile({onion: "", displayName: "", profileImage: "", encrypted: true}) {
|
||||||
Provider.of<ErrorHandler>(context, listen: false).reset();
|
Navigator.of(context).push(
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
PageRouteBuilder(
|
||||||
builder: (BuildContext bcontext) {
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
|
var profile = Provider.of<FlwtchState>(bcontext).profs.getProfile(onion)!;
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -116,6 +118,9 @@ class _ProfileRowState extends State<ProfileRow> {
|
||||||
builder: (context, widget) => AddEditProfileView(),
|
builder: (context, widget) => AddEditProfileView(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,19 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
|
||||||
)),
|
)),
|
||||||
]),
|
]),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
Navigator.of(context).push(
|
||||||
|
PageRouteBuilder(
|
||||||
settings: RouteSettings(name: "remoteserverview"),
|
settings: RouteSettings(name: "remoteserverview"),
|
||||||
builder: (BuildContext context) {
|
pageBuilder: (bcontext, a1, a2) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [Provider.value(value: profile), ChangeNotifierProvider(create: (context) => server), Provider.value(value: Provider.of<FlwtchState>(context))],
|
providers: [Provider.value(value: profile), ChangeNotifierProvider(create: (context) => server), Provider.value(value: Provider.of<FlwtchState>(context))],
|
||||||
child: RemoteServerView(),
|
child: RemoteServerView(),
|
||||||
);
|
);
|
||||||
}));
|
},
|
||||||
|
transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child),
|
||||||
|
transitionDuration: Duration(milliseconds: 200),
|
||||||
|
),
|
||||||
|
);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue