Compare commits

..

No commits in common. "b8245b00b61977ae2ed89216d83c084554b795f9" and "e4582b7d257cb5007cd2e1ea51313033042cdbee" have entirely different histories.

4 changed files with 42 additions and 79 deletions

View File

@ -5,7 +5,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:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_attachment.dart'; import 'package:surface/providers/sn_attachment.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/post.dart'; import 'package:surface/types/post.dart';
@ -173,10 +172,7 @@ class _ExploreScreenState extends State<ExploreScreen> {
onFetchData: _fetchPosts, onFetchData: _fetchPosts,
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
return GestureDetector( return GestureDetector(
child: Container( child: PostItem(data: _posts[idx]),
constraints: const BoxConstraints(maxWidth: 640),
child: PostItem(data: _posts[idx]),
).center(),
onTap: () { onTap: () {
GoRouter.of(context).pushNamed( GoRouter.of(context).pushNamed(
'postDetail', 'postDetail',

View File

@ -9,7 +9,6 @@ import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_attachment.dart'; import 'package:surface/providers/sn_attachment.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/post.dart'; import 'package:surface/types/post.dart';
import 'package:surface/widgets/dialog.dart'; import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart'; import 'package:surface/widgets/loading_indicator.dart';
@ -72,7 +71,6 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ua = context.watch<UserProvider>();
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
return Scaffold( return Scaffold(
@ -109,13 +107,10 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
), ),
if (_data != null) if (_data != null)
SliverToBoxAdapter( SliverToBoxAdapter(
child: Container( child: PostItem(
constraints: const BoxConstraints(maxWidth: 640), data: _data!,
child: PostItem( showComments: false,
data: _data!, ),
showComments: false,
),
).center(),
), ),
const SliverToBoxAdapter(child: Divider(height: 1)), const SliverToBoxAdapter(child: Divider(height: 1)),
if (_data != null) if (_data != null)
@ -131,7 +126,7 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
], ],
).padding(horizontal: 20, vertical: 12), ).padding(horizontal: 20, vertical: 12),
), ),
if (_data != null && ua.isAuthorized) if (_data != null)
SliverToBoxAdapter( SliverToBoxAdapter(
child: Container( child: Container(
height: 240, height: 240,
@ -162,7 +157,6 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
PostCommentSliverList( PostCommentSliverList(
key: _childListKey, key: _childListKey,
parentPostId: _data!.id, parentPostId: _data!.id,
maxWidth: 640,
), ),
SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)), SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
], ],

View File

@ -26,11 +26,6 @@ class AttachmentList extends StatelessWidget {
final borderSide = (bordered ?? false) final borderSide = (bordered ?? false)
? BorderSide(width: 1, color: Theme.of(context).dividerColor) ? BorderSide(width: 1, color: Theme.of(context).dividerColor)
: BorderSide.none; : 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.isEmpty) return const SizedBox.shrink();
if (data.length == 1) { if (data.length == 1) {
@ -39,9 +34,11 @@ class AttachmentList extends StatelessWidget {
// Single child list-like displaying // Single child list-like displaying
padding: listPadding ?? EdgeInsets.zero, padding: listPadding ?? EdgeInsets.zero,
child: Container( child: Container(
constraints: constraints, constraints: BoxConstraints(
minWidth: 80,
maxHeight: maxHeight ?? double.infinity,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor,
border: Border(top: borderSide, bottom: borderSide), border: Border(top: borderSide, bottom: borderSide),
borderRadius: kDefaultRadius, borderRadius: kDefaultRadius,
), ),
@ -58,7 +55,6 @@ class AttachmentList extends StatelessWidget {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor,
border: Border(top: borderSide, bottom: borderSide), border: Border(top: borderSide, bottom: borderSide),
), ),
child: AspectRatio( child: AspectRatio(
@ -76,32 +72,22 @@ class AttachmentList extends StatelessWidget {
shrinkWrap: true, shrinkWrap: true,
itemCount: data.length, itemCount: data.length,
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
return Stack( return Container(
children: [ constraints: BoxConstraints(
Container( minWidth: 80,
constraints: constraints, maxHeight: maxHeight ?? double.infinity,
decoration: BoxDecoration( ),
color: backgroundColor, decoration: BoxDecoration(
border: Border(top: borderSide, bottom: borderSide), border: Border(top: borderSide, bottom: borderSide),
borderRadius: kDefaultRadius, borderRadius: kDefaultRadius,
), ),
child: AspectRatio( child: AspectRatio(
aspectRatio: data[idx].metadata['ratio']?.toDouble() ?? 1, aspectRatio: data[idx].metadata['ratio']?.toDouble() ?? 1,
child: ClipRRect( child: ClipRRect(
borderRadius: kDefaultRadius, borderRadius: kDefaultRadius,
child: child: AttachmentItem(data: data[idx], isExpandable: true),
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), separatorBuilder: (context, index) => const Gap(8),

View File

@ -7,7 +7,6 @@ import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_attachment.dart'; import 'package:surface/providers/sn_attachment.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/post.dart'; import 'package:surface/types/post.dart';
import 'package:surface/widgets/post/post_item.dart'; import 'package:surface/widgets/post/post_item.dart';
import 'package:surface/widgets/post/post_mini_editor.dart'; import 'package:surface/widgets/post/post_mini_editor.dart';
@ -15,12 +14,7 @@ import 'package:very_good_infinite_list/very_good_infinite_list.dart';
class PostCommentSliverList extends StatefulWidget { class PostCommentSliverList extends StatefulWidget {
final int parentPostId; final int parentPostId;
final double? maxWidth; const PostCommentSliverList({super.key, required this.parentPostId});
const PostCommentSliverList({
super.key,
required this.parentPostId,
this.maxWidth,
});
@override @override
State<PostCommentSliverList> createState() => PostCommentSliverListState(); State<PostCommentSliverList> createState() => PostCommentSliverListState();
@ -94,12 +88,7 @@ class PostCommentSliverListState extends State<PostCommentSliverList> {
onFetchData: _fetchPosts, onFetchData: _fetchPosts,
itemBuilder: (context, idx) { itemBuilder: (context, idx) {
return GestureDetector( return GestureDetector(
child: Container( child: PostItem(data: _posts[idx]),
constraints: BoxConstraints(
maxWidth: widget.maxWidth ?? double.infinity,
),
child: PostItem(data: _posts[idx]),
).center(),
onTap: () { onTap: () {
GoRouter.of(context).pushNamed( GoRouter.of(context).pushNamed(
'postDetail', 'postDetail',
@ -132,7 +121,6 @@ class _PostCommentListPopupState extends State<PostCommentListPopup> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ua = context.watch<UserProvider>();
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
return Column( return Column(
@ -151,26 +139,25 @@ class _PostCommentListPopupState extends State<PostCommentListPopup> {
Expanded( Expanded(
child: CustomScrollView( child: CustomScrollView(
slivers: [ slivers: [
if (ua.isAuthorized) SliverToBoxAdapter(
SliverToBoxAdapter( child: Container(
child: Container( height: 240,
height: 240, decoration: BoxDecoration(
decoration: BoxDecoration( border: Border.symmetric(
border: Border.symmetric( horizontal: BorderSide(
horizontal: BorderSide( color: Theme.of(context).dividerColor,
color: Theme.of(context).dividerColor, width: 1 / devicePixelRatio,
width: 1 / devicePixelRatio,
),
), ),
), ),
child: PostMiniEditor( ),
postReplyId: widget.postId, child: PostMiniEditor(
onPost: () { postReplyId: widget.postId,
_childListKey.currentState!.refresh(); onPost: () {
}, _childListKey.currentState!.refresh();
), },
), ),
), ),
),
PostCommentSliverList( PostCommentSliverList(
key: _childListKey, key: _childListKey,
parentPostId: widget.postId, parentPostId: widget.postId,