Compare commits
2 Commits
e4582b7d25
...
b8245b00b6
Author | SHA1 | Date | |
---|---|---|---|
b8245b00b6 | |||
462e818078 |
@ -5,6 +5,7 @@ import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:surface/providers/sn_attachment.dart';
|
||||
import 'package:surface/providers/sn_network.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
@ -172,7 +173,10 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
||||
onFetchData: _fetchPosts,
|
||||
itemBuilder: (context, idx) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: PostItem(data: _posts[idx]),
|
||||
).center(),
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'postDetail',
|
||||
|
@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:surface/providers/sn_attachment.dart';
|
||||
import 'package:surface/providers/sn_network.dart';
|
||||
import 'package:surface/providers/userinfo.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
import 'package:surface/widgets/dialog.dart';
|
||||
import 'package:surface/widgets/loading_indicator.dart';
|
||||
@ -71,6 +72,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ua = context.watch<UserProvider>();
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
|
||||
return Scaffold(
|
||||
@ -107,10 +109,13 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
),
|
||||
if (_data != null)
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: PostItem(
|
||||
data: _data!,
|
||||
showComments: false,
|
||||
),
|
||||
).center(),
|
||||
),
|
||||
const SliverToBoxAdapter(child: Divider(height: 1)),
|
||||
if (_data != null)
|
||||
@ -126,7 +131,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
],
|
||||
).padding(horizontal: 20, vertical: 12),
|
||||
),
|
||||
if (_data != null)
|
||||
if (_data != null && ua.isAuthorized)
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 240,
|
||||
@ -157,6 +162,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
PostCommentSliverList(
|
||||
key: _childListKey,
|
||||
parentPostId: _data!.id,
|
||||
maxWidth: 640,
|
||||
),
|
||||
SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
|
||||
],
|
||||
|
@ -26,6 +26,11 @@ class AttachmentList extends StatelessWidget {
|
||||
final borderSide = (bordered ?? false)
|
||||
? BorderSide(width: 1, color: Theme.of(context).dividerColor)
|
||||
: BorderSide.none;
|
||||
final backgroundColor = Theme.of(context).colorScheme.surfaceContainer;
|
||||
final constraints = BoxConstraints(
|
||||
minWidth: 80,
|
||||
maxHeight: maxHeight ?? double.infinity,
|
||||
);
|
||||
|
||||
if (data.isEmpty) return const SizedBox.shrink();
|
||||
if (data.length == 1) {
|
||||
@ -34,11 +39,9 @@ class AttachmentList extends StatelessWidget {
|
||||
// Single child list-like displaying
|
||||
padding: listPadding ?? EdgeInsets.zero,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 80,
|
||||
maxHeight: maxHeight ?? double.infinity,
|
||||
),
|
||||
constraints: constraints,
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
border: Border(top: borderSide, bottom: borderSide),
|
||||
borderRadius: kDefaultRadius,
|
||||
),
|
||||
@ -55,6 +58,7 @@ class AttachmentList extends StatelessWidget {
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
border: Border(top: borderSide, bottom: borderSide),
|
||||
),
|
||||
child: AspectRatio(
|
||||
@ -72,12 +76,12 @@ class AttachmentList extends StatelessWidget {
|
||||
shrinkWrap: true,
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, idx) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 80,
|
||||
maxHeight: maxHeight ?? double.infinity,
|
||||
),
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
constraints: constraints,
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
border: Border(top: borderSide, bottom: borderSide),
|
||||
borderRadius: kDefaultRadius,
|
||||
),
|
||||
@ -85,9 +89,19 @@ class AttachmentList extends StatelessWidget {
|
||||
aspectRatio: data[idx].metadata['ratio']?.toDouble() ?? 1,
|
||||
child: ClipRRect(
|
||||
borderRadius: kDefaultRadius,
|
||||
child: AttachmentItem(data: data[idx], isExpandable: true),
|
||||
child:
|
||||
AttachmentItem(data: data[idx], isExpandable: true),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 12,
|
||||
bottom: 12,
|
||||
child: Chip(
|
||||
label: Text('${idx + 1}/${data.length}'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => const Gap(8),
|
||||
|
@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:surface/providers/sn_attachment.dart';
|
||||
import 'package:surface/providers/sn_network.dart';
|
||||
import 'package:surface/providers/userinfo.dart';
|
||||
import 'package:surface/types/post.dart';
|
||||
import 'package:surface/widgets/post/post_item.dart';
|
||||
import 'package:surface/widgets/post/post_mini_editor.dart';
|
||||
@ -14,7 +15,12 @@ import 'package:very_good_infinite_list/very_good_infinite_list.dart';
|
||||
|
||||
class PostCommentSliverList extends StatefulWidget {
|
||||
final int parentPostId;
|
||||
const PostCommentSliverList({super.key, required this.parentPostId});
|
||||
final double? maxWidth;
|
||||
const PostCommentSliverList({
|
||||
super.key,
|
||||
required this.parentPostId,
|
||||
this.maxWidth,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PostCommentSliverList> createState() => PostCommentSliverListState();
|
||||
@ -88,7 +94,12 @@ class PostCommentSliverListState extends State<PostCommentSliverList> {
|
||||
onFetchData: _fetchPosts,
|
||||
itemBuilder: (context, idx) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: widget.maxWidth ?? double.infinity,
|
||||
),
|
||||
child: PostItem(data: _posts[idx]),
|
||||
).center(),
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'postDetail',
|
||||
@ -121,6 +132,7 @@ class _PostCommentListPopupState extends State<PostCommentListPopup> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ua = context.watch<UserProvider>();
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
|
||||
return Column(
|
||||
@ -139,6 +151,7 @@ class _PostCommentListPopupState extends State<PostCommentListPopup> {
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (ua.isAuthorized)
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 240,
|
||||
|
Loading…
x
Reference in New Issue
Block a user