-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update search bar design and integrate state controllers
- Loading branch information
1 parent
51250f7
commit cbd9f53
Showing
3 changed files
with
45 additions
and
7 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
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 |
---|---|---|
@@ -1,24 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:memoree_client/app/models/drawer_state.dart'; | ||
import 'package:memoree_client/app/models/search_state.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class SearchWidget extends StatefulWidget { | ||
@override | ||
_SearchWidgetState createState() => _SearchWidgetState(); | ||
} | ||
|
||
class _SearchWidgetState extends State<SearchWidget> { | ||
TextEditingController _textController; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
void initState() { | ||
super.initState(); | ||
_textController = TextEditingController(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_textController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
void _updateSearchQuery(input) { | ||
setState(() { | ||
Provider.of<SearchModel>(context, listen: false).updateQuery(input); | ||
Provider.of<DrawerModel>(context, listen: false).home(); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TextFormField( | ||
decoration: InputDecoration( | ||
labelText: "Search", | ||
filled: true, | ||
contentPadding: EdgeInsets.all(10.0), | ||
prefixIcon: Icon(Icons.search), | ||
border: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(7.0), | ||
borderSide: new BorderSide() | ||
) | ||
borderSide: BorderSide.none, | ||
), | ||
focusedBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(7.0), | ||
borderSide: BorderSide(), | ||
), | ||
), | ||
controller: _textController, | ||
onFieldSubmitted: (input) { | ||
_textController.clear(); | ||
if(input != "") | ||
_updateSearchQuery(input); | ||
}, | ||
); | ||
} | ||
} | ||
} |