“yanghuaxuan” 3 jaren geleden
bovenliggende
commit
a18bbe84c1
5 gewijzigde bestanden met toevoegingen van 58 en 39 verwijderingen
  1. +2
    -1
      lib/pages/custom_page/bloc/custom_page_bloc.dart
  2. +46
    -37
      lib/pages/search_page/search_page.dart
  3. +1
    -1
      lib/widgets/custom/search/custom_search_widget.dart
  4. +4
    -0
      lib/widgets/custom/search/model/custom_search_model.dart
  5. +5
    -0
      lib/widgets/search/tabbar/search_tab_widget.dart

+ 2
- 1
lib/pages/custom_page/bloc/custom_page_bloc.dart Bestand weergeven

@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';

import 'package:bloc/bloc.dart';
import 'custom_page_event.dart';
@@ -55,7 +56,7 @@ class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> {
var result = await repository.fetchInitData();
List<Map<String, dynamic>> mdata = result.modList;
for (int i = 0; i < mdata.length; i++) {
Logger.log("页面数据: " + mdata[i].toString());
Logger.log("页面数据: " + json.encode(mdata[i]));
}
if (!EmptyUtil.isEmpty(result) && result is CustomPageData) {
yield CustomPageLoadedState(model: result.modList,backgroundModel: result.backgroundModel);


+ 46
- 37
lib/pages/search_page/search_page.dart Bestand weergeven

@@ -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;
// }
}

+ 1
- 1
lib/widgets/custom/search/custom_search_widget.dart Bestand weergeven

@@ -22,7 +22,7 @@ class CustomSearchWidget extends StatelessWidget {
// 点击事件
void _onClickListener(BuildContext context, SkipModel skipModel) {
if (!EmptyUtil.isEmpty(skipModel)) {
RouterUtil.route(skipModel, skipModel.toJson(), context);
RouterUtil.route(skipModel, model.toJson(), context);
}
}



+ 4
- 0
lib/widgets/custom/search/model/custom_search_model.dart Bestand weergeven

@@ -15,6 +15,7 @@ class CustomSearchModel {
String bottomLeftRadius;
String bottomRightRadius;
String bgColor;
String default_pvd;
ListStyle listStyle;

CustomSearchModel({
@@ -28,6 +29,7 @@ class CustomSearchModel {
this.topMargin,
this.leftRightMargin,
this.bgColor,
this.default_pvd,
this.listStyle,
this.topLeftRadius,
this.topRightRadius,
@@ -46,6 +48,7 @@ class CustomSearchModel {
topMargin = json['top_margin'];
leftRightMargin = json['left_right_margin'];
bgColor = json['bg_color'];
default_pvd=json['default_pvd'];
topLeftRadius = json['top_left_radius'];
topRightRadius = json['top_right_radius'];
bottomLeftRadius = json['bottom_left_radius'];
@@ -65,6 +68,7 @@ class CustomSearchModel {
data['top_margin'] = this.topMargin;
data['left_right_margin'] = this.leftRightMargin;
data['bg_color'] = this.bgColor;
data['default_pvd']=this.default_pvd;
data['top_left_radius'] = this.topLeftRadius;
data['top_right_radius'] = this.topRightRadius;
data['bottom_left_radius'] = this.bottomLeftRadius;


+ 5
- 0
lib/widgets/search/tabbar/search_tab_widget.dart Bestand weergeven

@@ -68,6 +68,11 @@ class _SearchTabWidgetState extends State<SearchTabWidget> {
}
}
});
for (int i = 0; i < widget?.model?.search_icon_list?.length ?? 0; i++) {
if (Provider.of<SearchTagNotifier>(context, listen: false).getType() == widget?.model?.search_icon_list[i].type) {
_tabController.animateTo(i);
}
}
WidgetsBinding.instance.addPostFrameCallback((_) => setTabSelect());
super.initState();
}


Laden…
Annuleren
Opslaan