sign in page changes
This commit is contained in:
parent
02bce8318a
commit
a97ec0411d
@ -86,6 +86,7 @@ class _MainAppState extends State<MainApp> {
|
||||
filled: true,
|
||||
fillColor: Colors.grey.withOpacity(0.1),
|
||||
labelStyle: const TextStyle(color: Colors.grey),
|
||||
outlineBorder: BorderSide(color: Colors.grey.shade700),
|
||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
||||
if (states.contains(WidgetState.focused) &&
|
||||
!states.contains(WidgetState.hovered)) {
|
||||
@ -118,6 +119,8 @@ class _MainAppState extends State<MainApp> {
|
||||
filled: true,
|
||||
fillColor: Colors.grey.withOpacity(0.25),
|
||||
labelStyle: TextStyle(color: Colors.grey.shade700),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey.shade700)),
|
||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
||||
if (states.contains(WidgetState.focused) &&
|
||||
!states.contains(WidgetState.hovered)) {
|
||||
|
||||
@ -37,7 +37,7 @@ class _SignInPageState extends State<SignInPage> {
|
||||
heightFactor: 1.0,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 50, 12, 50),
|
||||
height: 475,
|
||||
height: 450,
|
||||
width: 500,
|
||||
child: Card(
|
||||
child: Padding(
|
||||
@ -60,9 +60,12 @@ class _SignInPageState extends State<SignInPage> {
|
||||
controller: _usernameController,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.person_outline),
|
||||
labelText: 'Username',
|
||||
border: OutlineInputBorder()),
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Icon(Icons.person_outline),
|
||||
),
|
||||
labelText: 'Username',
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
@ -107,11 +110,13 @@ class _SignInPageState extends State<SignInPage> {
|
||||
autocorrect: false,
|
||||
obscureText: obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.fingerprint),
|
||||
prefixIcon: const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Icon(Icons.fingerprint),
|
||||
),
|
||||
labelText: 'Password',
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@ -131,63 +136,107 @@ class _SignInPageState extends State<SignInPage> {
|
||||
errorMessage!,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
CheckboxListTile(
|
||||
value: rememberMe,
|
||||
onChanged: (value) async {
|
||||
setState(() {
|
||||
rememberMe = value!;
|
||||
});
|
||||
},
|
||||
title: const Text('Remember me'),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
// padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 12.0, bottom: 12.0),
|
||||
),
|
||||
icon: _isloading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 3,
|
||||
))
|
||||
: const Icon(Icons.done, color: Colors.white),
|
||||
label: const Text('Sign In',
|
||||
style: TextStyle(color: Colors.white)),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
errorMessage = null;
|
||||
_isloading = true;
|
||||
});
|
||||
jwt = await signIn(username, password).timeout(
|
||||
const Duration(seconds: 20), onTimeout: () {
|
||||
_isloading = false;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
width: 300,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content:
|
||||
Text('Could not Sign in (timeout)!')),
|
||||
);
|
||||
});
|
||||
if (!jwt.contains('Error:')) {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
await prefs.setString('username', username);
|
||||
await prefs.setString('password', password);
|
||||
await prefs.setBool('rememberMe', rememberMe);
|
||||
widget.refreshAccount(true);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: FilledButton(
|
||||
style: FilledButton.styleFrom(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6)))),
|
||||
child: SizedBox(
|
||||
width: 374,
|
||||
height: 40,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_isloading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 3,
|
||||
))
|
||||
: const Padding(
|
||||
padding: EdgeInsets.only(right: 8.0),
|
||||
child: Icon(Icons.done,
|
||||
color: Colors.white),
|
||||
),
|
||||
const Text('Sign in',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 18)),
|
||||
],
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
errorMessage = 'Invalid Username/Password';
|
||||
_isloading = false;
|
||||
_isloading = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
jwt = await signIn(username, password).timeout(
|
||||
const Duration(seconds: 20), onTimeout: () {
|
||||
_isloading = false;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
width: 300,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content:
|
||||
Text('Could not Sign in (timeout)!')),
|
||||
);
|
||||
});
|
||||
if (!jwt.contains('Error:')) {
|
||||
final SharedPreferences prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
await prefs.setString('username', username);
|
||||
await prefs.setString('password', password);
|
||||
await prefs.setBool('rememberMe', rememberMe);
|
||||
widget.refreshAccount(true);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
setState(() {
|
||||
errorMessage = 'Invalid Username/Password';
|
||||
_isloading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: rememberMe,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
rememberMe = value!;
|
||||
});
|
||||
}),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text('Remember me'),
|
||||
)
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
rememberMe = !rememberMe;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user