Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misskey_page_page.dartにページURLをコピーするボタンを追加 #700

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/view/channels_page/channel_detail_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class ChannelDetailArea extends ConsumerWidget {
),
);
},
child: const Icon(Icons.copy),
child: const Icon(Icons.link),
),
],
),
Expand Down
83 changes: 74 additions & 9 deletions lib/view/misskey_page_page/misskey_page_page.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import "package:auto_route/auto_route.dart";
import "package:collection/collection.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_gen/gen_l10n/app_localizations.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:mfm_parser/mfm_parser.dart" hide MfmText;
import "package:miria/extensions/list_mfm_node_extension.dart";
import "package:miria/providers.dart";
import "package:miria/view/common/account_scope.dart";
import "package:miria/view/common/constants.dart";
import "package:miria/view/common/note_file_dialog/note_file_dialog.dart";
import "package:miria/view/common/misskey_notes/link_preview.dart";
import "package:miria/view/common/misskey_notes/mfm_text.dart";
import "package:miria/view/common/misskey_notes/misskey_note.dart";
import "package:miria/view/common/misskey_notes/network_image.dart";
import "package:miria/view/common/note_file_dialog/note_file_dialog.dart";
import "package:miria/view/misskey_page_page/misskey_page_notifier.dart";
import "package:miria/view/themes/app_theme.dart";
import "package:miria/view/user_page/user_list_item.dart";
Expand All @@ -39,6 +40,7 @@ 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)),
body: Padding(
Expand All @@ -57,9 +59,54 @@ class MisskeyPagePage extends ConsumerWidget implements AutoRouteWrapper {
mfmText: page.title,
style: Theme.of(context).textTheme.headlineSmall,
),
MfmText(
mfmText: page.summary ?? "",
style: Theme.of(context).textTheme.bodySmall,
if (page.summary != null)
MfmText(
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)
Expand All @@ -72,20 +119,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 @@ -98,6 +145,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