From ed7981fdafb0b2b206122284928f3ba4055f8d2d Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 19 Jan 2025 17:20:24 +0800 Subject: [PATCH] :test_tube: Post max width --- lib/screens/explore.dart | 57 +++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index d2adeda..6643d2a 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -217,27 +217,48 @@ class _ExploreScreenState extends State { hasReachedMax: _postCount != null && _posts.length >= _postCount!, onFetchData: _fetchPosts, itemBuilder: (context, idx) { - return GestureDetector( - child: PostItem( - data: _posts[idx], - maxWidth: 640, - onChanged: (data) { - setState(() => _posts[idx] = data); - }, - onDeleted: () { - _refreshPosts(); - }, + return Center( + child: Container( + decoration: BoxDecoration( + border: Border( + left: BorderSide( + color: Theme.of(context).dividerColor, + width: 1 / MediaQuery.of(context).devicePixelRatio, + ), + right: BorderSide( + color: Theme.of(context).dividerColor, + width: 1 / MediaQuery.of(context).devicePixelRatio, + ), + ), + ), + constraints: const BoxConstraints(maxWidth: 640), + child: Column( + children: [ + GestureDetector( + child: PostItem( + data: _posts[idx], + maxWidth: 640, + onChanged: (data) { + setState(() => _posts[idx] = data); + }, + onDeleted: () { + _refreshPosts(); + }, + ), + onTap: () { + GoRouter.of(context).pushNamed( + 'postDetail', + pathParameters: {'slug': _posts[idx].id.toString()}, + extra: _posts[idx], + ); + }, + ), + const Divider(height: 1), + ], + ), ), - onTap: () { - GoRouter.of(context).pushNamed( - 'postDetail', - pathParameters: {'slug': _posts[idx].id.toString()}, - extra: _posts[idx], - ); - }, ); }, - separatorBuilder: (context, index) => const Divider(height: 1), ), ], ),