171 lines
6.0 KiB
Dart
171 lines
6.0 KiB
Dart
import 'package:como_gasto/auth_providers/auth_provider.dart';
|
|
import 'package:como_gasto/como_gasto_localizations.dart';
|
|
import 'package:flare_flutter/flare_actor.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../states/login_state.dart';
|
|
import 'ui/legal_notice_widget.dart';
|
|
import 'ui/social_login_widget.dart';
|
|
|
|
class LoginPage extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ComoGastoLocalizations localizations = ComoGastoLocalizations.of(context);
|
|
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: <Widget>[
|
|
Text(
|
|
localizations.t('login.title'),
|
|
style: Theme.of(context).textTheme.display1,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(32.0),
|
|
child: Container(
|
|
height: 300,
|
|
child: FlareActor(
|
|
"assets/login_background.flr",
|
|
animation: "idle",
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
localizations.t('login.subtitle'),
|
|
style: Theme.of(context).textTheme.caption,
|
|
),
|
|
Consumer<LoginState>(
|
|
builder: (BuildContext context, LoginState value, Widget child) {
|
|
if (value.isLoading()) {
|
|
return CircularProgressIndicator();
|
|
} else {
|
|
return child;
|
|
}
|
|
},
|
|
child: Container(
|
|
width: 200,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
SocialLoginWidget(
|
|
backgroundColor: Color(0xff00aced),
|
|
iconData: FontAwesomeIcons.twitter,
|
|
),
|
|
FloatingActionButton(
|
|
backgroundColor: Color(0xff4285F4),
|
|
child: Icon(FontAwesomeIcons.google),
|
|
onPressed: () {
|
|
Provider.of<LoginState>(context, listen: false)
|
|
.login(LoginProvider.GOOGLE);
|
|
},
|
|
),
|
|
SocialLoginWidget(
|
|
backgroundColor: Color(0xff3b5998),
|
|
iconData: FontAwesomeIcons.facebook,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
// Modificación para publicación en tiendas (Google Play Store / Apple App Store):
|
|
// Acceso explícito de evaluación para revisores humanos con cuenta demo fija.
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 12.0),
|
|
child: OutlineButton.icon(
|
|
icon: Icon(Icons.verified_user, size: 18.0),
|
|
label: Text(
|
|
'Acceso Revisor de Tienda (Demo)',
|
|
style: TextStyle(fontSize: 13.0),
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20.0),
|
|
),
|
|
onPressed: () {
|
|
_mostrarDialogoDemo(context);
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(32.0),
|
|
child: LegalNoticeWidget(),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Modificación para publicación en tiendas:
|
|
// Diálogo modal con credenciales fijas demo@comogasto.com y PIN 123456 preconfiguradas
|
|
// para garantizar que la app nunca sea rechazada por problemas de autenticación o backend.
|
|
void _mostrarDialogoDemo(BuildContext context) {
|
|
final emailController = TextEditingController(text: LoginState.DEMO_EMAIL);
|
|
final pinController = TextEditingController(text: LoginState.DEMO_PIN);
|
|
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext ctx) {
|
|
return AlertDialog(
|
|
title: Row(
|
|
children: <Widget>[
|
|
Icon(Icons.lock_open, color: Theme.of(context).primaryColor),
|
|
SizedBox(width: 8.0),
|
|
Text('Acceso Demo / Revisor', style: TextStyle(fontSize: 18.0)),
|
|
],
|
|
),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Text(
|
|
'Credenciales de evaluación para Google Play Store y App Store:',
|
|
style: TextStyle(fontSize: 12.0, color: Colors.grey[700]),
|
|
),
|
|
SizedBox(height: 12.0),
|
|
TextField(
|
|
controller: emailController,
|
|
decoration: InputDecoration(
|
|
labelText: 'Correo Demo',
|
|
border: OutlineInputBorder(),
|
|
isDense: true,
|
|
),
|
|
),
|
|
SizedBox(height: 10.0),
|
|
TextField(
|
|
controller: pinController,
|
|
obscureText: true,
|
|
decoration: InputDecoration(
|
|
labelText: 'PIN / Clave',
|
|
border: OutlineInputBorder(),
|
|
isDense: true,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
actions: <Widget>[
|
|
FlatButton(
|
|
child: Text('Cancelar'),
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
),
|
|
RaisedButton(
|
|
color: Theme.of(context).primaryColor,
|
|
child: Text('Ingresar Demo', style: TextStyle(color: Colors.white)),
|
|
onPressed: () async {
|
|
Navigator.of(ctx).pop();
|
|
final loginState = Provider.of<LoginState>(context, listen: false);
|
|
await loginState.loginDemo(
|
|
email: emailController.text,
|
|
pin: pinController.text,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|