// lib/presentation/pages/user_info_page.dart import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:proxibuy/presentation/auth/bloc/auth_bloc.dart'; import 'package:proxibuy/presentation/pages/notification_preferences_page.dart'; import '../../core/config/app_colors.dart'; import '../../core/gen/assets.gen.dart'; import 'offers_page.dart'; // صفحه اصلی بعد از ورود class UserInfoPage extends StatefulWidget { const UserInfoPage({super.key}); @override State createState() => _UserInfoPageState(); } class _UserInfoPageState extends State { final _nameController = TextEditingController(); String _selectedGender = 'مرد'; // مقدار پیش‌فرض @override void dispose() { _nameController.dispose(); super.dispose(); } // ویجت برای ساخت دکمه‌های رادیویی جنسیت Widget _buildGenderRadio(String title, String value) { return InkWell( onTap: () => setState(() => _selectedGender = value), child: Row( mainAxisSize: MainAxisSize.min, children: [ Radio( value: value, groupValue: _selectedGender, onChanged: (newValue) => setState(() => _selectedGender = newValue!), activeColor: AppColors.active, ), Text(title, style: const TextStyle(color: Colors.grey)), ], ), ); } @override Widget build(BuildContext context) { final textTheme = Theme.of(context).textTheme; return Scaffold( body: Stack( children: [ // لایه پس‌زمینه: عکس Positioned.fill( child: Image.asset( Assets.images.userinfo.path, // یک عکس پس‌زمینه دلخواه fit: BoxFit.cover, ), ), // لایه رویی: باتم شیت ثابت DraggableScrollableSheet( initialChildSize: 0.50, // ارتفاع اولیه باتم شیت (۶۵٪ صفحه) minChildSize: 0.50, // حداقل ارتفاع maxChildSize: 0.50, // حداکثر ارتفاع هنگام اسکرول builder: (context, scrollController) { return Container( decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(32)), ), child: SingleChildScrollView( controller: scrollController, padding: const EdgeInsets.all(24.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Container( width: 50, height: 5, decoration: BoxDecoration( color: AppColors.grey.withOpacity(0.5), borderRadius: BorderRadius.circular(12), ), ), ), SizedBox(height: 40), // فیلد نام و نام خانوادگی TextField( controller: _nameController, decoration: const InputDecoration( labelText: "دوست داری با چه اسمی صدات کنیم؟", labelStyle: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), hintText: "مثلا نام کوچک شما", hintStyle: TextStyle( fontSize: 15, color: Colors.grey ) ), ), const SizedBox(height: 24), // بخش انتخاب جنسیت Text( "جنسیت", style: textTheme.titleMedium?.copyWith( color: Colors.black, ), ), const SizedBox(height: 8), Wrap( spacing: 10.0, runSpacing: 8.0, children: [ _buildGenderRadio('مرد', 'مرد'), _buildGenderRadio('زن', 'زن'), _buildGenderRadio('تمایلی به پاسخ ندارم', 'تمایلی به پاسخ ندارم'), ], ), const SizedBox(height: 70), // دکمه ادامه BlocConsumer( listener: (context, state) { if (state is UserInfoUpdateSuccess) { Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (_) => const OffersPage()), (route) => false, ); } else if (state is AuthFailure) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(state.message), backgroundColor: Colors.red) ); } }, builder: (context, state) { if (state is AuthLoading) { return const Center(child: CircularProgressIndicator()); } return SizedBox( width: double.infinity, child: ElevatedButton( // ۱. تغییر رنگ دکمه به سبز style: ElevatedButton.styleFrom( backgroundColor: AppColors.confirm, ), onPressed: () { context.read().add(UpdateUserInfoEvent( name: _nameController.text, gender: _selectedGender, )); }, child: const Text("اعمال"), ), ); }, ), const SizedBox(height: 9), // ۲. افزودن دکمه رد کردن Center( child: TextButton( onPressed: () { Navigator.of(context).push(NotificationPreferencesPage.route()); }, child: const Text( "رد شدن", style: TextStyle(color: Colors.black), ), ), ), ], ), ), ); }, ), ], ), ); } }