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
b436da7f
Unverified
Commit
b436da7f
authored
Aug 02, 2024
by
Ilham Maulana Pratama
Committed by
GitHub
Aug 02, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from impfundev/development
Development
parents
925c2451
a19ae843
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
51 deletions
+57
-51
book_provider.dart
lib/src/providers/book_provider.dart
+8
-0
form_screen.dart
lib/src/screens/form_screen.dart
+0
-35
profile_edit_screen.dart
lib/src/screens/profile_edit_screen.dart
+38
-0
book_list.dart
lib/src/widgets/books/book_list.dart
+1
-1
search_form.dart
lib/src/widgets/forms/search_form.dart
+8
-3
loan_item.dart
lib/src/widgets/loans/loan_item.dart
+1
-2
profile.dart
lib/src/widgets/profile.dart
+1
-1
pubspec.lock
pubspec.lock
+0
-8
pubspec.yaml
pubspec.yaml
+0
-1
No files found.
lib/src/providers/book_provider.dart
View file @
b436da7f
...
...
@@ -12,8 +12,15 @@ class BookProvider with ChangeNotifier {
String
?
searchKeyword
;
String
?
filterByCategory
;
bool
isLoading
=
false
;
void
setLoading
(
bool
value
)
{
isLoading
=
value
;
}
Future
<
void
>
getBooks
()
async
{
try
{
setLoading
(
true
);
String
url
=
'
$baseUrl
/books'
;
if
(
filterByCategory
!=
null
)
{
url
+=
'?category__name=
$filterByCategory
'
;
...
...
@@ -34,6 +41,7 @@ class BookProvider with ChangeNotifier {
debugPrint
(
"Error: Fetch books failed,
$code
"
);
}
setLoading
(
false
);
notifyListeners
();
}
catch
(
error
)
{
debugPrint
(
"Error: Fetch books failed,
$error
"
);
...
...
lib/src/screens/form_screen.dart
View file @
b436da7f
import
'package:flutter/material.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:library_app/src/widgets/forms/login_form.dart'
;
import
'package:library_app/src/widgets/forms/profile_edit_form.dart'
;
import
'package:library_app/src/widgets/forms/reset_password_form.dart'
;
import
'package:library_app/src/widgets/forms/sign_up_form.dart'
;
import
'package:provider/provider.dart'
;
class
FormScreen
extends
StatefulWidget
{
final
String
title
;
...
...
@@ -121,35 +118,3 @@ class ConfirmResetPasswordScreen extends StatelessWidget {
);
}
}
class
ProfileEditScreen
extends
StatelessWidget
{
const
ProfileEditScreen
({
super
.
key
,
});
@override
Widget
build
(
BuildContext
context
)
{
String
title
=
"Edit Profile"
;
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
title
),
leading:
BackButton
(
onPressed:
()
=>
context
.
pop
(),
),
),
body:
Consumer
<
AuthProvider
>(
builder:
(
context
,
authProvider
,
child
)
{
return
ListView
(
children:
[
Container
(
width:
double
.
infinity
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20.0
,
vertical:
40.0
),
child:
ProfileEditForm
(
user:
authProvider
.
user
),
),
]);
},
),
);
}
}
lib/src/screens/profile_edit_screen.dart
0 → 100644
View file @
b436da7f
import
'package:flutter/material.dart'
;
import
'package:provider/provider.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:library_app/src/widgets/forms/profile_edit_form.dart'
;
class
ProfileEditScreen
extends
StatelessWidget
{
const
ProfileEditScreen
({
super
.
key
,
});
@override
Widget
build
(
BuildContext
context
)
{
String
title
=
"Edit Profile"
;
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
title
),
leading:
BackButton
(
onPressed:
()
=>
context
.
pop
(),
),
),
body:
Consumer
<
AuthProvider
>(
builder:
(
context
,
authProvider
,
child
)
{
return
ListView
(
children:
[
Container
(
width:
double
.
infinity
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20.0
,
vertical:
40.0
),
child:
ProfileEditForm
(
user:
authProvider
.
user
),
),
]);
},
),
);
}
}
lib/src/widgets/books/book_list.dart
View file @
b436da7f
...
...
@@ -25,7 +25,7 @@ class _BookList extends State<BookList> {
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
BookProvider
>(
builder:
(
context
,
bookProvider
,
child
)
{
if
(
bookProvider
.
books
!=
null
)
{
if
(
!
bookProvider
.
isLoading
)
{
final
Iterable
<
Book
>
books
=
bookProvider
.
books
!.
map
((
book
)
{
if
(
book
[
"category_detail"
]
!=
null
)
{
final
Category
category
=
Category
.
fromJson
(
...
...
lib/src/widgets/forms/search_form.dart
View file @
b436da7f
...
...
@@ -27,10 +27,15 @@ class _SearchForm extends State<SearchForm> {
hintText:
"Enter keywords..."
,
elevation:
WidgetStateProperty
.
all
(
0
),
onChanged:
(
value
)
{
Future
.
delayed
(
Duration
.
zero
,
()
{
Provider
.
of
<
BookProvider
>(
context
,
listen:
false
)
.
setSearchKeyword
(
value
);
Provider
.
of
<
BookProvider
>(
context
,
listen:
false
).
getBooks
();
},
);
},
leading:
const
Icon
(
Icons
.
search
),
),
);
...
...
lib/src/widgets/loans/loan_item.dart
View file @
b436da7f
...
...
@@ -44,9 +44,8 @@ class LoanItem extends StatelessWidget {
Offstage
(
offstage:
user
==
null
,
child:
Card
(
color:
Theme
.
of
(
context
).
primary
Color
,
color:
Theme
.
of
(
context
).
canvas
Color
,
child:
ListTile
(
textColor:
Colors
.
white
,
title:
Text
(
user
!=
null
?
user
!.
username
:
""
),
subtitle:
Text
(
user
!=
null
?
user
!.
email
:
""
),
),
...
...
lib/src/widgets/profile.dart
View file @
b436da7f
import
'package:flutter/material.dart'
;
import
'package:library_app/src/providers/auth_provider.dart'
;
import
'package:library_app/src/screens/
form
_screen.dart'
;
import
'package:library_app/src/screens/
profile_edit
_screen.dart'
;
import
'package:library_app/src/widgets/navigations.dart'
;
import
'package:provider/provider.dart'
;
...
...
pubspec.lock
View file @
b436da7f
...
...
@@ -86,14 +86,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_keychain:
dependency: "direct main"
description:
name: flutter_keychain
sha256: "0d000c0e9b3c16fdec016df406b4e89e7195bf719ed0882157400f1e16323cf8"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
flutter_lints:
dependency: "direct dev"
description:
...
...
pubspec.yaml
View file @
b436da7f
...
...
@@ -40,7 +40,6 @@ dependencies:
intl
:
^0.19.0
provider
:
^6.1.2
http
:
^1.2.2
flutter_keychain
:
^2.5.0
flutter_secure_storage
:
^9.2.2
go_router
:
^14.2.1
...
...
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