From 8eeb37c28c18cc181878b58621650ddb3c149137 Mon Sep 17 00:00:00 2001 From: Daniel Borges Date: Tue, 6 Aug 2019 17:05:59 -0300 Subject: [PATCH] search page layout --- lib/src/resources/openlp_icons.dart | 9 ++ .../widgets/service_item_bottom_sheet.dart | 3 + lib/src/widgets/service_item_search.dart | 86 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 lib/src/resources/openlp_icons.dart create mode 100644 lib/src/widgets/service_item_search.dart diff --git a/lib/src/resources/openlp_icons.dart b/lib/src/resources/openlp_icons.dart new file mode 100644 index 0000000..a4945f3 --- /dev/null +++ b/lib/src/resources/openlp_icons.dart @@ -0,0 +1,9 @@ +import 'package:flutter/material.dart'; + +class OpenLPIcons { + final IconData songs = Icons.audiotrack; + final IconData biblies = Icons.book; + final IconData presentations = Icons.present_to_all; + final IconData media = Icons.ondemand_video; + final IconData custom = Icons.video_label; +} diff --git a/lib/src/widgets/service_item_bottom_sheet.dart b/lib/src/widgets/service_item_bottom_sheet.dart index 262e48e..6984759 100644 --- a/lib/src/widgets/service_item_bottom_sheet.dart +++ b/lib/src/widgets/service_item_bottom_sheet.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'service_item_search.dart'; + class _ServiceItem { IconData icon; String title; @@ -23,6 +25,7 @@ class ServiceItemBottomSheet extends StatelessWidget { title: Text(item.title), onTap: () { Navigator.of(context).pop(); + showSearch(context: context, delegate: ServiceItemSearch()); }, ); }).toList(), diff --git a/lib/src/widgets/service_item_search.dart b/lib/src/widgets/service_item_search.dart new file mode 100644 index 0000000..e15bee4 --- /dev/null +++ b/lib/src/widgets/service_item_search.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; + +class ServiceItemSearch extends SearchDelegate { + @override + List buildActions(BuildContext context) { + return null; + } + + @override + Widget buildLeading(BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + close(context, null); + }, + ); + } + + void _showOptions(BuildContext context) { + showModalBottomSheet( + context: context, + builder: (context) => Wrap( + alignment: WrapAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(15), + child: Text( + query, + style: Theme.of(context).textTheme.title, + textAlign: TextAlign.center, + ), + ), + ListTile( + title: Text('Go live'), + onTap: () { + Navigator.of(context).pop(); + close(context, null); + }, + ), + ListTile( + title: Text('Add to service'), + onTap: () { + Navigator.of(context).pop(); + }, + ), + ListTile( + title: Text('Add & Go to service'), + onTap: () { + Navigator.of(context).pop(); + close(context, null); + }, + ), + ], + ), + ); + } + + Widget _resultList(BuildContext context) { + if (query.isEmpty) { + return Container(); + } + return ListView.builder( + itemCount: 5, + itemBuilder: (context, i) { + return ListTile( + title: Text(query), + onTap: () { + _showOptions(context); + }, + ); + }, + ); + } + + @override + Widget buildResults(BuildContext context) { + print('buildResults - query: $query'); + return _resultList(context); + } + + @override + Widget buildSuggestions(BuildContext context) { + print('buildSuggestions - query: $query'); + return _resultList(context); + } +}