-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13b7d38
commit 2aa36ba
Showing
7 changed files
with
110 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:gogrocy/core/enums/viewstate.dart'; | ||
import 'package:gogrocy/core/models/ProductsByCity.dart'; | ||
import 'package:gogrocy/core/models/product.dart'; | ||
import 'package:gogrocy/core/services/api.dart'; | ||
import 'package:gogrocy/core/viewModels/base_model.dart'; | ||
import 'package:gogrocy/service_locator.dart'; | ||
|
||
class SearchViewModel extends BaseModel{ | ||
Apis _apis=locator<Apis>(); | ||
|
||
ProductsByCity searchResults; | ||
|
||
Future getAllProducts(String query) async{ | ||
setState(ViewState.Busy); | ||
searchResults=await _apis.searchProductByCity(query); | ||
//allProducts.result.shuffle(); | ||
setState(ViewState.Idle); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:gogrocy/core/services/navigation_service.dart'; | ||
import 'package:gogrocy/service_locator.dart'; | ||
import 'package:simple_search_bar/simple_search_bar.dart'; | ||
|
||
class SearchView extends StatelessWidget { | ||
|
||
final AppBarController appBarController = AppBarController(); | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea(child: Scaffold( | ||
appBar: SearchAppBar( | ||
primary: Theme.of(context).primaryColor, | ||
appBarController: appBarController, | ||
// You could load the bar with search already active | ||
autoSelected: true, | ||
searchHint: "Pesquise aqui...", | ||
mainTextColor: Colors.white, | ||
onChange: (String value) { | ||
//Your function to filter list. It should interact with | ||
//the Stream that generate the final list | ||
}, | ||
//Will show when SEARCH MODE wasn't active | ||
mainAppBar: AppBar( | ||
title: Text("Yout Bar Title"), | ||
actions: <Widget>[ | ||
InkWell( | ||
child: Icon( | ||
Icons.search, | ||
), | ||
onTap: () { | ||
//This is where You change to SEARCH MODE. To hide, just | ||
//add FALSE as value on the stream | ||
appBarController.stream.add(true); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters