Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amse
Project
Project
Details
Activity
Releases
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
Matis SPINELLI
amse
Commits
1393677b
Commit
1393677b
authored
Feb 12, 2024
by
Timothé KOBAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
categories but ?
parent
0fd135d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
favorite_page.dart
tp1/lib/favorite_page.dart
+30
-3
No files found.
tp1/lib/favorite_page.dart
View file @
1393677b
...
...
@@ -2,7 +2,14 @@ import 'package:flutter/material.dart';
import
'package:provider/provider.dart'
;
import
'app_state.dart'
;
class
FavoritePage
extends
StatelessWidget
{
class
FavoritePage
extends
StatefulWidget
{
@override
_FavoritePageState
createState
()
=>
_FavoritePageState
();
}
class
_FavoritePageState
extends
State
<
FavoritePage
>
{
String
?
selectedCategory
;
@override
Widget
build
(
BuildContext
context
)
{
TindBookState
state
=
Provider
.
of
<
TindBookState
>(
context
);
...
...
@@ -10,6 +17,22 @@ class FavoritePage extends StatelessWidget {
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Favorite Books'
),
actions:
[
DropdownButton
<
String
>(
value:
selectedCategory
,
onChanged:
(
String
?
newValue
)
{
setState
(()
{
selectedCategory
=
newValue
;
});
},
items:
state
.
uniqueCategories
.
map
((
String
category
)
{
return
DropdownMenuItem
<
String
>(
value:
category
,
child:
Text
(
category
),
);
}).
toList
(),
),
],
),
body:
GridView
.
builder
(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
...
...
@@ -18,19 +41,23 @@ class FavoritePage extends StatelessWidget {
),
itemCount:
state
.
favorites
.
length
,
itemBuilder:
(
context
,
index
)
{
Map
<
String
,
dynamic
>
book
=
state
.
getFav
(
index
);
if
(
selectedCategory
!=
null
&&
book
[
'category'
]
!=
selectedCategory
)
{
return
Container
();
// Return an empty container if the book doesn't belong to the selected category
}
return
GestureDetector
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
ImageScreen
(
book:
state
.
getFav
(
index
)
),
builder:
(
context
)
=>
ImageScreen
(
book:
book
),
),
);
},
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Image
.
asset
(
state
.
getFav
(
index
)
[
'image'
],
book
[
'image'
],
fit:
BoxFit
.
cover
,
),
),
...
...
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