|
|
@@ -1,3 +1,5 @@ |
|
|
|
import 'dart:convert'; |
|
|
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/search_page/notifier/search_tag_notifier.dart'; |
|
|
@@ -20,14 +22,10 @@ class SearchPage extends StatelessWidget { |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Logger.log("数据: "+data.toString()); |
|
|
|
return MultiProvider( |
|
|
|
providers: [ |
|
|
|
ChangeNotifierProvider.value(value: SearchTagNotifier()) |
|
|
|
], |
|
|
|
providers: [ChangeNotifierProvider.value(value: SearchTagNotifier())], |
|
|
|
child: MultiProvider( |
|
|
|
providers: [ |
|
|
|
|
|
|
|
/// 搜索页面的bloc |
|
|
|
BlocProvider<SearchBloc>( |
|
|
|
create: (_) => SearchBloc(repository: SearchRepository())..add(SearchInitEvent(model: data)), |
|
|
@@ -35,11 +33,12 @@ class SearchPage extends StatelessWidget { |
|
|
|
|
|
|
|
/// 输入框联想的bloc |
|
|
|
BlocProvider<SearchThinkBloc>( |
|
|
|
create: (_)=> SearchThinkBloc(SearchThinkRepository()), |
|
|
|
create: (_) => SearchThinkBloc(SearchThinkRepository()), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
child: SearchPageContianer(), |
|
|
|
child: SearchPageContianer( |
|
|
|
data: data, |
|
|
|
), |
|
|
|
), |
|
|
|
// child: BlocProvider<SearchBloc>( |
|
|
|
// create: (_) => SearchBloc(repository: SearchRepository())..add(SearchInitEvent(model: data)), |
|
|
@@ -50,6 +49,10 @@ class SearchPage extends StatelessWidget { |
|
|
|
} |
|
|
|
|
|
|
|
class SearchPageContianer extends StatefulWidget { |
|
|
|
final Map<String, dynamic> data; |
|
|
|
|
|
|
|
const SearchPageContianer({Key key, this.data}) : super(key: key); |
|
|
|
|
|
|
|
@override |
|
|
|
_SearchPageContianerState createState() => _SearchPageContianerState(); |
|
|
|
} |
|
|
@@ -72,6 +75,12 @@ class _SearchPageContianerState extends State<SearchPageContianer> { |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
//设置搜索bar应该选择哪个type的item |
|
|
|
Logger.log("数据2: " + json.encode(widget.data)); |
|
|
|
Logger.log("类型: " + widget.data['default_pvd']); |
|
|
|
if(!EmptyUtil.isEmpty(widget.data['default_pvd'])){ |
|
|
|
Provider.of<SearchTagNotifier>(context, listen: false).setType(widget.data['default_pvd']); |
|
|
|
} |
|
|
|
return MediaQuery.removePadding( |
|
|
|
removeTop: true, |
|
|
|
context: context, |
|
|
@@ -158,33 +167,33 @@ class _SearchPageContianerState extends State<SearchPageContianer> { |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
// List<Widget> _createContent(BuildContext context, List<Map<String, dynamic>> datas) { |
|
|
|
// List<Widget> list = List(); |
|
|
|
// |
|
|
|
// int length = datas?.length ?? 0; |
|
|
|
// |
|
|
|
// if (length <= 0) { |
|
|
|
// list.add(SliverToBoxAdapter( |
|
|
|
// child: Container( |
|
|
|
// height: 200, |
|
|
|
// child: Center( |
|
|
|
// child: Text('暂时无数据哦~'), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// )); |
|
|
|
// return list; |
|
|
|
// } |
|
|
|
// |
|
|
|
// for (int i = 0; i < 3; i++) { |
|
|
|
// WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); |
|
|
|
// print('item.modName ${item.modName}'); |
|
|
|
// list.addAll(WidgetFactory.create( |
|
|
|
// item.modName, |
|
|
|
// isSliver: true, |
|
|
|
// model: datas[i], |
|
|
|
// )); |
|
|
|
// } |
|
|
|
// |
|
|
|
// return list; |
|
|
|
// } |
|
|
|
// List<Widget> _createContent(BuildContext context, List<Map<String, dynamic>> datas) { |
|
|
|
// List<Widget> list = List(); |
|
|
|
// |
|
|
|
// int length = datas?.length ?? 0; |
|
|
|
// |
|
|
|
// if (length <= 0) { |
|
|
|
// list.add(SliverToBoxAdapter( |
|
|
|
// child: Container( |
|
|
|
// height: 200, |
|
|
|
// child: Center( |
|
|
|
// child: Text('暂时无数据哦~'), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// )); |
|
|
|
// return list; |
|
|
|
// } |
|
|
|
// |
|
|
|
// for (int i = 0; i < 3; i++) { |
|
|
|
// WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); |
|
|
|
// print('item.modName ${item.modName}'); |
|
|
|
// list.addAll(WidgetFactory.create( |
|
|
|
// item.modName, |
|
|
|
// isSliver: true, |
|
|
|
// model: datas[i], |
|
|
|
// )); |
|
|
|
// } |
|
|
|
// |
|
|
|
// return list; |
|
|
|
// } |
|
|
|
} |