Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AtClub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DAI Leslie
AtClub
Commits
85101819
Commit
85101819
authored
1 year ago
by
RENAULT Juliette
Browse files
Options
Downloads
Patches
Plain Diff
modif recherche profil pour que ce soit plus utilisable
parent
383ab573
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
atlub/lib/Pages/recherche_profil.dart
+41
-15
41 additions, 15 deletions
atlub/lib/Pages/recherche_profil.dart
with
41 additions
and
15 deletions
atlub/lib/Pages/recherche_profil.dart
+
41
−
15
View file @
85101819
...
...
@@ -25,6 +25,7 @@ class SearchBar extends StatefulWidget {
class
_SearchBarState
extends
State
<
SearchBar
>
{
TextEditingController
_controller
=
TextEditingController
();
bool
_isError
=
false
;
// Variable pour suivre l'état de l'erreur
List
<
Map
<
String
,
dynamic
>>
_profiles
=
[];
// Liste des profils trouvés
void
_search
()
async
{
// Récupération des données
...
...
@@ -33,21 +34,26 @@ class _SearchBarState extends State<SearchBar> {
// Récupération du profil
DatabaseService
recherche
=
DatabaseService
();
Future
<
List
<
Map
<
String
,
dynamic
>>
>
profil
=
recherche
.
searchProfiles
(
searchText
);
List
<
Map
<
String
,
dynamic
>>
profil
=
await
recherche
.
searchProfiles
(
searchText
);
// Vérifier si le profil est vide
final
isEmpty
=
(
await
profil
)
.
isEmpty
;
if
(
isEmpty
)
{
if
(
profil
.
isEmpty
)
{
setState
(()
{
_isError
=
true
;
// Définir l'état de l'erreur sur true
_profiles
=
[];
// Vider la liste des profils
});
return
;
// Sortir de la méthode si le profil est vide
}
else
{
setState
(()
{
_isError
=
false
;
// Définir l'état de l'erreur sur false
_profiles
=
profil
;
// Mettre à jour la liste des profils
});
}
}
// Affichage du profil en utilisant Navigator pour naviguer vers une nouvelle page
void
_navigateToProfile
(
Map
<
String
,
dynamic
>
profile
)
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=
>
Profil
(
profil:
profil
)),
MaterialPageRoute
(
builder:
(
context
)
=
>
Profil
(
profil:
Future
.
value
([
profil
e
])
)),
);
}
...
...
@@ -60,7 +66,10 @@ class _SearchBarState extends State<SearchBar> {
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
const
Text
(
'Rechercher un profil'
,
style:
TextStyle
(
color:
AppColor
.
violetBlue
,
fontSize:
30
,
fontWeight:
FontWeight
.
bold
),),
const
Text
(
'Rechercher un profil'
,
style:
TextStyle
(
color:
AppColor
.
violetBlue
,
fontSize:
30
,
fontWeight:
FontWeight
.
bold
),
),
SizedBox
(
height:
8.0
),
// Espacement entre le texte et la case de recherche
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
...
...
@@ -90,8 +99,25 @@ class _SearchBarState extends State<SearchBar> {
),
],
),
SizedBox
(
height:
16.0
),
// Espacement entre la barre de recherche et la liste de résultats
Expanded
(
child:
_profiles
.
isEmpty
&&
!
_isError
?
Center
(
child:
Text
(
'Aucun profil trouvé'
))
:
ListView
.
builder
(
itemCount:
_profiles
.
length
,
itemBuilder:
(
context
,
index
)
{
final
profile
=
_profiles
[
index
];
final
nom
=
profile
[
'nom'
]
??
'Nom inconnu'
;
final
prenom
=
profile
[
'prenom'
]
??
'Prénom inconnu'
;
return
ListTile
(
title:
Text
(
'
$nom
$prenom
'
),
onTap:
()
=
>
_navigateToProfile
(
profile
),
);
},
),
),
],
)
)
,
),
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment