feat: deploy infrastructure + disk/drive, calendar, presentation, workspaces, onboarding, demo user
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../../core/utils/validators.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
|
||||
class ForgotPasswordScreen extends ConsumerStatefulWidget {
|
||||
const ForgotPasswordScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ForgotPasswordScreen> createState() =>
|
||||
_ForgotPasswordScreenState();
|
||||
}
|
||||
|
||||
class _ForgotPasswordScreenState extends ConsumerState<ForgotPasswordScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailController = TextEditingController();
|
||||
bool _sent = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final authNotifier = ref.read(authProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Восстановление пароля')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 48),
|
||||
const Icon(
|
||||
Icons.lock_reset,
|
||||
size: 64,
|
||||
color: VoIdeaColors.primary,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_sent) ...[
|
||||
Text(
|
||||
'Введите email, привязанный к аккаунту',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
validator: Validators.email,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (authState.error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(
|
||||
authState.error!,
|
||||
style: const TextStyle(color: VoIdeaColors.error),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: authState.status == AuthStatus.loading
|
||||
? null
|
||||
: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
authNotifier
|
||||
.forgotPassword(_emailController.text.trim())
|
||||
.then((_) => setState(() => _sent = true));
|
||||
}
|
||||
},
|
||||
child: const Text('Отправить'),
|
||||
),
|
||||
] else ...[
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
size: 64,
|
||||
color: VoIdeaColors.success,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Письмо отправлено',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Проверьте почту и перейдите по ссылке для сброса пароля',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: () => context.go('/auth/login'),
|
||||
child: const Text('Вернуться ко входу'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/utils/validators.dart';
|
||||
import '../../../core/constants/app_constants.dart';
|
||||
|
||||
class LoginScreen extends ConsumerStatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
bool _obscurePassword = true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final authNotifier = ref.read(authProvider.notifier);
|
||||
|
||||
ref.listen(authProvider, (_, state) {
|
||||
if (state.status == AuthStatus.authenticated) {
|
||||
context.go('/');
|
||||
}
|
||||
if (state.needsTwoFactor) {
|
||||
context.push('/auth/2fa');
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 60),
|
||||
Icon(
|
||||
Icons.lightbulb_outline,
|
||||
size: 64,
|
||||
color: VoIdeaColors.primary,
|
||||
).animate().fadeIn().scale(),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
AppConstants.appName,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: VoIdeaColors.primary,
|
||||
),
|
||||
).animate().fadeIn(delay: 100.ms),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Войдите в аккаунт',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: VoIdeaColors.muted,
|
||||
),
|
||||
).animate().fadeIn(delay: 200.ms),
|
||||
const SizedBox(height: 48),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
validator: Validators.email,
|
||||
).animate().fadeIn(delay: 300.ms).slideX(),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Пароль',
|
||||
prefixIcon: const Icon(Icons.lock_outlined),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility),
|
||||
onPressed: () =>
|
||||
setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
),
|
||||
validator: Validators.password,
|
||||
).animate().fadeIn(delay: 400.ms).slideX(),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () => context.push('/auth/forgot-password'),
|
||||
child: const Text('Забыли пароль?'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (authState.error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(
|
||||
authState.error!,
|
||||
style:
|
||||
const TextStyle(color: VoIdeaColors.error),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: authState.status == AuthStatus.loading
|
||||
? null
|
||||
: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
authNotifier.login(
|
||||
_emailController.text.trim(),
|
||||
_passwordController.text,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: authState.status == AuthStatus.loading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Text('Войти'),
|
||||
).animate().fadeIn(delay: 500.ms),
|
||||
const SizedBox(height: 12),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
_emailController.text = AppConstants.demoEmail;
|
||||
_passwordController.text = AppConstants.demoPassword;
|
||||
authNotifier.login(AppConstants.demoEmail, AppConstants.demoPassword);
|
||||
},
|
||||
icon: const Icon(Icons.play_circle_outline, size: 18),
|
||||
label: const Text('Демо-доступ'),
|
||||
).animate().fadeIn(delay: 550.ms),
|
||||
const SizedBox(height: 12),
|
||||
OutlinedButton(
|
||||
onPressed: () => context.push('/auth/register'),
|
||||
child: const Text('Создать аккаунт'),
|
||||
).animate().fadeIn(delay: 600.ms),
|
||||
const SizedBox(height: 32),
|
||||
const Row(
|
||||
children: [
|
||||
Expanded(child: Divider()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text('или'),
|
||||
),
|
||||
Expanded(child: Divider()),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => _oauthLogin('google'),
|
||||
icon: const Icon(Icons.g_mobiledata),
|
||||
label: const Text('Google'),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () => _oauthLogin('yandex'),
|
||||
icon: const Icon(Icons.cloud),
|
||||
label: const Text('Яндекс'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _oauthLogin(String provider) {
|
||||
ref.read(authProvider.notifier).getOAuthUrl(provider).then((url) {
|
||||
if (url != null && mounted) {
|
||||
context.push('/auth/oauth?provider=$provider&url=$url');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../../core/utils/validators.dart';
|
||||
|
||||
class RegisterScreen extends ConsumerStatefulWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
|
||||
class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
final _confirmController = TextEditingController();
|
||||
bool _obscurePassword = true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
_confirmController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final authNotifier = ref.read(authProvider.notifier);
|
||||
|
||||
ref.listen(authProvider, (_, state) {
|
||||
if (state.status == AuthStatus.authenticated) {
|
||||
context.go('/');
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Регистрация')),
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Имя',
|
||||
prefixIcon: Icon(Icons.person_outline),
|
||||
),
|
||||
validator: (v) => Validators.required(v, 'Имя'),
|
||||
).animate().fadeIn().slideX(),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
validator: Validators.email,
|
||||
).animate().fadeIn(delay: 100.ms).slideX(),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Пароль',
|
||||
prefixIcon: const Icon(Icons.lock_outlined),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility),
|
||||
onPressed: () =>
|
||||
setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
),
|
||||
validator: Validators.password,
|
||||
).animate().fadeIn(delay: 200.ms).slideX(),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _confirmController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Подтвердите пароль',
|
||||
prefixIcon: Icon(Icons.lock_outlined),
|
||||
),
|
||||
validator: (v) =>
|
||||
Validators.confirmPassword(v, _passwordController.text),
|
||||
).animate().fadeIn(delay: 300.ms).slideX(),
|
||||
const SizedBox(height: 32),
|
||||
if (authState.error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(
|
||||
authState.error!,
|
||||
style: const TextStyle(color: Color(0xFFEF4444)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: authState.status == AuthStatus.loading
|
||||
? null
|
||||
: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
authNotifier.register(
|
||||
_emailController.text.trim(),
|
||||
_passwordController.text,
|
||||
_nameController.text.trim(),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: authState.status == AuthStatus.loading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Text('Зарегистрироваться'),
|
||||
).animate().fadeIn(delay: 400.ms),
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: const Text('Уже есть аккаунт? Войти'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../../core/utils/validators.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
|
||||
class ResetPasswordScreen extends ConsumerStatefulWidget {
|
||||
const ResetPasswordScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ResetPasswordScreen> createState() =>
|
||||
_ResetPasswordScreenState();
|
||||
}
|
||||
|
||||
class _ResetPasswordScreenState extends ConsumerState<ResetPasswordScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _tokenController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
final _confirmController = TextEditingController();
|
||||
bool _success = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tokenController.dispose();
|
||||
_passwordController.dispose();
|
||||
_confirmController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final authNotifier = ref.read(authProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Новый пароль')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 48),
|
||||
const Icon(
|
||||
Icons.lock_reset,
|
||||
size: 64,
|
||||
color: VoIdeaColors.primary,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_success) ...[
|
||||
Text(
|
||||
'Введите код из письма и новый пароль',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
TextFormField(
|
||||
controller: _tokenController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Код из письма',
|
||||
prefixIcon: Icon(Icons.vpn_key_outlined),
|
||||
),
|
||||
validator: (v) => Validators.required(v, 'Код'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Новый пароль',
|
||||
prefixIcon: Icon(Icons.lock_outlined),
|
||||
),
|
||||
validator: Validators.password,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _confirmController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Подтвердите пароль',
|
||||
prefixIcon: Icon(Icons.lock_outlined),
|
||||
),
|
||||
validator: (v) =>
|
||||
Validators.confirmPassword(v, _passwordController.text),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (authState.error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(
|
||||
authState.error!,
|
||||
style: const TextStyle(color: VoIdeaColors.error),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: authState.status == AuthStatus.loading
|
||||
? null
|
||||
: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
authNotifier
|
||||
.resetPassword(
|
||||
_tokenController.text.trim(),
|
||||
_passwordController.text,
|
||||
)
|
||||
.then((_) => setState(() => _success = true));
|
||||
}
|
||||
},
|
||||
child: const Text('Сохранить'),
|
||||
),
|
||||
] else ...[
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
size: 64,
|
||||
color: VoIdeaColors.success,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Пароль изменён',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: () => context.go('/auth/login'),
|
||||
child: const Text('Войти'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
|
||||
class TwoFactorScreen extends ConsumerStatefulWidget {
|
||||
const TwoFactorScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<TwoFactorScreen> createState() => _TwoFactorScreenState();
|
||||
}
|
||||
|
||||
class _TwoFactorScreenState extends ConsumerState<TwoFactorScreen> {
|
||||
final _codeController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_codeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final authNotifier = ref.read(authProvider.notifier);
|
||||
|
||||
ref.listen(authProvider, (_, state) {
|
||||
if (state.status == AuthStatus.authenticated) {
|
||||
context.go('/');
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Двухфакторная аутентификация')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 48),
|
||||
const Icon(
|
||||
Icons.security,
|
||||
size: 64,
|
||||
color: VoIdeaColors.primary,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Введите код из приложения аутентификации',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
TextField(
|
||||
controller: _codeController,
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(
|
||||
hintText: '000000',
|
||||
counterText: '',
|
||||
helperText: '6-значный код',
|
||||
),
|
||||
maxLength: 6,
|
||||
style: const TextStyle(fontSize: 32, letterSpacing: 8),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
if (authState.error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Text(
|
||||
authState.error!,
|
||||
style: const TextStyle(color: VoIdeaColors.error),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: authState.status == AuthStatus.loading
|
||||
? null
|
||||
: () {
|
||||
if (_codeController.text.length == 6) {
|
||||
authNotifier.verifyTwoFactor(_codeController.text);
|
||||
}
|
||||
},
|
||||
child: authState.status == AuthStatus.loading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Text('Подтвердить'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
authNotifier.logout();
|
||||
context.go('/auth/login');
|
||||
},
|
||||
child: const Text('Назад ко входу'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user