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
99c75c17
Commit
99c75c17
authored
Jul 31, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: widget actions handle filter category
parent
8032ad3b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
40 deletions
+64
-40
list_screen.dart
lib/src/screens/list_screen.dart
+3
-0
book_list.dart
lib/src/widgets/books/book_list.dart
+49
-35
search_form.dart
lib/src/widgets/forms/search_form.dart
+6
-2
loan_item.dart
lib/src/widgets/loans/loan_item.dart
+6
-3
No files found.
lib/src/screens/list_screen.dart
View file @
99c75c17
...
...
@@ -87,6 +87,9 @@ class _ListScreen extends State<ListScreen> {
return
ListTile
(
title:
Text
(
category
.
elementAt
(
index
).
name
),
onTap:
()
{
bookProvider
.
filterBookByCategory
(
category
!.
elementAt
(
index
).
name
);
bookProvider
.
getBooks
();
Navigator
.
pop
(
context
);
},
);
...
...
lib/src/widgets/books/book_list.dart
View file @
99c75c17
...
...
@@ -95,8 +95,12 @@ class _TopAppBar extends State<TopAppBar> {
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
BookProvider
>(
builder:
(
context
,
bookProvider
,
child
)
{
final
category
=
bookProvider
.
filterByCategory
;
final
appBarTitle
=
category
!=
null
?
"
$category
$title
"
:
title
;
return
SliverAppBar
(
title:
Text
(
showWidget
?
""
:
t
itle
),
title:
Text
(
showWidget
?
""
:
appBarT
itle
),
actions:
[
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
...
...
@@ -105,6 +109,10 @@ class _TopAppBar extends State<TopAppBar> {
onPressed:
()
{
setState
(()
{
showWidget
=
!
showWidget
;
if
(!
showWidget
)
{
bookProvider
.
setSearchKeyword
(
null
);
bookProvider
.
getBooks
();
}
});
},
icon:
Icon
(
showWidget
?
Icons
.
close
:
Icons
.
search
),
...
...
@@ -119,9 +127,14 @@ class _TopAppBar extends State<TopAppBar> {
leading:
!
showWidget
?
IconButton
(
onPressed:
()
{
if
(
category
!=
null
)
{
bookProvider
.
filterBookByCategory
(
null
);
bookProvider
.
getBooks
();
}
else
{
Scaffold
.
of
(
context
).
openDrawer
();
}
},
icon:
const
Icon
(
Icons
.
menu
),
icon:
Icon
(
category
!=
null
?
Icons
.
close
:
Icons
.
menu
),
)
:
null
,
elevation:
10.0
,
...
...
@@ -130,5 +143,6 @@ class _TopAppBar extends State<TopAppBar> {
floating:
true
,
snap:
true
,
);
});
}
}
lib/src/widgets/forms/search_form.dart
View file @
99c75c17
...
...
@@ -24,9 +24,13 @@ class _SearchForm extends State<SearchForm> {
width:
queryData
.
size
.
width
*
0.8
,
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8.0
),
child:
SearchBar
(
hintText:
"Enter keywords..."
,
elevation:
WidgetStateProperty
.
all
(
0
),
onChanged:
(
value
)
=>
Provider
.
of
<
BookProvider
>(
context
,
listen:
false
).
searchBook
(
value
),
onChanged:
(
value
)
{
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 @
99c75c17
...
...
@@ -14,6 +14,7 @@ class LoanItem extends StatelessWidget {
final
loanDate
=
formater
.
format
(
DateTime
.
parse
(
_loan
.
loanDate
));
final
dueDate
=
formater
.
format
(
DateTime
.
parse
(
_loan
.
dueDate
));
final
remainingDays
=
_loan
.
remainingDays
;
final
isOverdue
=
_loan
.
isOverdue
;
final
bookTitle
=
_loan
.
book
.
title
;
return
Container
(
...
...
@@ -30,9 +31,11 @@ class LoanItem extends StatelessWidget {
margin:
const
EdgeInsets
.
only
(
bottom:
10.0
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
20.0
),
color:
Theme
.
of
(
context
).
primaryColor
),
color:
!
isOverdue
?
Theme
.
of
(
context
).
primaryColor
:
Colors
.
red
,
),
child:
Text
(
remainingDays
,
!
isOverdue
?
remainingDays
:
"Overdued"
,
style:
const
TextStyle
(
fontSize:
12.0
,
color:
Colors
.
white
),
),
),
...
...
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