|
1 | 1 | import 'package:flutter/material.dart'; |
2 | 2 | import 'package:flutter_wordpress/flutter_wordpress.dart' as wp; |
| 3 | + |
3 | 4 | import 'display_posts.dart'; |
4 | 5 |
|
5 | 6 | const PADDING_16 = EdgeInsets.all(16.0); |
@@ -46,67 +47,64 @@ class LoginFieldsState extends State<LoginFields> { |
46 | 47 |
|
47 | 48 | @override |
48 | 49 | Widget build(BuildContext context) { |
49 | | - // TODO: implement build |
50 | 50 | return Center( |
51 | 51 | child: SingleChildScrollView( |
52 | | - child: Container( |
53 | | - padding: PADDING_16, |
54 | | - child: Column( |
55 | | - mainAxisAlignment: MainAxisAlignment.center, |
56 | | - crossAxisAlignment: CrossAxisAlignment.center, |
57 | | - children: [ |
58 | | - Padding( |
59 | | - padding: PADDING_8, |
60 | | - child: _buildFormField( |
61 | | - icon: Icon(Icons.person), |
62 | | - labelText: "Username", |
63 | | - hintText: "Username", |
64 | | - initialText: _username, |
65 | | - onChanged: _onUsernameChanged, |
66 | | - ), |
67 | | - ), |
68 | | - Padding( |
69 | | - padding: PADDING_8, |
70 | | - child: _buildFormField( |
71 | | - icon: Icon(Icons.lock), |
72 | | - labelText: "Password", |
73 | | - hintText: "Password", |
74 | | - initialText: _password, |
75 | | - obscureText: true, |
76 | | - onChanged: _onPasswordChanged, |
77 | | - ), |
78 | | - ), |
79 | | - _isDetailValid |
80 | | - ? SizedBox( |
81 | | - width: 0.0, |
82 | | - height: 0.0, |
83 | | - ) |
84 | | - : Padding( |
85 | | - padding: PADDING_8, |
86 | | - child: Text( |
87 | | - "Invalid Username / Password", |
88 | | - style: TextStyle( |
89 | | - color: Colors.red, |
90 | | - ), |
91 | | - ), |
92 | | - ), |
93 | | - RaisedButton( |
94 | | - onPressed: _isValidating ? () {} : _validateUser, |
95 | | - color: Colors.blue, |
96 | | - textColor: Colors.white, |
97 | | - child: Padding( |
| 52 | + child: Container( |
| 53 | + padding: PADDING_16, |
| 54 | + child: Column( |
| 55 | + mainAxisAlignment: MainAxisAlignment.center, |
| 56 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 57 | + children: [ |
| 58 | + Padding( |
| 59 | + padding: PADDING_8, |
| 60 | + child: _buildFormField( |
| 61 | + icon: Icon(Icons.person), |
| 62 | + labelText: "Username", |
| 63 | + hintText: "Username", |
| 64 | + initialText: _username, |
| 65 | + onChanged: _onUsernameChanged, |
| 66 | + ), |
| 67 | + ), |
| 68 | + Padding( |
| 69 | + padding: PADDING_8, |
| 70 | + child: _buildFormField( |
| 71 | + icon: Icon(Icons.lock), |
| 72 | + labelText: "Password", |
| 73 | + hintText: "Password", |
| 74 | + initialText: _password, |
| 75 | + obscureText: true, |
| 76 | + onChanged: _onPasswordChanged, |
| 77 | + ), |
| 78 | + ), |
| 79 | + _isDetailValid |
| 80 | + ? SizedBox( |
| 81 | + width: 0.0, |
| 82 | + height: 0.0, |
| 83 | + ) |
| 84 | + : Padding( |
98 | 85 | padding: PADDING_8, |
99 | | - child: _isValidating |
100 | | - ? CircularProgressIndicator( |
101 | | - valueColor: AlwaysStoppedAnimation(Colors.white), |
102 | | - ) |
103 | | - : Text('Login'), |
| 86 | + child: Text( |
| 87 | + "Invalid Username / Password", |
| 88 | + style: TextStyle( |
| 89 | + color: Colors.red, |
| 90 | + ), |
| 91 | + ), |
104 | 92 | ), |
105 | | - ), |
106 | | - ], |
| 93 | + ElevatedButton( |
| 94 | + onPressed: _isValidating ? () {} : _validateUser, |
| 95 | + child: Padding( |
| 96 | + padding: PADDING_8, |
| 97 | + child: _isValidating |
| 98 | + ? CircularProgressIndicator( |
| 99 | + valueColor: AlwaysStoppedAnimation(Colors.white), |
| 100 | + ) |
| 101 | + : Text('Login'), |
| 102 | + ), |
107 | 103 | ), |
108 | | - ), |
109 | | - )); |
| 104 | + ], |
| 105 | + ), |
| 106 | + ), |
| 107 | + )); |
110 | 108 | } |
111 | 109 |
|
112 | 110 | Widget _buildFormField({ |
@@ -155,7 +153,7 @@ class LoginFieldsState extends State<LoginFields> { |
155 | 153 | ); |
156 | 154 |
|
157 | 155 | final response = |
158 | | - wordPress.authenticateUser(username: _username, password: _password); |
| 156 | + wordPress.authenticateUser(username: _username, password: _password); |
159 | 157 |
|
160 | 158 | response.then((user) { |
161 | 159 | setState(() { |
|
0 commit comments