relatica/lib/screens/post_screen.dart

52 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../controls/standard_appbar.dart';
import '../controls/status_and_refresh_button.dart';
import '../controls/timeline/post_control.dart';
import '../globals.dart';
import '../services/network_status_service.dart';
import '../services/timeline_manager.dart';
import '../utils/active_profile_selector.dart';
class PostScreen extends StatelessWidget {
final String id;
final String goToId;
const PostScreen({
super.key,
required this.id,
required this.goToId,
});
@override
Widget build(BuildContext context) {
final nss = getIt<NetworkStatusService>();
final manager = context
.watch<ActiveProfileSelector<TimelineManager>>()
.activeEntry
.value;
final body = manager.getPostTreeEntryBy(id).fold(
onSuccess: (post) => PostControl(
originalItem: post,
scrollToId: goToId,
openRemote: true,
showStatusOpenButton: true,
isRoot: true,
),
onError: (error) => Text('Error getting post: $error'));
return Scaffold(
appBar: StandardAppBar.build(context, 'View Post', actions: [
StatusAndRefreshButton(
valueListenable: nss.timelineLoadingStatus,
refreshFunction: () async => await manager.refreshStatusChain(id),
busyColor: Theme.of(context).appBarTheme.foregroundColor,
),
]),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: body,
));
}
}