Create account

This commit is contained in:
Hillel Coren 2019-08-26 10:28:48 +03:00
parent 278d3b0cf6
commit 3105ce2e1a
2 changed files with 75 additions and 46 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
@ -210,7 +211,13 @@ class _LoginState extends State<LoginView> {
),
Padding(
padding: EdgeInsets.only(top: 35, bottom: 10),
child: Row(
child: _createAccount
? ProgressButton(
isLoading: viewModel.isLoading,
label: localization.signUp.toUpperCase(),
onPressed: () => _submitForm(),
)
: Row(
children: <Widget>[
Expanded(
child: ProgressButton(
@ -223,7 +230,8 @@ class _LoginState extends State<LoginView> {
Expanded(
child: ElevatedButton(
label: localization.googleLogin.toUpperCase(),
onPressed: () => viewModel.onGoogleLoginPressed(
onPressed: () =>
viewModel.onGoogleLoginPressed(
context,
_urlController.text,
_secretController.text),
@ -236,16 +244,25 @@ class _LoginState extends State<LoginView> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Row(
children: <Widget>[
Icon(FontAwesomeIcons.user, size: 16),
_createAccount
? FlatButton(
onPressed: () =>
setState(() => _createAccount = false),
child: Text(localization.login))
child: Text(localization.accountLogin))
: FlatButton(
key: ValueKey(localization.selfhostLogin),
onPressed: () =>
setState(() => _createAccount = true),
onPressed: () => setState(() {
_createAccount = true;
_isSelfHosted = false;
}),
child: Text(localization.createAccount)),
],
),
Row(children: <Widget>[
Icon(FontAwesomeIcons.userCog, size: 16),
_isSelfHosted
? FlatButton(
onPressed: () =>
@ -254,8 +271,14 @@ class _LoginState extends State<LoginView> {
: FlatButton(
key: ValueKey(localization.selfhostLogin),
onPressed: () =>
setState(() => _isSelfHosted = true),
setState(() {
_isSelfHosted = true;
_createAccount = false;
}),
child: Text(localization.selfhostLogin)),
]),
Row(children: <Widget>[
Icon(FontAwesomeIcons.externalLinkAlt, size: 16),
FlatButton(
child: Text(localization.viewWebsite),
onPressed: () async {
@ -265,6 +288,7 @@ class _LoginState extends State<LoginView> {
}
},
),
]),
],
),
if (isOneTimePassword && !viewModel.isLoading)

View File

@ -14,6 +14,8 @@ abstract class LocaleCodeAware {
mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
'sign_up': 'Sign Up',
'account_login': 'Account Login',
'view_website': 'View Website',
'create_account': 'Create Account',
'email_login': 'Email Login',
@ -13812,6 +13814,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get viewWebsite => _localizedValues[localeCode]['view_website'];
String get accountLogin => _localizedValues[localeCode]['account_login'];
String get signUp => _localizedValues[localeCode]['sign_up'];
String lookup(String key) {
final lookupKey = toSnakeCase(key);