осталось сделать поиск
This commit is contained in:
parent
9ae72e9613
commit
1c7eb9525f
@ -6,12 +6,15 @@ const _imagePlaceholder =
|
||||
'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png';
|
||||
|
||||
extension CharacterDataDtoMapper on CharacterDataDto {
|
||||
CardData toDomain() => CardData(
|
||||
name ?? 'UNKNOWN',
|
||||
imageUrl: image ?? _imagePlaceholder,
|
||||
descriptionText: '',
|
||||
id: id,
|
||||
);
|
||||
CardData toDomain() {
|
||||
final cardData = CardData(
|
||||
name ?? 'UNKNOWN',
|
||||
imageUrl: image ?? _imagePlaceholder,
|
||||
descriptionText: description ?? '',
|
||||
id: id ?? '',
|
||||
);
|
||||
return cardData;
|
||||
}
|
||||
}
|
||||
|
||||
extension CharactersDtoToModel on CharactersDto {
|
||||
|
@ -11,7 +11,8 @@ class CardData {
|
||||
this.text, {
|
||||
this.icon = Icons.bookmark_border,
|
||||
required this.descriptionText,
|
||||
this.imageUrl,
|
||||
this.id,
|
||||
});
|
||||
required this.imageUrl,
|
||||
required this.id,
|
||||
}) {
|
||||
}
|
||||
}
|
@ -12,8 +12,7 @@ class DetailsPage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -25,7 +24,7 @@ class DetailsPage extends StatelessWidget {
|
||||
data.imageUrl ?? '',
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: 400.0,
|
||||
height: 300.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -36,11 +35,15 @@ class DetailsPage extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
data.descriptionText,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
fontSize: 25.0,
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Text(
|
||||
data.descriptionText,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
fontSize: 22.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
@ -4,7 +4,6 @@ typedef OnLikeCallback = void Function(String? id, String title, bool isLiked)?;
|
||||
|
||||
class _Card extends StatelessWidget {
|
||||
final String text;
|
||||
final String descriptionText;
|
||||
final String? imageUrl;
|
||||
final OnLikeCallback onLike;
|
||||
final VoidCallback? onTap;
|
||||
@ -13,7 +12,6 @@ class _Card extends StatelessWidget {
|
||||
|
||||
const _Card(
|
||||
this.text, {
|
||||
required this.descriptionText,
|
||||
this.imageUrl,
|
||||
this.onLike,
|
||||
this.onTap,
|
||||
@ -29,7 +27,6 @@ class _Card extends StatelessWidget {
|
||||
}) =>
|
||||
_Card(
|
||||
data.text,
|
||||
descriptionText: data.descriptionText,
|
||||
imageUrl: data.imageUrl,
|
||||
onLike: onLike,
|
||||
onTap: onTap,
|
||||
@ -56,74 +53,59 @@ class _Card extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(20),
|
||||
topLeft: Radius.circular(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 220,
|
||||
width: double.infinity,
|
||||
child: Image.network(
|
||||
imageUrl ?? '',
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: double.infinity,
|
||||
width: 120,
|
||||
child: Stack(
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.network(
|
||||
imageUrl ?? '',
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => onLike?.call(id, text, isLiked),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: isLiked
|
||||
? const Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.redAccent,
|
||||
key: ValueKey<int>(0),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.favorite_border,
|
||||
key: ValueKey<int>(1),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
Text(
|
||||
descriptionText,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 8, right: 16, bottom: 16),
|
||||
child: GestureDetector(
|
||||
onTap: () => onLike?.call(id, text, isLiked),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: isLiked
|
||||
? const Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.redAccent,
|
||||
key: ValueKey<int>(0),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.favorite_border,
|
||||
key: ValueKey<int>(1),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user