62 lines
1.8 KiB
Dart
62 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_samples/logics/entities/page/poetry.dart';
|
|
import 'package:flutter_samples/main.dart';
|
|
|
|
typedef ClickCallback = void Function();
|
|
|
|
class Poetrycard extends StatelessWidget {
|
|
final Poetry poetry;
|
|
final ClickCallback? onClick;
|
|
const Poetrycard({super.key, required this.poetry, this.onClick});
|
|
|
|
void _tapPoetry() {
|
|
onClick?.call();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
|
|
decoration: BoxDecoration(
|
|
color: $styles.colors.white,
|
|
border: Border(
|
|
bottom: BorderSide(color: $styles.colors.borderColor, width: 0.5),
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
poetry.authorAvatar.isNotEmpty
|
|
? CircleAvatar(
|
|
backgroundColor: $styles.colors.bgColor,
|
|
backgroundImage: NetworkImage(poetry.authorAvatar),
|
|
radius: 20,
|
|
)
|
|
: CircleAvatar(
|
|
backgroundColor: $styles.colors.bgColor,
|
|
radius: 20,
|
|
child: const Icon(Icons.person, color: Colors.white),
|
|
),
|
|
SizedBox(width: 10),
|
|
Text(poetry.authorName, style: $styles.normalText),
|
|
],
|
|
),
|
|
GestureDetector(
|
|
onTap: _tapPoetry,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 10),
|
|
Text(poetry.title, style: $styles.grayText),
|
|
SizedBox(height: 10),
|
|
Text(poetry.content, style: $styles.normalText),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|