Remove context from push signature cuz it was not needed

This commit is contained in:
krawieck 2020-09-12 10:25:22 +02:00
parent bc3d67bb4e
commit 3c22966ea3
1 changed files with 9 additions and 9 deletions

View File

@ -13,8 +13,8 @@ Future<void> urlLauncher({
@required String url, @required String url,
@required String instanceUrl, @required String instanceUrl,
}) async { }) async {
push(Widget Function(BuildContext) builder) { push(Widget Function() builder) {
Navigator.of(context).push(MaterialPageRoute(builder: builder)); Navigator.of(context).push(MaterialPageRoute(builder: (c) => builder()));
} }
final instances = context.read<AccountsStore>().users.keys.toList(); final instances = context.read<AccountsStore>().users.keys.toList();
@ -23,13 +23,13 @@ Future<void> urlLauncher({
// CHECK IF LINK TO USER // CHECK IF LINK TO USER
if (chonks[1] == 'u') { if (chonks[1] == 'u') {
return push((_) => return push(
UserPage.fromName(instanceUrl: instanceUrl, username: chonks[2])); () => UserPage.fromName(instanceUrl: instanceUrl, username: chonks[2]));
} }
// CHECK IF LINK TO COMMUNITY // CHECK IF LINK TO COMMUNITY
if (chonks[1] == 'c') { if (chonks[1] == 'c') {
return push((_) => CommunityPage.fromName( return push(() => CommunityPage.fromName(
communityName: chonks[2], instanceUrl: instanceUrl)); communityName: chonks[2], instanceUrl: instanceUrl));
} }
@ -43,21 +43,21 @@ Future<void> urlLauncher({
if (matchedInstance != null && instances.any((e) => e == match.group(1))) { if (matchedInstance != null && instances.any((e) => e == match.group(1))) {
if (rest.isEmpty || rest == '/') { if (rest.isEmpty || rest == '/') {
return push((_) => InstancePage(instanceUrl: matchedInstance)); return push(() => InstancePage(instanceUrl: matchedInstance));
} }
final split = rest.split('/'); final split = rest.split('/');
switch (split[1]) { switch (split[1]) {
case 'c': case 'c':
return push((_) => CommunityPage.fromName( return push(() => CommunityPage.fromName(
communityName: split[2], instanceUrl: matchedInstance)); communityName: split[2], instanceUrl: matchedInstance));
case 'u': case 'u':
return push((_) => UserPage.fromName( return push(() => UserPage.fromName(
instanceUrl: matchedInstance, username: split[2])); instanceUrl: matchedInstance, username: split[2]));
case 'post': case 'post':
if (split.length == 3) { if (split.length == 3) {
return push((_) => FullPostPage( return push(() => FullPostPage(
id: int.parse(split[2]), instanceUrl: matchedInstance)); id: int.parse(split[2]), instanceUrl: matchedInstance));
} else if (split.length == 5) { } else if (split.length == 5) {
// TODO: post with focus on comment thread // TODO: post with focus on comment thread