Files
be_happy_public/lib/presentation/screens/promo_code_screen.dart
2026-05-12 12:02:40 +03:00

162 lines
6.6 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import '../../core/app_colors.dart';
import '../components/custom_app_bar.dart';
class PromoCodeScreen extends StatefulWidget {
const PromoCodeScreen({super.key});
@override
State<PromoCodeScreen> createState() => _PromoCodeScreenState();
}
class _PromoCodeScreenState extends State<PromoCodeScreen> {
final TextEditingController promoController = TextEditingController();
bool isError = false;
void _activatePromo() {
if (promoController.text == 'G17N160') {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Промокод активирован!')),
);
} else {
setState(() {
isError = true;
});
}
}
void _retry() {
setState(() {
isError = false;
promoController.clear();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: const BoxDecoration(gradient: AppColors.phoneScreenBg),
child: SafeArea(
child: Column(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: [
CustomAppBar(title: 'Промокоды'),
const SizedBox(height: 32),
Container(
padding: const EdgeInsets.all(25),
decoration: BoxDecoration(
color: Color(0xFF141530),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'У вас есть промокод?',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height:24),
const Text(
'Введите промокод и получите скидку на поездку',
style: TextStyle(
color: AppColors.white70,
fontSize: 16,
),
),
const SizedBox(height: 20),
TextField(
controller: promoController,
style: TextStyle(
color: isError ? Colors.red : Colors.white,
),
decoration: InputDecoration(
hintText: 'Введите промокод',
hintStyle: const TextStyle(color: AppColors.white70),
filled: true,
fillColor: Colors.white.withOpacity(0.1),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(color: AppColors.smsDigit, width: 1.5),
),
),
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () => Navigator.pop(context),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
side: BorderSide(color: AppColors.white70.withOpacity(0.4)),
padding: const EdgeInsets.symmetric(vertical: 12),
),
child: const Text(
'Отмена',
style: TextStyle(color: AppColors.white70),
),
),
),
const SizedBox(width: 22),
Expanded(
child: ElevatedButton(
onPressed: _activatePromo,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
backgroundColor: AppColors.activeButtonGradient.colors[0],
padding: const EdgeInsets.symmetric(vertical: 12),
),
child: const Text(
'Активировать',
style: TextStyle(color: AppColors.activeButtonText),
),
),
),
],
),
],
),
),
const Spacer(),
],
),
),
),
Image.asset('assets/promo_bottom.png',
width: double.infinity,
fit: BoxFit.contain,
alignment: Alignment.center,
),
const SizedBox(height: 80),
],
),
),
),
);
}
}