2023-04-18 23:39:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-12-07 02:33:51 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2023-04-18 23:39:52 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
|
|
|
import '../controls/responsive_max_width.dart';
|
|
|
|
import '../controls/standard_appbar.dart';
|
2024-08-28 15:57:10 +00:00
|
|
|
import '../models/timeline_grouping_list_data.dart';
|
2024-12-10 11:54:45 +00:00
|
|
|
import '../riverpod_controllers/account_services.dart';
|
2024-12-07 02:33:51 +00:00
|
|
|
import '../riverpod_controllers/circles_repo_services.dart';
|
2023-04-18 23:39:52 +00:00
|
|
|
import '../routes.dart';
|
|
|
|
|
2024-12-07 02:33:51 +00:00
|
|
|
class CircleManagementScreen extends ConsumerWidget {
|
2023-11-15 21:05:45 +00:00
|
|
|
const CircleManagementScreen({super.key});
|
2023-04-18 23:39:52 +00:00
|
|
|
|
|
|
|
@override
|
2024-12-07 02:33:51 +00:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2024-12-10 11:54:45 +00:00
|
|
|
final profile = ref.watch(activeProfileProvider);
|
2024-12-07 02:33:51 +00:00
|
|
|
final circles =
|
|
|
|
ref.watch(timelineGroupingListProvider(profile, GroupingType.circle));
|
2023-11-15 21:05:45 +00:00
|
|
|
circles.sort((g1, g2) => g1.name.compareTo(g2.name));
|
2023-04-18 23:39:52 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: StandardAppBar.build(
|
|
|
|
context,
|
2023-11-15 21:05:45 +00:00
|
|
|
'Circles Management',
|
2023-04-18 23:39:52 +00:00
|
|
|
withHome: false,
|
|
|
|
actions: [
|
|
|
|
IconButton(
|
|
|
|
onPressed: () => context.push(
|
2023-11-15 21:05:45 +00:00
|
|
|
'${ScreenPaths.circleManagement}/new',
|
2023-04-18 23:39:52 +00:00
|
|
|
),
|
|
|
|
icon: const Icon(Icons.add),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
body: Center(
|
|
|
|
child: RefreshIndicator(
|
|
|
|
onRefresh: () async {
|
2024-12-07 02:33:51 +00:00
|
|
|
ref.read(circlesProvider(profile).notifier).refresh();
|
2023-04-18 23:39:52 +00:00
|
|
|
},
|
|
|
|
child: ResponsiveMaxWidth(
|
|
|
|
child: ListView.separated(
|
|
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
|
|
itemBuilder: (context, index) {
|
2023-11-15 21:05:45 +00:00
|
|
|
final circle = circles[index];
|
2023-04-18 23:39:52 +00:00
|
|
|
return ListTile(
|
2023-11-15 21:05:45 +00:00
|
|
|
title: Text(circle.name),
|
2023-04-18 23:39:52 +00:00
|
|
|
onTap: () => context.push(
|
2023-11-15 21:05:45 +00:00
|
|
|
'${ScreenPaths.circleManagement}/show/${circle.id}'),
|
2023-04-18 23:39:52 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
separatorBuilder: (_, __) => const Divider(),
|
2023-11-15 21:05:45 +00:00
|
|
|
itemCount: circles.length,
|
2023-04-18 23:39:52 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|