Files
be_happy_public/lib/presentation/screens/card_binding_result_screen.dart
2026-07-13 01:38:13 +03:00

174 lines
5.6 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../components/gradient_button.dart';
enum CardBindingStatus { success, failed }
class CardBindingResultScreen extends StatefulWidget {
final CardBindingStatus status;
final String title;
final String cardImagePath;
const CardBindingResultScreen({
super.key,
required this.status,
required this.title,
required this.cardImagePath,
});
@override
State<CardBindingResultScreen> createState() => _CardBindingResultScreenState();
}
class _CardBindingResultScreenState extends State<CardBindingResultScreen> {
Timer? _autoPopTimer;
@override
void initState() {
super.initState();
if (widget.status == CardBindingStatus.success) {
_autoPopTimer = Timer(const Duration(seconds: 5), () {
if (mounted) {
final timestamp = DateTime.now().millisecondsSinceEpoch;
context.go("/home/payment-methods?refreshId=$timestamp");
}
});
}
}
@override
void dispose() {
_autoPopTimer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
final isSuccess = widget.status == CardBindingStatus.success;
return Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF1B284F),
Color(0xFF0F172A),
],
),
),
child: SafeArea(
child: Stack(
children: [
// Positioned(
// bottom: 50,
// left: 0,
// right: 0,
// child: Image.asset(
// 'assets/wave.png',
// fit: BoxFit.cover,
// ),
// ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// const Spacer(),
Text(
widget.title,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 40),
Image.asset(
isSuccess
? 'assets/icons/success.png'
: 'assets/icons/failed.png',
width: 140,
height: 140,
),
const SizedBox(height: 40),
if (isSuccess) ...[
Padding(
padding: const EdgeInsets.only(bottom: 40.0),
// child: Image.asset(
// widget.cardImagePath,
// width: double.infinity,
// fit: BoxFit.contain,
// ),
),
] else ...[
const Text(
'Проверьте подключение к\nинтернету и попробуйте снова',
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF94A3B8),
fontSize: 16,
height: 1.4,
),
),
const SizedBox(height: 40),
GradientButton(
text: "Попробовать снова",
onTap: () {
final timestamp = DateTime.now().millisecondsSinceEpoch;
context.go("/home/payment-methods?refreshId=$timestamp");
},
enabled: true,
showArrows: true,
),
const SizedBox(height: 12),
SizedBox(
width: double.infinity,
height: 56,
child: TextButton(
onPressed: ()
{
final timestamp = DateTime.now().millisecondsSinceEpoch;
context.go("/home/payment-methods?refreshId=$timestamp");
},
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(28),
),
backgroundColor: const Color(0xFF0F172A).withOpacity(0.4),
),
child: const Text(
'Закрыть',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
],
],
),
),
],
),
),
),
);
}
}