Five Good
This commit is contained in:
parent
96016dcfe3
commit
bfd46aca31
@ -5,6 +5,7 @@ extension AnimeDataDtoToModel on AnimeDataDto {
|
|||||||
CardData toDomain() => CardData(
|
CardData toDomain() => CardData(
|
||||||
title ?? 'NOT',
|
title ?? 'NOT',
|
||||||
imageUrl: images?.jpg?.image ?? "NONE",
|
imageUrl: images?.jpg?.image ?? "NONE",
|
||||||
description: synopsis ?? "NONE",
|
score ?? 8,
|
||||||
|
description: synopsis == null ? "NONE" : synopsis!.split('\n').sublist(0, synopsis!.split('\n').length - 1).join('\n'),
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -8,10 +8,12 @@ class MockRepository extends ApiInterface {
|
|||||||
return [
|
return [
|
||||||
const CardData(
|
const CardData(
|
||||||
"First",
|
"First",
|
||||||
|
5,
|
||||||
description: "SomeText",
|
description: "SomeText",
|
||||||
),
|
),
|
||||||
const CardData(
|
const CardData(
|
||||||
"Second",
|
"Second",
|
||||||
|
8,
|
||||||
icon: Icons.gamepad,
|
icon: Icons.gamepad,
|
||||||
description: "ManyText",
|
description: "ManyText",
|
||||||
imageUrl:
|
imageUrl:
|
||||||
@ -19,6 +21,7 @@ class MockRepository extends ApiInterface {
|
|||||||
),
|
),
|
||||||
const CardData(
|
const CardData(
|
||||||
"Third",
|
"Third",
|
||||||
|
9,
|
||||||
icon: Icons.offline_bolt_outlined,
|
icon: Icons.offline_bolt_outlined,
|
||||||
description: "Wow >_<",
|
description: "Wow >_<",
|
||||||
),
|
),
|
||||||
|
@ -10,26 +10,28 @@ class DetailsPage extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: Column(
|
body: SingleChildScrollView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Padding(
|
children: [
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
Padding(
|
||||||
child: Image.network(
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
data.imageUrl ?? '',
|
child: Image.network(
|
||||||
|
data.imageUrl,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(bottom: 4),
|
||||||
padding: const EdgeInsets.only(bottom: 4),
|
child: Text(
|
||||||
child: Text(
|
data.text,
|
||||||
data.text,
|
style: Theme.of(context).textTheme.headlineLarge,
|
||||||
style: Theme.of(context).textTheme.headlineLarge,
|
)),
|
||||||
)),
|
Text(
|
||||||
Text(
|
data.description,
|
||||||
data.description,
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:first_project/presentation/home_page/home_page.dart';
|
import 'package:first_project/presentation/home_page/home_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -22,3 +20,4 @@ class MyApp extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,12 @@ class CardData {
|
|||||||
final String text;
|
final String text;
|
||||||
final String description;
|
final String description;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
final double score;
|
||||||
final String imageUrl;
|
final String imageUrl;
|
||||||
|
|
||||||
const CardData(
|
const CardData(
|
||||||
this.text, {
|
this.text,
|
||||||
|
this.score, {
|
||||||
required this.description,
|
required this.description,
|
||||||
this.icon = Icons.add_call,
|
this.icon = Icons.add_call,
|
||||||
this.imageUrl =
|
this.imageUrl =
|
||||||
@ -21,6 +23,7 @@ class _Card extends StatefulWidget {
|
|||||||
final String text;
|
final String text;
|
||||||
final String description;
|
final String description;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
|
final double score;
|
||||||
final OnLikeCallback onLike;
|
final OnLikeCallback onLike;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
@ -28,6 +31,7 @@ class _Card extends StatefulWidget {
|
|||||||
this.text, {
|
this.text, {
|
||||||
required this.description,
|
required this.description,
|
||||||
required this.imageUrl,
|
required this.imageUrl,
|
||||||
|
required this.score,
|
||||||
this.onLike,
|
this.onLike,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
@ -41,6 +45,7 @@ class _Card extends StatefulWidget {
|
|||||||
data.text,
|
data.text,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
imageUrl: data.imageUrl,
|
imageUrl: data.imageUrl,
|
||||||
|
score: data.score,
|
||||||
onLike: onLike,
|
onLike: onLike,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
);
|
);
|
||||||
@ -54,6 +59,8 @@ class _CardState extends State<_Card> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
List<String> desc = widget.description.split("\n");
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: widget.onTap,
|
onTap: widget.onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -82,7 +89,7 @@ class _CardState extends State<_Card> {
|
|||||||
topLeft: Radius.circular(18),
|
topLeft: Radius.circular(18),
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: double.infinity,
|
height: 300,
|
||||||
width: 120,
|
width: 120,
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
widget.imageUrl ?? '',
|
widget.imageUrl ?? '',
|
||||||
@ -100,7 +107,7 @@ class _CardState extends State<_Card> {
|
|||||||
topRight: Radius.circular(20),
|
topRight: Radius.circular(20),
|
||||||
bottomLeft: Radius.circular(18))),
|
bottomLeft: Radius.circular(18))),
|
||||||
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
||||||
child: Text('Новинка',
|
child: Text(generateStars(widget.score),
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodyMedium
|
.bodyMedium
|
||||||
@ -117,10 +124,10 @@ class _CardState extends State<_Card> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
widget.text,
|
widget.text,
|
||||||
style: Theme.of(context).textTheme.headlineLarge,
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
widget.description,
|
desc[0],
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -162,3 +169,16 @@ class _CardState extends State<_Card> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String generateStars(double rating) {
|
||||||
|
rating = rating / 2;
|
||||||
|
int fullStars = rating.floor();
|
||||||
|
bool hasHalfStar = (rating - fullStars) >= 0.5;
|
||||||
|
String stars = '★' * fullStars;
|
||||||
|
if (hasHalfStar) {
|
||||||
|
stars += '✪';
|
||||||
|
}
|
||||||
|
int emptyStars = 5 - stars.length;
|
||||||
|
stars += '☆' * emptyStars;
|
||||||
|
return stars;
|
||||||
|
}
|
||||||
|
12
pubspec.lock
12
pubspec.lock
@ -138,10 +138,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: code_builder
|
name: code_builder
|
||||||
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
|
sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.10.0"
|
version: "4.10.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -348,10 +348,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: logging
|
name: logging
|
||||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
macros:
|
macros:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -545,10 +545,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.4.0"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
Loading…
Reference in New Issue
Block a user