Clean up login form

This commit is contained in:
Hillel Coren 2020-05-12 23:25:38 +03:00
parent f75368bbb1
commit f57b3c5407
2 changed files with 50 additions and 47 deletions

View File

@ -30,8 +30,7 @@ class FormCard extends StatelessWidget {
child: Card( child: Card(
elevation: 4.0, elevation: 4.0,
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.all(16),
left: 16.0, top: 16.0, right: 16.0, bottom: 20.0),
child: child != null child: child != null
? child ? child
: Container( : Container(

View File

@ -84,6 +84,10 @@ class _LoginState extends State<LoginView> {
_emailLogin = true; _emailLogin = true;
} }
if (kIsWeb) {
_isSelfHosted = widget.viewModel.authState.isSelfHost;
}
if (_urlController.text.isEmpty) { if (_urlController.text.isEmpty) {
_urlController.text = widget.viewModel.authState.url; _urlController.text = widget.viewModel.authState.url;
} }
@ -322,21 +326,22 @@ class _LoginState extends State<LoginView> {
Column( Column(
children: <Widget>[ children: <Widget>[
SizedBox(height: 10), SizedBox(height: 10),
_ToggleButtons( if (!kIsWeb)
tabLabels: [ _ToggleButtons(
localization.hosted, tabLabels: [
localization.selfhosted, localization.hosted,
], localization.selfhosted,
selectedIndex: _isSelfHosted ? 1 : 0, ],
onTabChanged: (index) { selectedIndex: _isSelfHosted ? 1 : 0,
setState(() { onTabChanged: (index) {
_isSelfHosted = index == 1; setState(() {
_loginError = ''; _isSelfHosted = index == 1;
_emailLogin = _isSelfHosted; _loginError = '';
_createAccount = !_isSelfHosted; _emailLogin = _isSelfHosted;
}); _createAccount = !_isSelfHosted;
}, });
), },
),
if (!_isSelfHosted) if (!_isSelfHosted)
_ToggleButtons( _ToggleButtons(
tabLabels: [ tabLabels: [
@ -559,7 +564,7 @@ class _LoginState extends State<LoginView> {
), ),
), ),
Padding( Padding(
padding: EdgeInsets.only(top: 30, bottom: 10), padding: EdgeInsets.only(top: 20, bottom: 10),
child: viewModel.isLoading child: viewModel.isLoading
? LoadingIndicator(height: 48) ? LoadingIndicator(height: 48)
: _createAccount : _createAccount
@ -581,7 +586,6 @@ class _LoginState extends State<LoginView> {
.toUpperCase(), .toUpperCase(),
onPressed: () => _submitLoginForm(), onPressed: () => _submitLoginForm(),
)), )),
SizedBox(height: 6),
if (!isOneTimePassword) if (!isOneTimePassword)
Column( Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -634,34 +638,6 @@ class _LoginState extends State<LoginView> {
} }
} }
// https://github.com/iampawan/Flutter-UI-Kit
class ArcClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final path = Path();
path.lineTo(0.0, size.height - 30);
final firstControlPoint = Offset(size.width / 4, size.height);
final firstPoint = Offset(size.width / 2, size.height);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstPoint.dx, firstPoint.dy);
final secondControlPoint =
Offset(size.width - (size.width / 4), size.height);
final secondPoint = Offset(size.width, size.height - 30);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondPoint.dx, secondPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
class _ToggleButtons extends StatelessWidget { class _ToggleButtons extends StatelessWidget {
const _ToggleButtons({ const _ToggleButtons({
@required this.selectedIndex, @required this.selectedIndex,
@ -701,3 +677,31 @@ class _ToggleButtons extends StatelessWidget {
); );
} }
} }
// https://github.com/iampawan/Flutter-UI-Kit
class ArcClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final path = Path();
path.lineTo(0.0, size.height - 30);
final firstControlPoint = Offset(size.width / 4, size.height);
final firstPoint = Offset(size.width / 2, size.height);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstPoint.dx, firstPoint.dy);
final secondControlPoint =
Offset(size.width - (size.width / 4), size.height);
final secondPoint = Offset(size.width, size.height - 30);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondPoint.dx, secondPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}