2024-09-08 20:09:41 +04:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2024-10-16 10:48:22 +04:00
|
|
|
|
// Класс приложения
|
2024-09-08 20:09:41 +04:00
|
|
|
|
void main() {
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
2024-09-18 14:39:19 +04:00
|
|
|
|
@override
|
2024-09-08 20:09:41 +04:00
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return MaterialApp(
|
2024-10-16 10:48:22 +04:00
|
|
|
|
debugShowCheckedModeBanner: false,
|
2024-09-08 20:09:41 +04:00
|
|
|
|
title: 'Flutter Demo',
|
|
|
|
|
theme: ThemeData(
|
2024-10-16 10:48:22 +04:00
|
|
|
|
// Настраиваем цветовую схему приложения
|
2024-09-08 20:09:41 +04:00
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigoAccent),
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
|
|
|
|
home: const MyHomePage(title: 'Валова Анна Дмитриевна'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-16 10:48:22 +04:00
|
|
|
|
// Класс домашней страницы
|
2024-09-08 20:09:41 +04:00
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2024-10-16 10:48:22 +04:00
|
|
|
|
// Список слов и их переводов
|
|
|
|
|
final List<Word> words = [
|
|
|
|
|
Word(word: 'Hello', translation: 'Привет', image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS69a8OWnRueQNykBpuyfbGxl3gt5ct46NOHg&s'),
|
|
|
|
|
Word(word: 'Book', translation: 'Книга', image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSfbH7Ckkbzrr3KZlb144GTaAmJnz87U9opGw&s'),
|
|
|
|
|
Word(word: 'Cat', translation: 'Кот', image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Felis_silvestris_silvestris.jpg'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
int currentIndex = 0;
|
|
|
|
|
|
2024-09-08 20:09:41 +04:00
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
|
|
|
title: Text(widget.title),
|
|
|
|
|
),
|
2024-10-16 10:48:22 +04:00
|
|
|
|
body: Center(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
for (var word in words)
|
|
|
|
|
_Card(
|
|
|
|
|
word: word.word,
|
|
|
|
|
translation: word.translation,
|
|
|
|
|
image: word.image,
|
|
|
|
|
),
|
|
|
|
|
// Кнопки "Знаю" и "Не знаю"
|
|
|
|
|
/* Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
// Кнопка "Знаю"
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
currentIndex++;
|
|
|
|
|
if (currentIndex >= words.length) {
|
|
|
|
|
currentIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Знаю'),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 20),
|
|
|
|
|
// Кнопка "Не знаю"
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// Переходим к предыдущей карточке
|
|
|
|
|
setState(() {
|
|
|
|
|
currentIndex--;
|
|
|
|
|
if (currentIndex < 0) {
|
|
|
|
|
currentIndex = words.length - 1;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Не знаю'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),*/
|
|
|
|
|
],
|
|
|
|
|
),
|
2024-09-08 20:09:41 +04:00
|
|
|
|
),
|
|
|
|
|
),
|
2024-09-25 09:17:26 +04:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-16 10:48:22 +04:00
|
|
|
|
// Класс карточки
|
2024-10-16 11:36:35 +04:00
|
|
|
|
class _Card extends StatefulWidget {
|
2024-09-25 09:17:26 +04:00
|
|
|
|
final String word;
|
|
|
|
|
final String translation;
|
2024-10-16 10:48:22 +04:00
|
|
|
|
final String image;
|
2024-09-25 09:17:26 +04:00
|
|
|
|
|
2024-10-16 10:48:22 +04:00
|
|
|
|
const _Card({
|
|
|
|
|
required this.word,
|
2024-09-25 09:17:26 +04:00
|
|
|
|
required this.translation,
|
2024-10-16 10:48:22 +04:00
|
|
|
|
required this.image,
|
2024-09-25 09:17:26 +04:00
|
|
|
|
});
|
|
|
|
|
|
2024-10-16 11:36:35 +04:00
|
|
|
|
@override
|
|
|
|
|
State<_Card> createState() => _CardState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CardState extends State<_Card> {
|
|
|
|
|
bool isKnow = false;
|
2024-09-25 09:17:26 +04:00
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
|
margin: const EdgeInsets.all(10),
|
|
|
|
|
decoration: BoxDecoration(
|
2024-10-16 11:36:35 +04:00
|
|
|
|
color: Colors.black12,
|
2024-09-25 09:17:26 +04:00
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
),
|
2024-10-16 11:36:35 +04:00
|
|
|
|
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)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
2024-09-25 09:17:26 +04:00
|
|
|
|
),
|
2024-10-16 11:36:35 +04:00
|
|
|
|
));
|
2024-09-08 20:09:41 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-16 10:48:22 +04:00
|
|
|
|
|
|
|
|
|
// Класс для слов
|
|
|
|
|
class Word {
|
|
|
|
|
final String word;
|
|
|
|
|
final String translation;
|
|
|
|
|
final String image;
|
|
|
|
|
|
|
|
|
|
Word({required this.word, required this.translation, required this.image});
|
|
|
|
|
}
|