process 4 lab
This commit is contained in:
parent
56cc6deabc
commit
491b5b3d26
@ -101,7 +101,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
}
|
||||
|
||||
// Класс карточки
|
||||
class _Card extends StatelessWidget {
|
||||
class _Card extends StatefulWidget {
|
||||
final String word;
|
||||
final String translation;
|
||||
final String image;
|
||||
@ -112,30 +112,63 @@ class _Card extends StatelessWidget {
|
||||
required this.image,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_Card> createState() => _CardState();
|
||||
}
|
||||
|
||||
class _CardState extends State<_Card> {
|
||||
bool isKnow = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
margin: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: word == "Cat" ? Colors.greenAccent : Colors.indigoAccent ,
|
||||
color: Colors.black12,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.network(image, width: 300),
|
||||
Text(
|
||||
word,
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
children: [
|
||||
Image.network(widget.image, width: 300),
|
||||
Text(
|
||||
widget.word,
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
),
|
||||
// Перевод слова
|
||||
Text(
|
||||
widget.translation,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isKnow = !isKnow;
|
||||
});
|
||||
},
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: isKnow
|
||||
? const Icon(
|
||||
Icons.check_circle,
|
||||
color: Colors.green,
|
||||
key: ValueKey(0))
|
||||
: const Icon(
|
||||
Icons.check_circle_outline,
|
||||
key: ValueKey(1)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
// Перевод слова
|
||||
Text(
|
||||
translation,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user