Create account

This commit is contained in:
Hillel Coren 2019-08-26 10:13:25 +03:00
parent 4a4dc21a47
commit 278d3b0cf6
4 changed files with 134 additions and 97 deletions

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
// This version must be updated in tandem with the pubspec version.
const String kAppVersion = '0.1.47';
const String kSiteUrl = 'https://invoiceninja.com';
const String kAppUrl = 'https://app.invoiceninja.com';
const String kAppleStoreUrl =

View File

@ -17,9 +17,7 @@ class ProgressButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: padding ?? EdgeInsets.only(left: 16.0, right: 16.0, top: 2.0),
child: isLoading
return isLoading
? Center(
child: SizedBox(
height: 48,
@ -31,7 +29,6 @@ class ProgressButton extends StatelessWidget {
width: double.infinity,
label: label,
onPressed: () => this.onPressed(),
),
);
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.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';
import 'package:invoiceninja_flutter/ui/app/progress_button.dart';
@ -7,6 +8,7 @@ import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
import 'package:url_launcher/url_launcher.dart';
class LoginView extends StatefulWidget {
const LoginView({
@ -33,6 +35,7 @@ class _LoginState extends State<LoginView> {
final FocusNode _focusNode1 = new FocusNode();
bool _createAccount = false;
bool _isSelfHosted = false;
bool _autoValidate = false;
@ -166,8 +169,8 @@ class _LoginState extends State<LoginView> {
focusNode: _focusNode1,
onFieldSubmitted: (value) => _submitForm(),
),
_isSelfHosted
? TextFormField(
if (_isSelfHosted)
TextFormField(
controller: _urlController,
key: ValueKey(localization.url),
autocorrect: false,
@ -179,23 +182,21 @@ class _LoginState extends State<LoginView> {
? localization.pleaseEnterYourUrl
: null,
keyboardType: TextInputType.url,
)
: Container(),
_isSelfHosted
? TextFormField(
),
if (_isSelfHosted)
TextFormField(
controller: _secretController,
key: ValueKey(localization.secret),
autocorrect: false,
decoration: InputDecoration(
labelText: localization.secret),
obscureText: true,
)
: Container(),
),
],
),
viewModel.authState.error == null || error.contains(OTP_ERROR)
? Container()
: Container(
if (viewModel.authState.error != null &&
!error.contains(OTP_ERROR))
Container(
padding: EdgeInsets.only(top: 26.0),
child: Center(
child: Text(
@ -207,18 +208,44 @@ class _LoginState extends State<LoginView> {
),
),
),
SizedBox(height: 24.0),
ProgressButton(
padding: EdgeInsets.only(top: 12.0, bottom: 12.0),
Padding(
padding: EdgeInsets.only(top: 35, bottom: 10),
child: Row(
children: <Widget>[
Expanded(
child: ProgressButton(
isLoading: viewModel.isLoading,
label: localization.login.toUpperCase(),
label: localization.emailLogin.toUpperCase(),
onPressed: () => _submitForm(),
),
isOneTimePassword
? Container()
: Row(
),
SizedBox(width: 20),
Expanded(
child: ElevatedButton(
label: localization.googleLogin.toUpperCase(),
onPressed: () => viewModel.onGoogleLoginPressed(
context,
_urlController.text,
_secretController.text),
),
),
],
),
),
if (!isOneTimePassword)
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
_createAccount
? FlatButton(
onPressed: () =>
setState(() => _createAccount = false),
child: Text(localization.login))
: FlatButton(
key: ValueKey(localization.selfhostLogin),
onPressed: () =>
setState(() => _createAccount = true),
child: Text(localization.createAccount)),
_isSelfHosted
? FlatButton(
onPressed: () =>
@ -230,15 +257,18 @@ class _LoginState extends State<LoginView> {
setState(() => _isSelfHosted = true),
child: Text(localization.selfhostLogin)),
FlatButton(
onPressed: () => viewModel.onGoogleLoginPressed(
context,
_urlController.text,
_secretController.text),
child: Text(localization.googleLogin)),
child: Text(localization.viewWebsite),
onPressed: () async {
if (await canLaunch(kSiteUrl)) {
await launch(kSiteUrl,
forceSafariVC: false, forceWebView: false);
}
},
),
],
),
isOneTimePassword && !viewModel.isLoading
? Padding(
if (isOneTimePassword && !viewModel.isLoading)
Padding(
padding: EdgeInsets.only(top: 12.0, bottom: 12.0),
child: ElevatedButton(
label: localization.cancel.toUpperCase(),
@ -250,8 +280,7 @@ class _LoginState extends State<LoginView> {
viewModel.onCancel2FAPressed();
},
),
)
: Container(),
),
],
),
),

View File

@ -14,6 +14,9 @@ abstract class LocaleCodeAware {
mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
'view_website': 'View Website',
'create_account': 'Create Account',
'email_login': 'Email Login',
'create_new': 'Create New',
'no_record_selected': 'No record selected',
'error_unsaved_changes': 'Please save or cancel your changes',
@ -13803,6 +13806,13 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get createNew => _localizedValues[localeCode]['create_new'];
String get emailLogin => _localizedValues[localeCode]['email_login'];
String get createAccount => _localizedValues[localeCode]['create_account'];
String get viewWebsite => _localizedValues[localeCode]['view_website'];
String lookup(String key) {
final lookupKey = toSnakeCase(key);
return _localizedValues[localeCode][lookupKey] ??