Compare commits
2 Commits
274168d4bc
...
f8d1940af6
Author | SHA1 | Date | |
---|---|---|---|
f8d1940af6 | |||
b2b0891d24 |
@ -22,6 +22,7 @@ import 'package:island/widgets/account/status.dart';
|
||||
import 'package:island/widgets/alert.dart';
|
||||
import 'package:island/widgets/app_scaffold.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:palette_generator/palette_generator.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 {
|
||||
if (!account.hasValue) return;
|
||||
if (accountChat.value != null) {
|
||||
@ -396,49 +414,108 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
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: relationshipAction,
|
||||
label:
|
||||
Text(
|
||||
if (accountRelationship.value == null ||
|
||||
accountRelationship.value!.status > -100)
|
||||
Expanded(
|
||||
child: FilledButton.icon(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
accountRelationship.value == null
|
||||
? 'addFriendShort'
|
||||
: 'added',
|
||||
).tr(),
|
||||
icon:
|
||||
accountRelationship.value == null
|
||||
? const Icon(Symbols.person_add)
|
||||
: const Icon(Symbols.person_check),
|
||||
? null
|
||||
: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
foregroundColor: WidgetStatePropertyAll(
|
||||
accountRelationship.value == null
|
||||
? null
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSecondary,
|
||||
),
|
||||
),
|
||||
onPressed: relationshipAction,
|
||||
label:
|
||||
Text(
|
||||
accountRelationship.value == null
|
||||
? 'addFriendShort'
|
||||
: 'added',
|
||||
).tr(),
|
||||
icon:
|
||||
accountRelationship.value == null
|
||||
? const Icon(Symbols.person_add)
|
||||
: const Icon(Symbols.person_check),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FilledButton.icon(
|
||||
onPressed: directMessageAction,
|
||||
icon: const Icon(Symbols.message),
|
||||
label:
|
||||
Text(
|
||||
accountChat.value == null
|
||||
? 'createDirectMessage'
|
||||
: 'gotoDirectMessage',
|
||||
maxLines: 1,
|
||||
).tr(),
|
||||
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(
|
||||
child: FilledButton.icon(
|
||||
onPressed: directMessageAction,
|
||||
icon: const Icon(Symbols.message),
|
||||
label:
|
||||
Text(
|
||||
accountChat.value == null
|
||||
? 'createDirectMessage'
|
||||
: 'gotoDirectMessage',
|
||||
maxLines: 1,
|
||||
).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, top: 4),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: const Divider(height: 1).padding(top: 12),
|
||||
),
|
||||
|
@ -187,7 +187,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context, true);
|
||||
context.push('/account/${data.name}');
|
||||
context.push('/account/${data.account?.name}');
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
|
@ -576,7 +576,7 @@ class PostItem extends HookConsumerWidget {
|
||||
callback: () {
|
||||
showAbuseReportSheet(
|
||||
context,
|
||||
resourceIdentifier: 'posts:${item.id}',
|
||||
resourceIdentifier: 'post/${item.id}',
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user