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
6ab0290f
Commit
6ab0290f
authored
Aug 05, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: navigation and handle new loans endpoint
parent
7c5cd9f1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
69 deletions
+38
-69
main.dart
lib/main.dart
+7
-1
loan.dart
lib/src/models/loan.dart
+0
-12
auth_provider.dart
lib/src/providers/auth_provider.dart
+7
-7
form_screen.dart
lib/src/screens/form_screen.dart
+1
-1
profile_edit_screen.dart
lib/src/screens/profile_edit_screen.dart
+1
-1
change_password_form.dart
lib/src/widgets/forms/change_password_form.dart
+16
-28
admin_loan_list.dart
lib/src/widgets/loans/admin_loan_list.dart
+2
-11
profile.dart
lib/src/widgets/profile.dart
+4
-8
No files found.
lib/main.dart
View file @
6ab0290f
...
...
@@ -3,6 +3,8 @@ import 'package:flutter/gestures.dart';
import
'package:go_router/go_router.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:library_app/src/screens/profile_edit_screen.dart'
;
import
'package:library_app/src/widgets/profile.dart'
;
import
'package:provider/provider.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:library_app/src/providers/navigations_provider.dart'
;
...
...
@@ -54,7 +56,11 @@ class _LibraryApp extends State<LibraryApp> {
GoRoute
(
path:
"/change-password"
,
builder:
(
context
,
state
)
=>
const
ChangePasswordScreen
(),
)
),
GoRoute
(
path:
"/profile-edit"
,
builder:
(
context
,
state
)
=>
const
ProfileEditScreen
(),
),
],
);
...
...
lib/src/models/loan.dart
View file @
6ab0290f
...
...
@@ -17,16 +17,4 @@ class Loan {
this
.
remainingDays
,
this
.
isOverdue
,
);
factory
Loan
.
fromJson
(
Map
<
String
,
dynamic
>
data
)
{
final
book
=
Book
.
fromJson
(
data
[
"book_detail"
]);
return
Loan
(
book
,
null
,
data
[
"loan_date"
],
data
[
"due_date"
],
data
[
"remaining_loan_time"
],
data
[
"is_overdue"
],
);
}
}
lib/src/providers/auth_provider.dart
View file @
6ab0290f
...
...
@@ -459,13 +459,13 @@ class AuthProvider with ChangeNotifier {
// for admin or librarian
Future
<
void
>
getLoans
(
String
?
type
)
async
{
final
token
=
await
storage
.
read
(
key:
'access_token'
);
String
url
=
baseUrl
;
String
url
=
"
$baseUrl
/book-loans"
;
if
(
type
==
"upcoming"
)
{
url
+=
"/upcoming-loans/"
;
url
+=
'?near_outstanding=True'
;
}
else
if
(
type
==
"overdue"
)
{
url
+=
"/overdued-loans/"
;
url
+=
'?overdue=True'
;
}
else
{
url
+=
"/book-loans/"
;
null
;
}
if
(
token
!=
null
)
{
...
...
@@ -482,11 +482,11 @@ class AuthProvider with ChangeNotifier {
if
(
response
.
statusCode
==
200
)
{
final
data
=
jsonDecode
(
response
.
body
);
if
(
type
==
"upcoming"
)
{
nearOutstandingLoans
=
data
[
"results"
]
;
nearOutstandingLoans
=
data
;
}
else
if
(
type
==
"overdue"
)
{
overduedLoans
=
data
[
"results"
]
;
overduedLoans
=
data
;
}
else
{
loans
=
data
[
"results"
]
;
loans
=
data
;
}
}
else
{
final
code
=
response
.
statusCode
;
...
...
lib/src/screens/form_screen.dart
View file @
6ab0290f
...
...
@@ -99,7 +99,7 @@ class ChangePasswordScreen extends StatelessWidget {
return
FormScreen
(
title:
title
,
backRoute:
"/"
,
backRoute:
"/
profile-edit
"
,
body:
const
ChangePasswordForm
(),
);
}
...
...
lib/src/screens/profile_edit_screen.dart
View file @
6ab0290f
...
...
@@ -18,7 +18,7 @@ class ProfileEditScreen extends StatelessWidget {
appBar:
AppBar
(
title:
Text
(
title
),
leading:
BackButton
(
onPressed:
()
=>
context
.
p
op
(
),
onPressed:
()
=>
context
.
p
ush
(
"/"
),
),
),
body:
Consumer
<
AuthProvider
>(
...
...
lib/src/widgets/forms/change_password_form.dart
View file @
6ab0290f
import
'package:flutter/material.dart'
;
import
'package:flutter_svg/svg.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:library_app/src/widgets/loading.dart'
;
import
'package:provider/provider.dart'
;
...
...
@@ -139,8 +138,6 @@ class _ChangePasswordForm extends State<ChangePasswordForm> {
const
SizedBox
(
height:
20.0
,
),
Column
(
children:
[
SizedBox
(
width:
double
.
infinity
,
child:
FilledButton
(
...
...
@@ -158,15 +155,6 @@ class _ChangePasswordForm extends State<ChangePasswordForm> {
:
const
Text
(
"Submit"
),
),
),
SizedBox
(
width:
double
.
infinity
,
child:
TextButton
(
child:
const
Text
(
"Cancel"
),
onPressed:
()
=>
context
.
pop
(
"/"
),
),
),
],
),
],
),
),
...
...
lib/src/widgets/loans/admin_loan_list.dart
View file @
6ab0290f
...
...
@@ -45,17 +45,8 @@ class _AdminLoanList extends State<AdminLoanList> {
if
(
getLoans
!=
null
)
{
var
loans
=
getLoans
.
map
(
(
loan
)
{
var
book
=
Book
.
fromJson
(
loan
[
"book_detail"
]);
var
memberData
=
loan
[
"member_detail"
];
var
userData
=
memberData
[
"user"
];
var
user
=
User
(
userData
[
"id"
],
userData
[
"username"
],
userData
[
"email"
],
userData
[
"first_name"
],
userData
[
"last_name"
],
userData
[
"is_staff"
],
);
var
book
=
Book
.
fromJson
(
loan
[
"book"
]);
var
user
=
User
.
fromJson
(
loan
[
"user"
]);
return
Loan
(
book
,
...
...
lib/src/widgets/profile.dart
View file @
6ab0290f
import
'package:flutter/material.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:provider/provider.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:library_app/src/
screens/profile_edit_screen
.dart'
;
import
'package:library_app/src/
providers/auth_provider
.dart'
;
import
'package:library_app/src/widgets/navigations.dart'
;
import
'package:provider/provider.dart'
;
class
Profile
extends
StatefulWidget
{
const
Profile
({
super
.
key
});
...
...
@@ -81,11 +81,7 @@ class _Profile extends State<Profile> {
FilledButton
(
child:
const
Text
(
"Edit Profile"
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
=>
const
ProfileEditScreen
(),
),
);
context
.
go
(
"/profile-edit"
);
},
),
const
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