♻️ Apply new OpenablePostItem to almost everywhere

This commit is contained in:
2025-02-08 13:58:35 +08:00
parent 74882116e3
commit 2d5b3b554e
4 changed files with 89 additions and 65 deletions

View File

@ -134,7 +134,7 @@ class _PostSearchScreenState extends State<PostSearchScreen> {
body: Stack(
children: [
InfiniteList(
padding: const EdgeInsets.only(top: 100),
padding: const EdgeInsets.only(top: 100 + 8),
itemCount: _posts.length,
isLoading: _isBusy,
hasReachedMax: _postCount != null && _posts.length >= _postCount!,
@ -142,27 +142,18 @@ class _PostSearchScreenState extends State<PostSearchScreen> {
_fetchPosts();
},
itemBuilder: (context, idx) {
return 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],
);
return OpenablePostItem(
data: _posts[idx],
maxWidth: 640,
onChanged: (data) {
setState(() => _posts[idx] = data);
},
onDeleted: () {
_refreshPosts();
},
);
},
separatorBuilder: (context, index) => const Divider(height: 1),
separatorBuilder: (_, __) => const Gap(8),
),
Positioned(
top: 16,

View File

@ -287,8 +287,8 @@ class _PostPublisherScreenState extends State<PostPublisherScreen> with SingleTi
Theme(
data: Theme.of(context).copyWith(
appBarTheme: Theme.of(context).appBarTheme.copyWith(
foregroundColor: Colors.white,
),
foregroundColor: Colors.white,
),
),
child: SliverAppBar(
expandedHeight: _appBarHeight,
@ -597,25 +597,16 @@ class _PublisherPostList extends StatelessWidget {
hasReachedMax: postCount != null && posts.length >= postCount!,
onFetchData: fetchPosts,
itemBuilder: (context, idx) {
return GestureDetector(
child: PostItem(
data: posts[idx],
maxWidth: 640,
onChanged: (data) {
onChanged(idx, data);
},
onDeleted: onDeleted,
),
onTap: () {
GoRouter.of(context).pushNamed(
'postDetail',
pathParameters: {'slug': posts[idx].id.toString()},
extra: posts[idx],
);
return OpenablePostItem(
data: posts[idx],
maxWidth: 640,
onChanged: (data) {
onChanged(idx, data);
},
onDeleted: onDeleted,
);
},
separatorBuilder: (context, index) => const Divider(height: 1),
separatorBuilder: (_, __) => const Gap(8),
);
}
}