|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import 'dart:convert';
-
- import 'package:flutter/material.dart';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:tab_indicator_styler/tab_indicator_styler.dart';
- import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
- import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_sk.dart';
- import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart';
-
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- import 'model/search_tab_model.dart';
-
- class SearchTabWidget extends StatefulWidget {
- final Map<String, dynamic> data;
- SearchTabModel model;
-
- SearchTabWidget(this.data, {Key key}) : super(key: key) {
- try {
- model = SearchTabModel.fromJson(jsonDecode(data['data']));
- } catch (e) {
- Logger.error(e.toString());
- }
- }
-
- @override
- _SearchTabWidgetState createState() => _SearchTabWidgetState();
- }
-
- class _SearchTabWidgetState extends State<SearchTabWidget> {
- TabController _tabController;
- int _currentIndex = 0;
-
- @override
- void initState() {
- _tabController = TabController(length: widget?.model?.search_icon_list?.length ?? 0, vsync: ScrollableState())..addListener((){
- setState(()=> _currentIndex = _tabController.index);
- });
- super.initState();
- }
-
- @override
- void dispose() {
- _tabController?.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return _getMainWidget(widget?.model);
- }
-
- /// 获取主视图
- Widget _getMainWidget(SearchTabModel model) {
- return Visibility(
- replacement: SearchTabSkeleton(),
- visible: !EmptyUtil.isEmpty(model),
- child: _getTabar(model),
- );
- }
-
- /// 获取TabBar
- Widget _getTabar(SearchTabModel model) {
- return Container(
- margin: const EdgeInsets.only(left: 12.5, right: 12.5, top: 20),
- child: TabBar(
- controller: _tabController,
- isScrollable: true,
- labelStyle: TextStyle( fontSize: 14),
- unselectedLabelColor: HexColor.fromHex('#999999'),
- labelColor: HexColor.fromHex('#FF4242'),
- // indicatorSize: TabBarIndicatorSize.label,
- indicator: MaterialIndicator(
- height: 2.5,
- topLeftRadius: 8,
- topRightRadius: 8,
- bottomLeftRadius: 8,
- bottomRightRadius: 8,
- color: HexColor.fromHex('#FF4242'),
- horizontalPadding: 25,
- ),
- tabs: model.search_icon_list.map((item) {
- return MyTab(
- icon: CachedNetworkImage(imageUrl: item?.with_icon_color ?? '', width: 14,),
- text: item.name,
- );
- }).toList(),
- ),
- );
- }
- }
-
-
- class SearchTabItemWidget extends StatelessWidget {
- final bool isSelect;
- final SearchTabItemModel model;
-
- const SearchTabItemWidget(this.isSelect, this.model);
-
- @override
- Widget build(BuildContext context) {
- return Container();
- }
- }
-
|