Compare commits

...

2 Commits

Author SHA1 Message Date
f8d1940af6 Report user 2025-07-03 22:07:51 +08:00
b2b0891d24 Block user 2025-07-03 22:03:12 +08:00
3 changed files with 116 additions and 39 deletions

View File

@ -22,6 +22,7 @@ import 'package:island/widgets/account/status.dart';
import 'package:island/widgets/alert.dart'; import 'package:island/widgets/alert.dart';
import 'package:island/widgets/app_scaffold.dart'; import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/content/cloud_files.dart'; import 'package:island/widgets/content/cloud_files.dart';
import 'package:island/widgets/safety/abuse_report_helper.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:palette_generator/palette_generator.dart'; import 'package:palette_generator/palette_generator.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart';
@ -143,6 +144,23 @@ class AccountProfileScreen extends HookConsumerWidget {
} }
} }
Future<void> blockAction() async {
showLoadingModal(context);
try {
final client = ref.watch(apiClientProvider);
if (accountRelationship.value == null) {
await client.post('/relationships/${account.value!.id}/block');
} else {
await client.delete('/relationships/${account.value!.id}/block');
}
ref.invalidate(accountRelationshipProvider(name));
} catch (err) {
showErrorAlert(err);
} finally {
if (context.mounted) hideLoadingModal(context);
}
}
Future<void> directMessageAction() async { Future<void> directMessageAction() async {
if (!account.hasValue) return; if (!account.hasValue) return;
if (accountChat.value != null) { if (accountChat.value != null) {
@ -396,6 +414,8 @@ class AccountProfileScreen extends HookConsumerWidget {
child: Row( child: Row(
spacing: 8, spacing: 8,
children: [ children: [
if (accountRelationship.value == null ||
accountRelationship.value!.status > -100)
Expanded( Expanded(
child: FilledButton.icon( child: FilledButton.icon(
style: ButtonStyle( style: ButtonStyle(
@ -407,7 +427,9 @@ class AccountProfileScreen extends HookConsumerWidget {
foregroundColor: WidgetStatePropertyAll( foregroundColor: WidgetStatePropertyAll(
accountRelationship.value == null accountRelationship.value == null
? null ? null
: Theme.of(context).colorScheme.onSecondary, : Theme.of(
context,
).colorScheme.onSecondary,
), ),
), ),
onPressed: relationshipAction, onPressed: relationshipAction,
@ -423,6 +445,44 @@ class AccountProfileScreen extends HookConsumerWidget {
: const Icon(Symbols.person_check), : const Icon(Symbols.person_check),
), ),
), ),
if (accountRelationship.value == null ||
accountRelationship.value!.status <= -100)
Expanded(
child: FilledButton.icon(
style: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(
accountRelationship.value == null
? null
: Theme.of(context).colorScheme.secondary,
),
foregroundColor: WidgetStatePropertyAll(
accountRelationship.value == null
? null
: Theme.of(
context,
).colorScheme.onSecondary,
),
),
onPressed: blockAction,
label:
Text(
accountRelationship.value == null
? 'blockUser'
: 'unblockUser',
).tr(),
icon:
accountRelationship.value == null
? const Icon(Symbols.block)
: const Icon(Symbols.person_cancel),
),
),
],
).padding(horizontal: 16),
),
SliverToBoxAdapter(
child: Row(
spacing: 8,
children: [
Expanded( Expanded(
child: FilledButton.icon( child: FilledButton.icon(
onPressed: directMessageAction, onPressed: directMessageAction,
@ -436,8 +496,25 @@ class AccountProfileScreen extends HookConsumerWidget {
).tr(), ).tr(),
), ),
), ),
IconButton.filled(
onPressed: () {
showAbuseReportSheet(
context,
resourceIdentifier: 'account/${data.id}',
);
},
icon: Icon(
Symbols.flag,
color: Theme.of(context).colorScheme.onError,
),
style: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.error,
),
),
),
], ],
).padding(horizontal: 16), ).padding(horizontal: 16, top: 4),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: const Divider(height: 1).padding(top: 12), child: const Divider(height: 1).padding(top: 12),

View File

@ -187,7 +187,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
), ),
onTap: () { onTap: () {
Navigator.pop(context, true); Navigator.pop(context, true);
context.push('/account/${data.name}'); context.push('/account/${data.account?.name}');
}, },
), ),
Expanded( Expanded(

View File

@ -576,7 +576,7 @@ class PostItem extends HookConsumerWidget {
callback: () { callback: () {
showAbuseReportSheet( showAbuseReportSheet(
context, context,
resourceIdentifier: 'posts:${item.id}', resourceIdentifier: 'post/${item.id}',
); );
}, },
), ),