78 lines
2.3 KiB
Dart
78 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:driver/core/l10n/app_localizations.dart';
|
|
import '../cubit/auth_cubit.dart';
|
|
import '../cubit/auth_state.dart';
|
|
import '../../../core/ui/tripz_scaffold.dart';
|
|
import '../../../core/ui/tripz_button.dart';
|
|
import '../../../core/ui/tripz_text_field.dart';
|
|
|
|
class PhoneScreen extends StatefulWidget {
|
|
const PhoneScreen({super.key});
|
|
@override
|
|
State<PhoneScreen> createState() => _PhoneScreenState();
|
|
}
|
|
|
|
class _PhoneScreenState extends State<PhoneScreen> {
|
|
final _controller = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
return TripzScaffold(
|
|
safeAreaTop: true,
|
|
padding: true,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Spacer(flex: 2),
|
|
Text(
|
|
l10n.appName,
|
|
style: Theme.of(context).textTheme.headlineLarge,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
l10n.phoneTitle,
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const Spacer(),
|
|
TripzTextField(
|
|
controller: _controller,
|
|
label: l10n.phoneLabel,
|
|
hint: l10n.phoneHint,
|
|
keyboardType: TextInputType.phone,
|
|
),
|
|
const SizedBox(height: 20),
|
|
BlocConsumer<AuthCubit, AuthState>(
|
|
listener: (context, state) {
|
|
if (state.status == AuthStatus.error && state.error != null) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(state.error!)),
|
|
);
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return TripzButton(
|
|
label: l10n.sendCode,
|
|
loading: state.status == AuthStatus.authenticating,
|
|
onPressed: () =>
|
|
context.read<AuthCubit>().sendOtp(_controller.text),
|
|
);
|
|
},
|
|
),
|
|
const Spacer(flex: 2),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|