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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DAI Leslie
AtClub
Commits
240d0fb6
Commit
240d0fb6
authored
1 year ago
by
DAI Leslie
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.imt-atlantique.fr/l23dai/codev
parents
0155ebf3
85101819
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide 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 @
240d0fb6
...
...
@@ -7,12 +7,12 @@ class RechercheProfil extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Colors
.
transparent
,
elevation:
0
,
// Pas d'ombre
iconTheme:
IconThemeData
(
color:
AppColor
.
deepBlue
),
),
body:
SearchBar
(),
// Affichage de la barre de recherche
appBar:
AppBar
(
backgroundColor:
Colors
.
transparent
,
elevation:
0
,
// Pas d'ombre
iconTheme:
IconThemeData
(
color:
AppColor
.
deepBlue
),
),
body:
SearchBar
(),
// Affichage de la barre de recherche
);
}
}
...
...
@@ -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
});
}
else
{
setState
(()
{
_isError
=
false
;
// Définir l'état de l'erreur sur false
_profiles
=
profil
;
// Mettre à jour la liste des profils
});
return
;
// Sortir de la méthode si le profil est vide
}
}
// 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,9 +99,26 @@ 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
),
);
},
),
),
],
)
)
,
),
);
}
}
\ No newline at end of file
}
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