Add support for a number of pages
Linking to those pages is now supported: * `CommunityPage` (https://lemmy.instance/c/community_name) * `UserPage` (https://lemmy.instance/u/username) * `FullPostPage` (https://lemmy.instance/)
This commit is contained in:
parent
83f4f61952
commit
704daca4c7
|
@ -18,6 +18,15 @@ class UserPage extends HookWidget {
|
||||||
.getUserDetails(
|
.getUserDetails(
|
||||||
userId: userId, savedOnly: true, sort: SortType.active)
|
userId: userId, savedOnly: true, sort: SortType.active)
|
||||||
.then((res) => res.user);
|
.then((res) => res.user);
|
||||||
|
UserPage.fromName({@required this.instanceUrl, @required username})
|
||||||
|
: assert(instanceUrl != null),
|
||||||
|
assert(username != null),
|
||||||
|
userId = null,
|
||||||
|
_userView = LemmyApi(instanceUrl)
|
||||||
|
.v1
|
||||||
|
.getUserDetails(
|
||||||
|
username: username, savedOnly: true, sort: SortType.active)
|
||||||
|
.then((res) => res.user);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lemmur/pages/community.dart';
|
||||||
|
import 'package:lemmur/pages/full_post.dart';
|
||||||
|
import 'package:lemmur/pages/user.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart' as ul;
|
import 'package:url_launcher/url_launcher.dart' as ul;
|
||||||
|
|
||||||
|
@ -21,35 +24,52 @@ Future<void> urlLauncher(BuildContext c, String url) async {
|
||||||
final instanceRegex = RegExp(r'^(?:https?:\/\/)?([\w\.-]+)(.+)$');
|
final instanceRegex = RegExp(r'^(?:https?:\/\/)?([\w\.-]+)(.+)$');
|
||||||
final match = instanceRegex.firstMatch(url);
|
final match = instanceRegex.firstMatch(url);
|
||||||
|
|
||||||
final matchedDomain = match.group(1);
|
final matchedInstance = match.group(1);
|
||||||
final rest = match.group(2);
|
final rest = match.group(2);
|
||||||
|
|
||||||
print('matched domain: $matchedDomain, rest: $rest');
|
print('matched domain: $matchedInstance, rest: $rest');
|
||||||
print(rest.length);
|
print(rest.length);
|
||||||
|
|
||||||
if (instances.any((e) => e == match.group(1))) {
|
if (instances.any((e) => e == match.group(1))) {
|
||||||
switch (rest.split('/')[1]) {
|
push(Widget Function(BuildContext) builder) {
|
||||||
|
Navigator.of(c).push(MaterialPageRoute(builder: builder));
|
||||||
|
}
|
||||||
|
|
||||||
|
final split = rest.split('/');
|
||||||
|
switch (split[1]) {
|
||||||
case 'c':
|
case 'c':
|
||||||
print('comunity');
|
return push((_) => CommunityPage.fromName(
|
||||||
return;
|
communityName: split[2], instanceUrl: matchedInstance));
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
print('user');
|
return push((_) => UserPage.fromName(
|
||||||
return;
|
instanceUrl: matchedInstance, username: split[2]));
|
||||||
|
|
||||||
case 'post':
|
case 'post':
|
||||||
print('post');
|
return push((_) => FullPostPage(
|
||||||
return;
|
id: int.parse(split[2]), instanceUrl: matchedInstance));
|
||||||
|
|
||||||
case 'pictrs':
|
case 'pictrs':
|
||||||
print('pictures');
|
// TODO: put here push to media view
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'communities':
|
case 'communities':
|
||||||
print('communities');
|
// TODO: put here push to communities page
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'modlog':
|
case 'modlog':
|
||||||
|
// TODO: put here push to modlog
|
||||||
print('modlog');
|
print('modlog');
|
||||||
return;
|
return;
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
|
// TODO: put here push to inbox
|
||||||
print('inbox');
|
print('inbox');
|
||||||
return;
|
return;
|
||||||
|
case 'search':
|
||||||
|
// TODO: *maybe* put here push to search. we'll see
|
||||||
|
// how much web version differs form the app
|
||||||
|
print('search');
|
||||||
|
return;
|
||||||
case 'create_post':
|
case 'create_post':
|
||||||
case 'create_community':
|
case 'create_community':
|
||||||
case 'sponsors':
|
case 'sponsors':
|
||||||
|
|
Loading…
Reference in New Issue