Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team 37
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Om Akbari (nzc174)
Team 37
Commits
ba813665
You need to sign in or sign up before continuing.
Commit
ba813665
authored
3 years ago
by
Harshil Patel
Browse files
Options
Downloads
Patches
Plain Diff
"Implemented minimal serach bar for product search"
parent
e8636591
No related branches found
No related tags found
1 merge request
!3
Main product
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/providers/product_provider.dart
+9
-0
9 additions, 0 deletions
lib/providers/product_provider.dart
lib/screens/home_screens/home_screen.dart
+3
-1
3 additions, 1 deletion
lib/screens/home_screens/home_screen.dart
lib/screens/search/search.dart
+39
-10
39 additions, 10 deletions
lib/screens/search/search.dart
with
51 additions
and
11 deletions
lib/providers/product_provider.dart
+
9
−
0
View file @
ba813665
...
...
@@ -6,12 +6,14 @@ import 'package:food_app/models/product_model.dart';
class
ProductProvider
with
ChangeNotifier
{
ProductModel
productModel
;
List
<
ProductModel
>
search
=
[];
productModels
(
QueryDocumentSnapshot
element
)
{
productModel
=
ProductModel
(
productImage:
element
.
get
(
"productImage"
),
productName:
element
.
get
(
"productName"
),
productPrice:
element
.
get
(
"productPrice"
),
);
search
.
add
(
productModel
);
}
// Display Herbs Drawer
...
...
@@ -81,4 +83,11 @@ class ProductProvider with ChangeNotifier {
List
<
ProductModel
>
get
getRootProductDataList
{
return
rootProductList
;
}
// Search Return
List
<
ProductModel
>
get
getAllProductSearch
{
return
search
;
}
}
This diff is collapsed.
Click to expand it.
lib/screens/home_screens/home_screen.dart
+
3
−
1
View file @
ba813665
...
...
@@ -224,7 +224,9 @@ class _HomeScreenState extends State<HomeScreen> {
onPressed:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
=
>
Search
(),
builder:
(
context
)
=
>
Search
(
search:
productProvider
.
getAllProductSearch
,
),
),
);
},
...
...
This diff is collapsed.
Click to expand it.
lib/screens/search/search.dart
+
39
−
10
View file @
ba813665
import
'package:flutter/material.dart'
;
import
'package:food_app/config/colors.dart'
;
import
'package:food_app/models/product_model.dart'
;
import
'package:food_app/widgets/single_item.dart'
;
...
...
@@ -12,10 +13,20 @@ class Search extends StatefulWidget {
}
class
_SearchState
extends
State
<
Search
>
{
String
query
=
""
;
SigninCharacter
_character
=
SigninCharacter
.
alphabetically
;
searchItem
(
String
query
)
{
List
<
ProductModel
>
searhFood
=
widget
.
search
.
where
((
element
)
{
return
element
.
productName
.
toLowerCase
()
.
contains
(
query
);
})
.
toList
();
return
searhFood
;
}
@override
Widget
build
(
BuildContext
context
)
{
List
<
ProductModel
>
_searchItem
=
searchItem
(
query
);
void
bottomShet
()
=
>
showModalBottomSheet
(
context:
context
,
shape:
RoundedRectangleBorder
(
...
...
@@ -55,15 +66,28 @@ class _SearchState extends State<Search> {
Navigator
.
of
(
context
)
.
pop
();
}),
RadioListTile
(
value:
SigninCharacter
.
alphabetically
,
groupValue:
_character
,
title:
Text
(
"Price - Alphabetically"
),
onChanged:
(
vav
)
{
setState
(()
{
_character
=
vav
;
});
Navigator
.
of
(
context
)
.
pop
();
}),
value:
SigninCharacter
.
alphabetically
,
groupValue:
_character
,
title:
Text
(
"Price - Alphabetically"
),
onChanged:
(
vav
)
{
setState
(()
{
_character
=
vav
;
});
Navigator
.
of
(
context
)
.
pop
();
},
),
Container
(
height:
46
,
margin:
EdgeInsets
.
symmetric
(
vertical:
20
,
horizontal:
20
),
width:
double
.
infinity
,
child:
MaterialButton
(
child:
Text
(
"Submit"
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
30
)),
color:
primaryColor
,
onPressed:
()
{},
),
)
],
);
});
...
...
@@ -86,6 +110,11 @@ class _SearchState extends State<Search> {
height:
52
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
20
),
child:
TextField
(
onChanged:
(
value
)
{
setState
(()
{
query
=
value
;
});
},
decoration:
InputDecoration
(
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
30
),
...
...
@@ -102,7 +131,7 @@ class _SearchState extends State<Search> {
height:
10
,
),
Column
(
children:
widget
.
search
.
map
((
data
)
{
children:
_
search
Item
.
map
((
data
)
{
return
SingleItem
(
isBool:
false
,
productImage:
data
.
productImage
,
...
...
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