Compare commits
No commits in common. "058d668b6b37d8adc2c4d808ddde9af232cb028c" and "0a381ef09b8293940c5aa5975fe955da0a336ecf" have entirely different histories.
058d668b6b
...
0a381ef09b
@ -64,8 +64,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ua = context.watch<UserProvider>();
|
final ua = context.watch<UserProvider>();
|
||||||
|
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||||
final double maxWidth = _data?.type == 'video' ? double.infinity : 640;
|
|
||||||
|
|
||||||
return AppBackground(
|
return AppBackground(
|
||||||
isRoot: widget.onBack != null,
|
isRoot: widget.onBack != null,
|
||||||
@ -115,7 +114,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: PostItem(
|
child: PostItem(
|
||||||
data: _data!,
|
data: _data!,
|
||||||
maxWidth: maxWidth,
|
maxWidth: 640,
|
||||||
showComments: false,
|
showComments: false,
|
||||||
showFullPost: true,
|
showFullPost: true,
|
||||||
onChanged: (data) {
|
onChanged: (data) {
|
||||||
@ -126,11 +125,11 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_data != null && _data!.type != 'video') const SliverToBoxAdapter(child: Divider(height: 1)),
|
const SliverToBoxAdapter(child: Divider(height: 1)),
|
||||||
if (_data != null && _data!.type != 'video')
|
if (_data != null)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -143,30 +142,51 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
).padding(horizontal: 20, vertical: 12).center(),
|
).padding(horizontal: 20, vertical: 12).center(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_data != null && ua.isAuthorized && _data!.type != 'video')
|
if (_data != null && ua.isAuthorized)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: PostCommentQuickAction(
|
child: Container(
|
||||||
parentPost: _data!,
|
height: 240,
|
||||||
maxWidth: maxWidth,
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
onPosted: () {
|
margin:
|
||||||
setState(() {
|
ResponsiveBreakpoints.of(context).largerThan(MOBILE) ? const EdgeInsets.all(8) : EdgeInsets.zero,
|
||||||
_data = _data!.copyWith(
|
decoration: BoxDecoration(
|
||||||
metric: _data!.metric.copyWith(
|
borderRadius: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
replyCount: _data!.metric.replyCount + 1,
|
? const BorderRadius.all(Radius.circular(8))
|
||||||
),
|
: BorderRadius.zero,
|
||||||
);
|
border: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
});
|
? Border.all(
|
||||||
_childListKey.currentState!.refresh();
|
color: Theme.of(context).dividerColor,
|
||||||
},
|
width: 1 / devicePixelRatio,
|
||||||
),
|
)
|
||||||
|
: Border.symmetric(
|
||||||
|
horizontal: BorderSide(
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
width: 1 / devicePixelRatio,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: PostMiniEditor(
|
||||||
|
postReplyId: _data!.id,
|
||||||
|
onPost: () {
|
||||||
|
setState(() {
|
||||||
|
_data = _data!.copyWith(
|
||||||
|
metric: _data!.metric.copyWith(
|
||||||
|
replyCount: _data!.metric.replyCount + 1,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
_childListKey.currentState!.refresh();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
).center(),
|
||||||
),
|
),
|
||||||
if (_data != null && _data!.type != 'video')
|
if (_data != null)
|
||||||
PostCommentSliverList(
|
PostCommentSliverList(
|
||||||
key: _childListKey,
|
key: _childListKey,
|
||||||
parentPost: _data!,
|
parentPost: _data!,
|
||||||
maxWidth: maxWidth,
|
maxWidth: 640,
|
||||||
),
|
),
|
||||||
if (_data != null && _data!.type == 'video') SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
|
SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -891,7 +891,7 @@ class _PostVideoEditor extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
onTap: controller.videoAttachment == null ? () => _selectVideo(context) : null,
|
onTap: controller.videoAttachment != null ? () => _selectVideo(context) : null,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 16 / 9,
|
aspectRatio: 16 / 9,
|
||||||
child: controller.videoAttachment == null
|
child: controller.videoAttachment == null
|
||||||
|
@ -4,7 +4,6 @@ import 'package:gap/gap.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:responsive_framework/responsive_framework.dart';
|
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/providers/post.dart';
|
import 'package:surface/providers/post.dart';
|
||||||
import 'package:surface/providers/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
@ -16,47 +15,6 @@ import 'package:very_good_infinite_list/very_good_infinite_list.dart';
|
|||||||
|
|
||||||
import '../../providers/sn_network.dart';
|
import '../../providers/sn_network.dart';
|
||||||
|
|
||||||
class PostCommentQuickAction extends StatelessWidget {
|
|
||||||
final double? maxWidth;
|
|
||||||
final SnPost parentPost;
|
|
||||||
final Function? onPosted;
|
|
||||||
|
|
||||||
const PostCommentQuickAction({super.key, this.maxWidth, required this.parentPost, this.onPosted});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
height: 240,
|
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
|
||||||
margin: ResponsiveBreakpoints.of(context).largerThan(MOBILE) ? const EdgeInsets.symmetric(vertical: 8) : EdgeInsets.zero,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
|
||||||
? const BorderRadius.all(Radius.circular(8))
|
|
||||||
: BorderRadius.zero,
|
|
||||||
border: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
|
||||||
? Border.all(
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
width: 1 / devicePixelRatio,
|
|
||||||
)
|
|
||||||
: Border.symmetric(
|
|
||||||
horizontal: BorderSide(
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
width: 1 / devicePixelRatio,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: PostMiniEditor(
|
|
||||||
postReplyId: parentPost.id,
|
|
||||||
onPost: () {
|
|
||||||
onPosted?.call();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PostCommentSliverList extends StatefulWidget {
|
class PostCommentSliverList extends StatefulWidget {
|
||||||
final SnPost parentPost;
|
final SnPost parentPost;
|
||||||
final double? maxWidth;
|
final double? maxWidth;
|
||||||
@ -113,7 +71,6 @@ class PostCommentSliverListState extends State<PostCommentSliverList> {
|
|||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
_posts.clear();
|
_posts.clear();
|
||||||
_postCount = null;
|
|
||||||
_fetchPosts();
|
_fetchPosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,57 +195,6 @@ class PostItem extends StatelessWidget {
|
|||||||
final ua = context.read<UserProvider>();
|
final ua = context.read<UserProvider>();
|
||||||
final isAuthor = ua.isAuthorized && data.publisher.accountId == ua.user?.id;
|
final isAuthor = ua.isAuthorized && data.publisher.accountId == ua.user?.id;
|
||||||
|
|
||||||
// Video full view
|
|
||||||
if (showFullPost && data.type == 'video' && ResponsiveBreakpoints.of(context).largerThan(TABLET)) {
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Gap(16),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
_PostContentHeader(
|
|
||||||
data: data,
|
|
||||||
isAuthor: isAuthor,
|
|
||||||
isRelativeDate: !showFullPost,
|
|
||||||
onShare: () => _doShare(context),
|
|
||||||
onShareImage: () => _doShareViaPicture(context),
|
|
||||||
onSelectAnswer: onSelectAnswer,
|
|
||||||
onDeleted: () {
|
|
||||||
if (onDeleted != null) {}
|
|
||||||
},
|
|
||||||
).padding(bottom: 8),
|
|
||||||
if (data.preload?.video != null) _PostVideoPlayer(data: data).padding(bottom: 8),
|
|
||||||
_PostHeadline(data: data).padding(horizontal: 4, bottom: 8),
|
|
||||||
_PostFeaturedComment(data: data).padding(),
|
|
||||||
_PostBottomAction(
|
|
||||||
data: data,
|
|
||||||
showComments: true,
|
|
||||||
showReactions: showReactions,
|
|
||||||
onShare: () => _doShare(context),
|
|
||||||
onShareImage: () => _doShareViaPicture(context),
|
|
||||||
onChanged: _onChanged,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(4),
|
|
||||||
SizedBox(
|
|
||||||
width: 340,
|
|
||||||
child: CustomScrollView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
slivers: [
|
|
||||||
PostCommentSliverList(
|
|
||||||
parentPost: data,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Article headline preview
|
// Article headline preview
|
||||||
if (!showFullPost && data.type == 'article') {
|
if (!showFullPost && data.type == 'article') {
|
||||||
return Container(
|
return Container(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user