refinements
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
@@ -24,14 +25,18 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
void _submit() async {
|
||||
// Chiudiamo la tastiera per fare pulizia a schermo
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
context.read<AuthCubit>().submitAuth(
|
||||
final isSuccess = await context.read<AuthCubit>().submitAuth(
|
||||
_emailController.text.trim(),
|
||||
_passwordController.text.trim(),
|
||||
);
|
||||
|
||||
if (isSuccess) {
|
||||
TextInput.finishAutofillContext();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -69,125 +74,133 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// --- LOGO FLUX ---
|
||||
const FluxLogoAuto(height: 80),
|
||||
const SizedBox(height: 60),
|
||||
child: AutofillGroup(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// --- LOGO FLUX ---
|
||||
const FluxLogoAuto(height: 80),
|
||||
const SizedBox(height: 60),
|
||||
|
||||
// --- TITOLO DINAMICO ---
|
||||
Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenWelcomeBack
|
||||
: context.l10n.authScreenCreateAccount,
|
||||
style: TextStyle(
|
||||
color: context.primaryText,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: 1.5,
|
||||
// --- TITOLO DINAMICO ---
|
||||
Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenWelcomeBack
|
||||
: context.l10n.authScreenCreateAccount,
|
||||
style: TextStyle(
|
||||
color: context.primaryText,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenLoginToManageYourBusiness
|
||||
: context
|
||||
.l10n
|
||||
.authScreenStartTodayToDigitalizeYourStore,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: context.secondaryText),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenLoginToManageYourBusiness
|
||||
: context
|
||||
.l10n
|
||||
.authScreenStartTodayToDigitalizeYourStore,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: context.secondaryText),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// --- CAMPI INPUT ---
|
||||
FluxTextField(
|
||||
label: context.l10n.authScreenBusinessEmail,
|
||||
icon: Icons.email_outlined,
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FluxTextField(
|
||||
label: 'Password',
|
||||
icon: Icons.lock_outline,
|
||||
isPassword: true, // Magia del FluxTextField!
|
||||
controller: _passwordController,
|
||||
onSubmitted: (_) =>
|
||||
_submit(), // Se lo supporti nel tuo widget custom
|
||||
),
|
||||
// --- CAMPI INPUT ---
|
||||
FluxTextField(
|
||||
label: context.l10n.authScreenBusinessEmail,
|
||||
icon: Icons.email_outlined,
|
||||
controller: _emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autofillHints: const [
|
||||
AutofillHints.email,
|
||||
AutofillHints.username,
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FluxTextField(
|
||||
label: 'Password',
|
||||
icon: Icons.lock_outline,
|
||||
isPassword: true, // Magia del FluxTextField!
|
||||
controller: _passwordController,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
onSubmitted: (_) =>
|
||||
_submit(), // Se lo supporti nel tuo widget custom
|
||||
),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// --- BOTTONE PRINCIPALE ---
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton(
|
||||
onPressed: isLoading ? null : _submit,
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
// --- BOTTONE PRINCIPALE ---
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton(
|
||||
onPressed: isLoading ? null : _submit,
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenLogin
|
||||
: context.l10n.authScreenSignUp,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
state.isLoginMode
|
||||
? context.l10n.authScreenLogin
|
||||
: context.l10n.authScreenSignUp,
|
||||
style: const TextStyle(
|
||||
),
|
||||
),
|
||||
|
||||
// --- SWITCH LOGIN/SIGNUP ---
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () => context.read<AuthCubit>().toggleMode(),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: state.isLoginMode
|
||||
? context.l10n.authScreenDontHaveAccount
|
||||
: context.l10n.authScreenAlreadyHaveAccount,
|
||||
style: TextStyle(color: context.secondaryText),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: state.isLoginMode
|
||||
? context.l10n.authScreenSignUp
|
||||
: context.l10n.authScreenLogin,
|
||||
|
||||
style: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- SWITCH LOGIN/SIGNUP ---
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () => context.read<AuthCubit>().toggleMode(),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: state.isLoginMode
|
||||
? context.l10n.authScreenDontHaveAccount
|
||||
: context.l10n.authScreenAlreadyHaveAccount,
|
||||
style: TextStyle(color: context.secondaryText),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: state.isLoginMode
|
||||
? context.l10n.authScreenSignUp
|
||||
: context.l10n.authScreenLogin,
|
||||
|
||||
style: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.isLoginMode) ...[
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: () => context
|
||||
.read<AuthCubit>()
|
||||
.requestPasswordReset(_emailController.text.trim()),
|
||||
child: Text(
|
||||
context.l10n.authScreenForgotPassword,
|
||||
style: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.isLoginMode) ...[
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
context.read<AuthCubit>().requestPasswordReset(
|
||||
_emailController.text.trim(),
|
||||
),
|
||||
child: Text(
|
||||
context.l10n.authScreenForgotPassword,
|
||||
style: TextStyle(
|
||||
color: context.accent,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user