2024-06-16 19:01:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:mnemo_cards/di/locator.dart';
|
|
|
|
|
import 'package:mnemo_cards/theme/themes.dart';
|
|
|
|
|
import 'package:mnemo_cards/widgets/simple_tile.dart';
|
|
|
|
|
|
|
|
|
|
class EnterPromoCodeWidget extends StatefulWidget {
|
|
|
|
|
const EnterPromoCodeWidget();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<StatefulWidget> createState() => _EnterPromoCodeState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _EnterPromoCodeState extends State<EnterPromoCodeWidget> {
|
|
|
|
|
final TextEditingController controller = TextEditingController();
|
|
|
|
|
|
|
|
|
|
String? message;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
SimpleTile(
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text('Промокод'),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 16.w,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: TextField(
|
|
|
|
|
// cursorHeight: 17.h,
|
|
|
|
|
controller: controller,
|
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
|
style: TextStyle(fontSize: 17.sp),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
contentPadding: EdgeInsets.all(8.0),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 8.w,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
trail: GestureDetector(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final result = await locator.userManager.applyPromocode(
|
|
|
|
|
controller.text,
|
|
|
|
|
);
|
|
|
|
|
if (result.success == true) {
|
|
|
|
|
controller.clear();
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
message = result.message;
|
|
|
|
|
});
|
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
|
},
|
|
|
|
|
child: AspectRatio(
|
|
|
|
|
aspectRatio: 1.0,
|
|
|
|
|
child: Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: progressBlue,
|
|
|
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
|
|
|
),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'icons/gift.png',
|
|
|
|
|
width: 17.w,
|
2024-06-22 12:29:18 +00:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2024-06-16 19:01:33 +00:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (message != null && message!.isNotEmpty)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
|
|
|
child: Text(message!),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|