2022-11-29 15:33:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-12-01 19:57:47 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2022-11-29 15:33:16 +00:00
|
|
|
|
2023-03-20 00:54:28 +00:00
|
|
|
import '../controls/linear_status_indicator.dart';
|
2023-01-30 15:45:02 +00:00
|
|
|
import '../controls/standard_appbar.dart';
|
2022-11-29 15:33:16 +00:00
|
|
|
import '../controls/timeline/timeline_panel.dart';
|
2023-01-30 15:45:02 +00:00
|
|
|
import '../globals.dart';
|
2024-12-01 19:57:47 +00:00
|
|
|
import '../models/auth/profile.dart';
|
2024-07-26 14:15:24 +00:00
|
|
|
import '../models/timeline_identifiers.dart';
|
2024-12-01 19:57:47 +00:00
|
|
|
import '../riverpod_controllers/timeline_services.dart';
|
|
|
|
import '../services/auth_service.dart';
|
2023-01-30 15:45:02 +00:00
|
|
|
import '../services/network_status_service.dart';
|
2022-11-29 15:33:16 +00:00
|
|
|
|
2024-12-01 19:57:47 +00:00
|
|
|
class UserPostsScreen extends ConsumerStatefulWidget {
|
2022-11-29 15:33:16 +00:00
|
|
|
final String userId;
|
|
|
|
|
|
|
|
const UserPostsScreen({super.key, required this.userId});
|
|
|
|
|
2023-03-20 00:54:28 +00:00
|
|
|
@override
|
2024-12-01 19:57:47 +00:00
|
|
|
ConsumerState<UserPostsScreen> createState() => _UserPostsScreenState();
|
2023-03-20 00:54:28 +00:00
|
|
|
}
|
|
|
|
|
2024-12-01 19:57:47 +00:00
|
|
|
class _UserPostsScreenState extends ConsumerState<UserPostsScreen> {
|
2023-03-20 00:54:28 +00:00
|
|
|
late final TimelineIdentifiers timeline;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-12-01 19:57:47 +00:00
|
|
|
final profile = context.read<AccountsService>().currentProfile;
|
2023-03-20 00:54:28 +00:00
|
|
|
timeline = TimelineIdentifiers.profile(widget.userId);
|
2024-12-01 19:57:47 +00:00
|
|
|
updateTimeline(profile);
|
2023-03-20 00:54:28 +00:00
|
|
|
}
|
|
|
|
|
2024-12-01 19:57:47 +00:00
|
|
|
void updateTimeline(Profile profile) {
|
2023-03-20 00:54:28 +00:00
|
|
|
Future.delayed(const Duration(milliseconds: 100), () async {
|
2024-12-01 19:57:47 +00:00
|
|
|
await ref
|
|
|
|
.read(timelineManagerProvider(profile, timeline).notifier)
|
|
|
|
.updateTimeline(TimelineRefreshType.refresh);
|
2023-03-20 00:54:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-29 15:33:16 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-30 15:45:02 +00:00
|
|
|
final nss = getIt<NetworkStatusService>();
|
2024-12-01 19:57:47 +00:00
|
|
|
final profile = context.watch<AccountsService>().currentProfile;
|
|
|
|
ref.watch(timelineManagerProvider(profile, timeline));
|
2023-03-20 00:54:28 +00:00
|
|
|
|
2022-11-29 15:33:16 +00:00
|
|
|
return Scaffold(
|
2023-01-30 15:45:02 +00:00
|
|
|
appBar: StandardAppBar.build(
|
|
|
|
context,
|
|
|
|
'User Posts',
|
2023-03-20 00:54:28 +00:00
|
|
|
actions: [],
|
2022-11-29 15:33:16 +00:00
|
|
|
),
|
|
|
|
body: Center(
|
2023-03-20 00:54:28 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
StandardLinearProgressIndicator(nss.timelineLoadingStatus),
|
|
|
|
Expanded(
|
|
|
|
child: TimelinePanel(
|
|
|
|
timeline: timeline,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-11-29 15:33:16 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|