import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
bool isClicked = false;
bool secretMode = false;
void toggleTheme() {
setState(() {
isClicked = !isClicked;
});
}
void toggleSecretMode() {
setState(() {
secretMode = !secretMode;
});
}
@override
Widget build(BuildContext context) {
final textColor = isClicked ? Colors.white : Colors.black;
return Scaffold(
appBar: AppBar(
title: Text(secretMode ? '😎 Секретный режим' : 'Базовые UI элементы'),
centerTitle: true,
backgroundColor:
secretMode ? Colors.pink : (isClicked ? Colors.deepPurple : Colors.blue),
),
body: AnimatedContainer(
duration: const Duration(milliseconds: 500),
decoration: BoxDecoration(
color: secretMode
? null
: (isClicked ? Colors.black : Colors.white),
gradient: secretMode
? const LinearGradient(
colors: [Colors.pink, Colors.orange, Colors.purple],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
)
: null,
),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
secretMode
? 'Ты нашёл пасхалку 🎉'
: isClicked
? 'Кнопка нажата'
: 'Нажми кнопку',
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: secretMode ? Colors.white : textColor,
),
),
const SizedBox(height: 16),
// АНИМАЦИЯ (пульс)
AnimatedContainer(
duration: const Duration(milliseconds: 800),
width: secretMode ? 120 : 60,
height: secretMode ? 120 : 60,
decoration: BoxDecoration(
color: secretMode ? Colors.white.withAlpha(80) : Colors.grey,
shape: BoxShape.circle,
),
),
const SizedBox(height: 24),
// КНОПКИ
GestureDetector(
onLongPress: toggleSecretMode,
child: ElevatedButton(
onPressed: toggleTheme,
child: const Text('Нажми меня'),
),
),
const SizedBox(height: 8),
const Text(
'Подсказка: попробуй долго нажать 😉',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
),
),
);
}
}
