Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-flutter
Commits
79c9cf73
Commit
79c9cf73
authored
Aug 01, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: loading on login submit
parent
34821612
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
auth_provider.dart
lib/src/providers/auth_provider.dart
+6
-2
login_form.dart
lib/src/widgets/forms/login_form.dart
+10
-1
No files found.
lib/src/providers/auth_provider.dart
View file @
79c9cf73
...
...
@@ -36,9 +36,13 @@ class AuthProvider with ChangeNotifier {
return
await
storage
.
read
(
key:
'access_token'
);
}
void
setLoading
(
bool
value
)
{
isLoading
=
value
;
}
Future
<
void
>
signIn
(
String
username
,
String
password
)
async
{
isLoading
=
true
;
try
{
setLoading
(
true
);
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$baseUrl
/auth/login'
),
body:
jsonEncode
({
'username'
:
username
,
'password'
:
password
}),
...
...
@@ -62,7 +66,7 @@ class AuthProvider with ChangeNotifier {
debugPrint
(
"Login failed
$code
"
);
}
isLoading
=
false
;
setLoading
(
false
)
;
notifyListeners
();
}
catch
(
error
)
{
debugPrint
(
"Login failed
$error
"
);
...
...
lib/src/widgets/forms/login_form.dart
View file @
79c9cf73
...
...
@@ -133,7 +133,16 @@ class _LoginForm extends State<LoginForm> {
passwordController
.
text
,
);
},
child:
const
Text
(
"Submit"
),
child:
authProvider
.
isLoading
?
const
SizedBox
(
width:
20.0
,
height:
20.0
,
child:
CircularProgressIndicator
(
color:
Colors
.
white
,
strokeWidth:
3.0
,
),
)
:
const
Text
(
"Submit"
),
),
),
SizedBox
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment