Change `urlLanucher` signature to include `instanceUrl`
This commit is contained in:
parent
28bbe5b06f
commit
77d54016f3
|
@ -31,7 +31,10 @@ class CommunitiesListPage extends StatelessWidget {
|
||||||
subtitle: communities[i].description != null
|
subtitle: communities[i].description != null
|
||||||
? Opacity(
|
? Opacity(
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
child: MarkdownText(communities[i].description),
|
child: MarkdownText(
|
||||||
|
communities[i].description,
|
||||||
|
instanceUrl: communities[i].instanceUrl,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
onTap: () => goToCommunity.byId(
|
onTap: () => goToCommunity.byId(
|
||||||
|
|
|
@ -433,7 +433,8 @@ class _AboutTab extends StatelessWidget {
|
||||||
if (community.description != null) ...[
|
if (community.description != null) ...[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
child: MarkdownText(community.description),
|
child: MarkdownText(community.description,
|
||||||
|
instanceUrl: community.instanceUrl),
|
||||||
),
|
),
|
||||||
_Divider(),
|
_Divider(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -208,7 +208,9 @@ class InstancePage extends HookWidget {
|
||||||
Center(child: Text('comments go here')),
|
Center(child: Text('comments go here')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
_AboutTab(site, communitiesFuture: communitiesFuture),
|
_AboutTab(site,
|
||||||
|
communitiesFuture: communitiesFuture,
|
||||||
|
instanceUrl: instanceUrl),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -241,9 +243,12 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||||
class _AboutTab extends HookWidget {
|
class _AboutTab extends HookWidget {
|
||||||
final FullSiteView site;
|
final FullSiteView site;
|
||||||
final Future<List<CommunityView>> communitiesFuture;
|
final Future<List<CommunityView>> communitiesFuture;
|
||||||
|
final String instanceUrl;
|
||||||
|
|
||||||
const _AboutTab(this.site, {@required this.communitiesFuture})
|
const _AboutTab(this.site,
|
||||||
: assert(communitiesFuture != null);
|
{@required this.communitiesFuture, @required this.instanceUrl})
|
||||||
|
: assert(communitiesFuture != null),
|
||||||
|
assert(instanceUrl != null);
|
||||||
|
|
||||||
void goToUser(int id) {
|
void goToUser(int id) {
|
||||||
print('GO TO USER $id');
|
print('GO TO USER $id');
|
||||||
|
@ -280,7 +285,10 @@ class _AboutTab extends HookWidget {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
|
||||||
child: MarkdownText(site.site.description),
|
child: MarkdownText(
|
||||||
|
site.site.description,
|
||||||
|
instanceUrl: instanceUrl,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
_Divider(),
|
_Divider(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -356,7 +364,9 @@ class _AboutTab extends HookWidget {
|
||||||
e.preferredUsername.isEmpty)
|
e.preferredUsername.isEmpty)
|
||||||
? '@${e.name}'
|
? '@${e.name}'
|
||||||
: e.preferredUsername),
|
: e.preferredUsername),
|
||||||
subtitle: e.bio != null ? MarkdownText(e.bio) : null,
|
subtitle: e.bio != null
|
||||||
|
? MarkdownText(e.bio, instanceUrl: instanceUrl)
|
||||||
|
: null,
|
||||||
onTap: () => goToUser(e.id),
|
onTap: () => goToUser(e.id),
|
||||||
leading: e.avatar != null
|
leading: e.avatar != null
|
||||||
? CachedNetworkImage(
|
? CachedNetworkImage(
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||||
|
|
||||||
|
import '../util/api_extensions.dart';
|
||||||
import '../widgets/markdown_text.dart';
|
import '../widgets/markdown_text.dart';
|
||||||
|
|
||||||
class UsersListPage extends StatelessWidget {
|
class UsersListPage extends StatelessWidget {
|
||||||
|
@ -35,7 +36,10 @@ class UsersListPage extends StatelessWidget {
|
||||||
subtitle: users[i].bio != null
|
subtitle: users[i].bio != null
|
||||||
? Opacity(
|
? Opacity(
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
child: MarkdownText(users[i].bio),
|
child: MarkdownText(
|
||||||
|
users[i].bio,
|
||||||
|
instanceUrl: users[i].instanceUrl,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
onTap: () => goToUser(context, users[i].id),
|
onTap: () => goToUser(context, users[i].id),
|
||||||
|
|
|
@ -169,7 +169,9 @@ class Comment extends StatelessWidget {
|
||||||
style: TextStyle(fontStyle: FontStyle.italic),
|
style: TextStyle(fontStyle: FontStyle.italic),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return Flexible(child: MarkdownText(commentTree.comment.content));
|
return Flexible(
|
||||||
|
child: MarkdownText(commentTree.comment.content,
|
||||||
|
instanceUrl: commentTree.comment.instanceUrl));
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,22 @@ import 'package:markdown/markdown.dart' as md;
|
||||||
import '../url_launcher.dart';
|
import '../url_launcher.dart';
|
||||||
|
|
||||||
class MarkdownText extends StatelessWidget {
|
class MarkdownText extends StatelessWidget {
|
||||||
|
final String instanceUrl;
|
||||||
final String text;
|
final String text;
|
||||||
MarkdownText(this.text);
|
MarkdownText(this.text, {@required this.instanceUrl})
|
||||||
|
: assert(instanceUrl != null);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MarkdownBody(
|
Widget build(BuildContext context) => MarkdownBody(
|
||||||
data: text,
|
data: text,
|
||||||
extensionSet: md.ExtensionSet.gitHubWeb,
|
extensionSet: md.ExtensionSet.gitHubWeb,
|
||||||
onTapLink: (href) {
|
onTapLink: (href) {
|
||||||
urlLauncher(context, href)
|
urlLauncher(context: context, url: href, instanceUrl: instanceUrl)
|
||||||
.catchError((e) => Scaffold.of(context).showSnackBar(SnackBar(
|
.catchError((e) => Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: Row(
|
content: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.warning),
|
Icon(Icons.warning),
|
||||||
Text("couldn't open link"),
|
Text("couldn't open link, ${e.toString()}"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -144,7 +144,8 @@ class Post extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
void _openLink() => urlLauncher(context, post.url);
|
void _openLink() =>
|
||||||
|
urlLauncher(context: context, url: post.url, instanceUrl: instanceUrl);
|
||||||
|
|
||||||
final urlDomain = () {
|
final urlDomain = () {
|
||||||
if (post.url == null) return null;
|
if (post.url == null) return null;
|
||||||
|
@ -437,7 +438,7 @@ class Post extends StatelessWidget {
|
||||||
if (post.body != null)
|
if (post.body != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: MarkdownText(post.body)),
|
child: MarkdownText(post.body, instanceUrl: instanceUrl)),
|
||||||
actions(),
|
actions(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue