From 4dfd1c5e4a4b3afa7c25e84d6da31f54af74d199 Mon Sep 17 00:00:00 2001 From: Jonasz Bigda Date: Sun, 11 Oct 2020 13:20:19 +0200 Subject: [PATCH] Added search bar --- lib/components.dart | 48 +++++++++++++++++++++++++++++++++++++++++++++ lib/main.dart | 13 +++--------- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/lib/components.dart b/lib/components.dart index f1ff1b7..18a6268 100644 --- a/lib/components.dart +++ b/lib/components.dart @@ -58,3 +58,51 @@ class RestaurantCard extends StatelessWidget { ); } } + +class MenuiSearchBar extends StatefulWidget { + @override + MenuiSearchBarState createState() { + return MenuiSearchBarState(); + } +} + +class MenuiSearchBarState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return Form( + key: _formKey, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(12), + child: TextFormField( + style: TextStyle(color: Colors.orange), + decoration: InputDecoration( + hintStyle: TextStyle(color: Colors.grey), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(12)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.orange, width: 2.0), + borderRadius: BorderRadius.circular(12)), + hintText: 'Wyszukaj miasto lub nazwę restauracji.', + suffixIcon: Icon( + Icons.search, + color: Colors.orange, + )), + validator: (value) { + if (value.isEmpty) { + return 'Wpisz coś w pole wyszukiwania.'; + } + return null; + }, + cursorColor: Colors.orange, + ), + ), + ], + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 21b889c..fd3224a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,6 +12,8 @@ class App extends StatelessWidget { title: 'Menui', theme: ThemeData( primarySwatch: Colors.orange, + primaryColor: Colors.orange, + accentColor: Colors.grey, backgroundColor: Colors.grey, visualDensity: VisualDensity.adaptivePlatformDensity, ), @@ -44,16 +46,7 @@ class _HomePageState extends State { "img/logo_mint.png", width: 160, ), - RestaurantCard( - id: 1, - name: "Pierożek", - city: "Mikołajki", - ), - RestaurantCard( - id: 2, - name: "Kuchnie Świata", - city: "Mikołajki", - ) + MenuiSearchBar() ], ), ),