diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index d563f2a..47a2086 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -19,7 +19,7 @@ class HomePage extends GetView{ ), InkWell( onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (context) => const SearchPage())); + Navigator.push(context, MaterialPageRoute(builder: (context) => SearchPage())); }, child: Container( height: 32, diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index a7c3206..7d8c83c 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -25,27 +25,42 @@ class IndexPage extends GetView { return Scaffold( drawer: const DrawerPage(), appBar: AppBar( - // leading: IconButton( - // icon: Icon(Icons.arrow_back_ios), - // onPressed: (){ - // indexController.switchPage(AppPages.TRAVEL); - // }, - // ), + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: (){ + indexController.switchPage(AppPages.TRAVEL); + }, + ), //automaticallyImplyLeading: false, title: Text("Add locations"), actions: [ - RaisedButton( - child: Text("db"), - onPressed: (){ - DatabaseHelper db = DatabaseHelper.instance; - db.getDestinations().then((value){ - print("-------- lendth in db ${value.length} ---- :::::"); - for(Destination d in value){ - print("-------- values in db are ${d.checkedin} ---- :::::"); - }; - }); - }, - ), + InkWell( + onTap: (){ + Get.toNamed(AppPages.SEARCH); + }, + child: Container( + height: 32, + width: 75, + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.circular(25), + + ), + child: const Center(child: Icon(Icons.search),), + ), + ), + // RaisedButton( + // child: Text("db"), + // onPressed: (){ + // DatabaseHelper db = DatabaseHelper.instance; + // db.getDestinations().then((value){ + // print("-------- lendth in db ${value.length} ---- :::::"); + // for(Destination d in value){ + // print("-------- values in db are ${d.checkedin} ---- :::::"); + // }; + // }); + // }, + // ), CatWidget(indexController: indexController,), ], ), diff --git a/lib/pages/search/search_binding.dart b/lib/pages/search/search_binding.dart new file mode 100644 index 0000000..09cde26 --- /dev/null +++ b/lib/pages/search/search_binding.dart @@ -0,0 +1,9 @@ +import 'package:get/get.dart'; +import 'package:rogapp/pages/search/search_controller.dart'; + +class SearchBinding extends Bindings { + @override + void dependencies() { + Get.put(SearchController()); + } +} diff --git a/lib/pages/search/search_controller.dart b/lib/pages/search/search_controller.dart new file mode 100644 index 0000000..bf36e0b --- /dev/null +++ b/lib/pages/search/search_controller.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:geojson/geojson.dart'; +import 'package:get/get.dart'; +import 'package:get/get_state_manager/get_state_manager.dart'; +import 'package:rogapp/model/destination.dart'; +import 'package:rogapp/pages/index/index_controller.dart'; + +class SearchController extends GetxController { + +List searchResults = [].obs; + + +@override + void onInit() { + IndexController indexController = Get.find(); + indexController.locations.addAll(indexController.locations); + super.onInit(); + } + + +} \ No newline at end of file diff --git a/lib/pages/search/search_page.dart b/lib/pages/search/search_page.dart index 4622277..12d1c87 100644 --- a/lib/pages/search/search_page.dart +++ b/lib/pages/search/search_page.dart @@ -1,10 +1,12 @@ - - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:rogapp/pages/search/search_controller.dart'; class SearchPage extends StatelessWidget { - const SearchPage({Key? key}) : super(key: key); + SearchPage({Key? key}) : super(key: key); + + SearchController searchController = Get.find(); @override Widget build(BuildContext context) { @@ -20,6 +22,14 @@ class SearchPage extends StatelessWidget { title: const CupertinoSearchTextField(), ), + body: Obx(() => + ListView.builder( + itemCount: searchController.searchResults.length, + itemBuilder: (context, index){ + return Text("hello"); + }, + ), + ) ); } } \ No newline at end of file diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 16b3828..05a59ae 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -12,6 +12,7 @@ import 'package:rogapp/pages/loading/loading_page.dart'; import 'package:rogapp/pages/login/login_page.dart'; import 'package:rogapp/pages/permission/permission.dart'; import 'package:rogapp/pages/register/register_page.dart'; +import 'package:rogapp/pages/search/search_page.dart'; import 'package:rogapp/spa/spa_binding.dart'; import 'package:rogapp/spa/spa_page.dart'; @@ -32,6 +33,7 @@ class AppPages { static const DESTINATION_MAP = Routes.DESTINATION_MAP; static const HOME = Routes.HOME; static const PERMISSION = Routes.PERMISSION; + static const SEARCH = Routes.SEARCH; static final routes = [ // GetPage( @@ -92,6 +94,10 @@ class AppPages { GetPage( name: Routes.PERMISSION, page: () => PermissionHandlerScreen(), + ), + GetPage( + name: Routes.SEARCH, + page: () => SearchPage(), ) ]; } \ No newline at end of file diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 232930f..b35c75f 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -16,4 +16,5 @@ abstract class Routes { static const DESTINATION_MAP = '/destination_map'; static const HOME = '/home'; static const PERMISSION = '/permission'; + static const SEARCH = '/search'; } diff --git a/lib/widgets/fake_search.dart b/lib/widgets/fake_search.dart index 8cc1777..6c42961 100644 --- a/lib/widgets/fake_search.dart +++ b/lib/widgets/fake_search.dart @@ -10,7 +10,7 @@ class FakeSearch extends StatelessWidget { Widget build(BuildContext context) { return InkWell( onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (context) => const SearchPage())); + Navigator.push(context, MaterialPageRoute(builder: (context) => SearchPage())); }, child: Container( height: 35,