feat:更新菜谱显示模块
This commit is contained in:
@@ -10,12 +10,23 @@ class RecipeCard extends StatelessWidget {
|
||||
|
||||
const RecipeCard({super.key, required this.recipe});
|
||||
|
||||
void navigatorToRecipeDetail(BuildContext context) {
|
||||
Navigator.pushNamed(context, '/recipeDetail', arguments: {'id': recipe.id});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<String> imageUrls =
|
||||
recipe.recordList
|
||||
.map((item) => '${AppConfig.baseApiUrl}/${item.imageUrl}')
|
||||
.toList();
|
||||
final String firstImageUrl = recipe.recordList.first.imageUrl;
|
||||
|
||||
Widget buildRecipeImage() {
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.5,
|
||||
child: buildNetworkImage(
|
||||
context,
|
||||
'${AppConfig.baseApiUrl}/$firstImageUrl',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRecipeContent(BuildContext context) {
|
||||
return Column(
|
||||
@@ -32,26 +43,6 @@ class RecipeCard extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
circleIconButton(
|
||||
context: context,
|
||||
icon: Icons.edit,
|
||||
onPressed: () => {},
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
circleIconButton(
|
||||
context: context,
|
||||
icon: Icons.book,
|
||||
onPressed:
|
||||
() => Navigator.pushNamed(
|
||||
context,
|
||||
'/recipeDetail',
|
||||
arguments: {'id': recipe.id},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
@@ -105,12 +96,12 @@ class RecipeCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 1.5,
|
||||
child: buildNetworkImage(imageUrls.first),
|
||||
),
|
||||
buildRecipeImage(),
|
||||
SizedBox(height: 8),
|
||||
buildRecipeContent(context),
|
||||
GestureDetector(
|
||||
onTap: () => navigatorToRecipeDetail(context),
|
||||
child: buildRecipeContent(context)
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -120,10 +111,10 @@ class RecipeCard extends StatelessWidget {
|
||||
Widget _buildIconText({
|
||||
required IconData icon,
|
||||
required String text,
|
||||
Color color = Colors.grey, // 默认灰色
|
||||
Color color = Colors.grey,
|
||||
double iconSize = 16,
|
||||
double textSize = 16,
|
||||
double spacing = 2, // 图标与文本间距
|
||||
double spacing = 2,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
@@ -48,19 +48,28 @@ class _RecipeTimeline extends State<RecipeTimeline> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
record.date,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.date_range, color: Theme.of(context).colorScheme.primary),
|
||||
SizedBox(width: 5),
|
||||
Text(
|
||||
record.date,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(record.name, style: TextStyle(fontSize: 16)),
|
||||
Text(
|
||||
record.name,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
GestureDetector(
|
||||
onTap: () => imageTapClick(),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.5,
|
||||
child: buildNetworkImage(imageUrls.first),
|
||||
child: buildNetworkImage(context, imageUrls.first),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user