label
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_otp_text_field/flutter_otp_text_field.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
|
||||
|
||||
class OtpAuthScreen extends StatefulWidget {
|
||||
final String phoneNumber;
|
||||
|
||||
const OtpAuthScreen({super.key, required this.phoneNumber});
|
||||
|
||||
@override
|
||||
State<OtpAuthScreen> createState() => _OtpAuthScreenState();
|
||||
}
|
||||
|
||||
class _OtpAuthScreenState extends State<OtpAuthScreen> {
|
||||
bool _isRequestSent = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authBloc = Injector.appInstance.get<AuthBloc>();
|
||||
|
||||
if (!_isRequestSent) {
|
||||
authBloc.add(AuthEventLoginOAuth(phone: widget.phoneNumber));
|
||||
_isRequestSent = true;
|
||||
}
|
||||
|
||||
return BlocProvider<AuthBloc>(
|
||||
create: (context) => authBloc,
|
||||
child: BlocConsumer<AuthBloc, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthStateSuccess) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
if (state is AuthStateVerifyOAuth) {
|
||||
if (state.isWrongCode) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('El Código es incorrecto'),
|
||||
));
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
body: Column(children: [
|
||||
getContent(state, authBloc: authBloc),
|
||||
]),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getContent(AuthState state, {required AuthBloc authBloc}) {
|
||||
if (state is AuthStateInitial) {
|
||||
return const Text('Inicio');
|
||||
} else if (state is AuthStateProcess) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('${widget.phoneNumber} - $_isRequestSent'),
|
||||
OtpTextField(
|
||||
numberOfFields: 6,
|
||||
borderColor: const Color(0xFF512DA8),
|
||||
showFieldAsBox: true,
|
||||
onCodeChanged: (String code) {},
|
||||
onSubmit: (String verificationCode) {
|
||||
authBloc.add(AuthEventVerifyOAuth(code: verificationCode));
|
||||
}, // end onSubmit
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (state is AuthStateVerifyOAuth) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('${widget.phoneNumber} - $_isRequestSent'),
|
||||
state.isWrongCode ? const Text('❌') : const Text(''),
|
||||
OtpTextField(
|
||||
numberOfFields: 6,
|
||||
borderColor: const Color(0xFF512DA8),
|
||||
showFieldAsBox: true,
|
||||
onCodeChanged: (String code) {},
|
||||
onSubmit: (String verificationCode) {
|
||||
authBloc.add(AuthEventVerifyOAuth(code: verificationCode));
|
||||
}, // end onSubmit
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (state is AuthStateSuccess) {
|
||||
return const CircularProgressIndicator();
|
||||
} else if (state is AuthStateFailure) {
|
||||
return const Text('❌');
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,10 @@ class _SignInScreenState extends State<SignInScreen> {
|
||||
hintText: 'Email',
|
||||
obscureText: false,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
prefixIcon: const Icon(CupertinoIcons.mail_solid),
|
||||
prefixIcon: Icon(
|
||||
CupertinoIcons.mail_solid,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
errorMsg: _errorMsg,
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
@@ -72,7 +75,8 @@ class _SignInScreenState extends State<SignInScreen> {
|
||||
hintText: 'Password',
|
||||
obscureText: obscurePassword,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
prefixIcon: const Icon(CupertinoIcons.lock_fill),
|
||||
prefixIcon:
|
||||
Icon(CupertinoIcons.lock_fill, color: Colors.grey[600]),
|
||||
errorMsg: _errorMsg,
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
@@ -93,7 +97,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: Icon(iconPassword),
|
||||
icon: Icon(iconPassword, color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -58,32 +58,32 @@ class _SignScreenState extends State<SignScreen> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
),
|
||||
TabBar(
|
||||
controller: tabController,
|
||||
unselectedLabelColor:
|
||||
Theme.of(context).colorScheme.onBackground,
|
||||
labelColor: Theme.of(context).colorScheme.onBackground,
|
||||
tabs: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: Text(
|
||||
'Inicia sesión',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: Text(
|
||||
'Registrate',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// TabBar(
|
||||
// controller: tabController,
|
||||
// unselectedLabelColor:
|
||||
// Theme.of(context).colorScheme.onBackground,
|
||||
// labelColor: Theme.of(context).colorScheme.onBackground,
|
||||
// tabs: const [
|
||||
// Padding(
|
||||
// padding: EdgeInsets.all(12.0),
|
||||
// child: Text(
|
||||
// 'Inicia sesión',
|
||||
// style: TextStyle(
|
||||
// fontSize: 18,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.all(12.0),
|
||||
// child: Text(
|
||||
// 'Registrate',
|
||||
// style: TextStyle(
|
||||
// fontSize: 18,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -197,8 +197,9 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
child: MyTextField(
|
||||
labelText: 'Nombre',
|
||||
controller: nameController,
|
||||
hintText: 'Name',
|
||||
hintText: 'Ingresa tu nombre',
|
||||
obscureText: false,
|
||||
keyboardType: TextInputType.name,
|
||||
prefixIcon: const Icon(CupertinoIcons.person_fill),
|
||||
@@ -226,7 +227,9 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
||||
|
||||
setState(() {
|
||||
context.read<SignUpBloc>().add(SignUpRequired(
|
||||
myUser, passwordController.text));
|
||||
email: emailController.text,
|
||||
password: passwordController.text,
|
||||
));
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,14 +3,18 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl_phone_field/intl_phone_field.dart';
|
||||
import 'package:prosappco/components/general_input_decoration.dart';
|
||||
import 'package:prosappco/screens/authentication/otp_auth_screen.dart';
|
||||
import 'package:prosappco/screens/authentication/sign_screen.dart';
|
||||
|
||||
class WelcomeScreen extends StatelessWidget {
|
||||
const WelcomeScreen({Key? key});
|
||||
const WelcomeScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
String? _phoneNumber;
|
||||
String? _errorMsg;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.tertiary,
|
||||
@@ -70,6 +74,22 @@ class WelcomeScreen extends StatelessWidget {
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null) {
|
||||
return 'Ingresa un numero';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
onChanged: (phone) {
|
||||
_phoneNumber = phone.completeNumber;
|
||||
},
|
||||
decoration:
|
||||
GeneralInputDecoration.getCustomDecoration(
|
||||
context: context,
|
||||
hintText: 'Ingresa tu numero',
|
||||
errorMsg: _errorMsg,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
@@ -82,15 +102,19 @@ class WelcomeScreen extends StatelessWidget {
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const SignScreen(initialIndex: 1),
|
||||
),
|
||||
);
|
||||
final phoneNumber = _phoneNumber;
|
||||
|
||||
if (phoneNumber != null && phoneNumber.isNotEmpty) {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
OtpAuthScreen(phoneNumber: phoneNumber),
|
||||
),
|
||||
);
|
||||
} else {}
|
||||
},
|
||||
child: const Text('Iniciar Sesión'),
|
||||
child: const Text('Enviar código'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -148,170 +172,5 @@ class WelcomeScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
// Scaffold(
|
||||
// backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
// body: Column(
|
||||
// children: [
|
||||
// Container(
|
||||
// color: Theme.of(context).colorScheme.tertiary,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 20),
|
||||
// Center(
|
||||
// child: Image(
|
||||
// width: width * 0.7,
|
||||
// image: const AssetImage('images/logo_prosapp.png'),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 20),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: Text(
|
||||
// 'Iniciar sesión',
|
||||
// style: TextStyle(
|
||||
// // fontSize: 30,
|
||||
// fontSize: width * 0.08,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: SingleChildScrollView(
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: Text(
|
||||
// 'Numero de celular',
|
||||
// style: TextStyle(
|
||||
// fontSize: width * 0.045,
|
||||
// color: Theme.of(context).colorScheme.onBackground,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Form(
|
||||
// child: IntlPhoneField(
|
||||
// initialCountryCode: 'CO',
|
||||
// keyboardType: TextInputType.number,
|
||||
// inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// 'Un código será enviado a este numero de celular.',
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: 13.0,
|
||||
// color: Theme.of(context).colorScheme.onBackground,
|
||||
// ),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => SignScreen(initialIndex: 0),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// child: Text(
|
||||
// 'Inicia sesión con tu correo electrónico',
|
||||
// style: TextStyle(
|
||||
// fontSize: width * 0.04,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// RichText(
|
||||
// text: TextSpan(
|
||||
// style: const TextStyle(
|
||||
// fontSize: 16.0,
|
||||
// color: Color(0xFF65676B),
|
||||
// fontFamily: 'Poppins',
|
||||
// ),
|
||||
// children: [
|
||||
// const TextSpan(text: '¿No estás registrado? '),
|
||||
// TextSpan(
|
||||
// text: 'Regístrate',
|
||||
// style: TextStyle(
|
||||
// fontSize: width * 0.04,
|
||||
// color: Colors.blue,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// recognizer: TapGestureRecognizer()
|
||||
// ..onTap = () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) =>
|
||||
// SignScreen(initialIndex: 1),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
|
||||
// Scaffold(
|
||||
// backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
// body: ListView(
|
||||
// children: [
|
||||
// Container(
|
||||
// color: Theme.of(context).colorScheme.tertiary,
|
||||
// padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
// child: Center(
|
||||
// child: Image(
|
||||
// width: width * 0.7,
|
||||
// image: const AssetImage('images/logo_prosapp.png'),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// decoration: const BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.only(
|
||||
// topLeft: Radius.circular(60),
|
||||
// topRight: Radius.circular(60),
|
||||
// ),
|
||||
// ),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(20.0),
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// const TextField(
|
||||
// decoration: InputDecoration(
|
||||
// labelText: 'Usuario',
|
||||
// border: OutlineInputBorder(),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 20.0),
|
||||
// const TextField(
|
||||
// decoration: InputDecoration(
|
||||
// labelText: 'Contraseña',
|
||||
// border: OutlineInputBorder(),
|
||||
// ),
|
||||
// obscureText: true,
|
||||
// ),
|
||||
// const SizedBox(height: 20.0),
|
||||
//
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
body: BlocBuilder<MyUserBloc, MyUserState>(builder: (context, state) {
|
||||
if (state.status == MyUserStatus.success) {
|
||||
_nameController.text = state.user!.name;
|
||||
_nameController.text = state.user!.name ?? '';
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
|
||||
Reference in New Issue
Block a user