import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../cubit/auth_cubit.dart'; import '../cubit/auth_state.dart'; class PhoneScreen extends StatefulWidget { const PhoneScreen({super.key}); @override State createState() => _PhoneScreenState(); } class _PhoneScreenState extends State { final _controller = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Padding( padding: const EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 40), Text('Tripz', style: Theme.of(context).textTheme.headlineMedium), const SizedBox(height: 8), const Text('أدخل رقم هاتفك للمتابعة'), const SizedBox(height: 32), TextField( controller: _controller, keyboardType: TextInputType.phone, decoration: const InputDecoration( labelText: 'رقم الهاتف', hintText: '07XXXXXXXX', ), ), const SizedBox(height: 20), BlocConsumer( listener: (context, state) { if (state.status == AuthStatus.error && state.error != null) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(state.error!)), ); } }, builder: (context, state) { final loading = state.status == AuthStatus.authenticating; return FilledButton( onPressed: loading ? null : () => context.read().sendOtp(_controller.text), child: loading ? const SizedBox( height: 22, width: 22, child: CircularProgressIndicator(strokeWidth: 2), ) : const Text('إرسال الرمز'), ); }, ), ], ), ), ), ); } }