2023-05-03 01:13:53 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-11-26 02:27:22 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2023-05-03 01:13:53 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
2024-12-10 11:54:45 +00:00
|
|
|
import '../controls/async_value_widget.dart';
|
2023-05-07 23:06:31 +00:00
|
|
|
import '../controls/image_control.dart';
|
2024-12-10 11:54:45 +00:00
|
|
|
import '../riverpod_controllers/account_services.dart';
|
2024-11-26 02:27:22 +00:00
|
|
|
import '../riverpod_controllers/blocks_services.dart';
|
2023-05-03 01:13:53 +00:00
|
|
|
import '../routes.dart';
|
|
|
|
|
2024-11-26 02:27:22 +00:00
|
|
|
class BlocksScreen extends ConsumerWidget {
|
2023-05-03 20:16:50 +00:00
|
|
|
const BlocksScreen({super.key});
|
2023-05-03 01:13:53 +00:00
|
|
|
|
|
|
|
@override
|
2024-11-26 02:27:22 +00:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2024-12-10 11:54:45 +00:00
|
|
|
final profile = ref.watch(activeProfileProvider);
|
2024-11-26 02:27:22 +00:00
|
|
|
final blocksValue = ref.watch(blocksManagerProvider(profile));
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text('Blocks'),
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
2024-11-26 22:10:51 +00:00
|
|
|
child: AsyncValueWidget(
|
|
|
|
blocksValue,
|
|
|
|
valueBuilder: (context, ref, value) => ListView.builder(
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final contact = value[index];
|
|
|
|
return ListTile(
|
|
|
|
onTap: () async {
|
|
|
|
context.pushNamed(ScreenPaths.userProfile,
|
|
|
|
pathParameters: {'id': contact.id});
|
|
|
|
},
|
|
|
|
leading: ImageControl(
|
|
|
|
imageUrl: contact.avatarUrl.toString(),
|
|
|
|
iconOverride: const Icon(Icons.person),
|
|
|
|
width: 32.0,
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
'${contact.name} (${contact.handle})',
|
|
|
|
softWrap: true,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
'Last Status: ${contact.lastStatus?.toIso8601String() ?? "Unknown"}',
|
|
|
|
softWrap: true,
|
|
|
|
),
|
|
|
|
trailing: ElevatedButton(
|
|
|
|
onPressed: () async => await ref
|
|
|
|
.read(blocksManagerProvider(profile).notifier)
|
|
|
|
.unblockConnection(contact),
|
|
|
|
child: const Text('Unblock'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: value.length,
|
|
|
|
),
|
|
|
|
),
|
2023-05-03 01:13:53 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|