Skip to content

Commit

Permalink
ページタイトル下に「ブラウザで開く」ボタンと「リンクをコピー」ボタンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Npepperlinux committed Nov 30, 2024
1 parent 5b21ca6 commit 0a5e780
Showing 1 changed file with 69 additions and 28 deletions.
97 changes: 69 additions & 28 deletions lib/view/misskey_page_page/misskey_page_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,9 @@ class MisskeyPagePage extends ConsumerWidget implements AutoRouteWrapper {

@override
Widget build(BuildContext context, WidgetRef ref) {
final accountHost = ref.read(accountContextProvider).getAccount.host;
return Scaffold(
appBar: AppBar(
title: Text(S.of(context).page),
actions: <Widget>[
IconButton(
onPressed: () async {
await Clipboard.setData(
ClipboardData(
text:
"https://${ref.read(accountContextProvider).getAccount.host}/@${page.user.username}/pages/${page.name}",
),
);
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).doneCopy),
duration: const Duration(seconds: 1),
),
);
},
icon: const Icon(Icons.link),
),
],
),
appBar: AppBar(title: Text(S.of(context).page)),
body: Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 20),
child: Align(
Expand All @@ -84,6 +63,50 @@ class MisskeyPagePage extends ConsumerWidget implements AutoRouteWrapper {
mfmText: page.summary ?? "",
style: Theme.of(context).textTheme.bodySmall,
),
Align(
alignment: Alignment.centerRight,
child: Wrap(
spacing: 5,
alignment: WrapAlignment.end,
children: [
OutlinedButton(
onPressed: () async => launchUrl(
Uri(
scheme: "https",
host: accountHost,
pathSegments: [
"@${page.user.username}",
"pages",
page.name,
],
),
),
child: Text(
S.of(context).openBrowsers,
style: AppTheme.of(context).linkStyle,
),
),
OutlinedButton(
onPressed: () async {
await Clipboard.setData(
ClipboardData(
text:
"https://$accountHost/@${page.user.username}/pages/${page.name}",
),
);
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).doneCopy),
duration: const Duration(seconds: 1),
),
);
},
child: const Icon(Icons.link),
),
],
),
),
const Divider(),
if (page.eyeCatchingImage != null)
NetworkImageView(
Expand All @@ -95,20 +118,20 @@ class MisskeyPagePage extends ConsumerWidget implements AutoRouteWrapper {
const Divider(),
Text(S.of(context).pageWrittenBy),
UserListItem(user: page.user),
Row(
Wrap(
spacing: 5,
children: [
PageLikeButton(
initialLiked: page.isLiked ?? false,
likeCount: page.likedCount,
pageId: page.id,
userId: page.userId,
),
const Padding(padding: EdgeInsets.only(left: 10)),
GestureDetector(
onTap: () async => launchUrl(
OutlinedButton(
onPressed: () async => launchUrl(
Uri(
scheme: "https",
host: accountContext.getAccount.host,
host: accountHost,
pathSegments: [
"@${page.user.username}",
"pages",
Expand All @@ -121,6 +144,24 @@ class MisskeyPagePage extends ConsumerWidget implements AutoRouteWrapper {
style: AppTheme.of(context).linkStyle,
),
),
OutlinedButton(
onPressed: () async {
await Clipboard.setData(
ClipboardData(
text:
"https://$accountHost/@${page.user.username}/pages/${page.name}",
),
);
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context).doneCopy),
duration: const Duration(seconds: 1),
),
);
},
child: const Icon(Icons.link),
),
],
),
Align(
Expand Down

0 comments on commit 0a5e780

Please sign in to comment.