mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 03:15:14 +08:00
feat: article list
Closes #841 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
113
lib/pages/article_list/widgets/item.dart
Normal file
113
lib/pages/article_list/widgets/item.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_list/article.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ArticleListItem extends StatelessWidget {
|
||||
const ArticleListItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
|
||||
final Article item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
final dynIdStr = item.dynIdStr;
|
||||
Get.toNamed(
|
||||
'/articlePage',
|
||||
parameters: {
|
||||
'id': dynIdStr ?? item.id!.toString(),
|
||||
'type': dynIdStr != null ? 'opus' : 'read',
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title!,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
height: 1.42,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
if (item.summary != null)
|
||||
Text(
|
||||
item.summary!,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
context: context,
|
||||
value: item.stats?.view ?? 0,
|
||||
goto: 'picture',
|
||||
textColor: theme.colorScheme.outline,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
StatView(
|
||||
context: context,
|
||||
goto: 'like',
|
||||
value: item.stats?.like ?? 0,
|
||||
textColor: theme.colorScheme.outline,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
StatView(
|
||||
context: context,
|
||||
goto: 'reply',
|
||||
value: item.stats?.reply ?? 0,
|
||||
textColor: theme.colorScheme.outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (item.imageUrls?.isNotEmpty == true) ...[
|
||||
const SizedBox(width: 10),
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, boxConstraints) {
|
||||
return NetworkImgLayer(
|
||||
src: item.imageUrls!.first,
|
||||
width: boxConstraints.maxWidth,
|
||||
height: boxConstraints.maxHeight,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user