flutter tabbar

import 'package:flutter/material.dart';

import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:day_dream/utils/translate_util.dart' as T;
import 'package:day_dream/common/utils/px_utils.dart';

class MainRecommendCity extends StatefulWidget {
  @override
  _MainRecommendCityState createState() => _MainRecommendCityState();
}

class _MainRecommendCityState extends State<MainRecommendCity>
    with SingleTickerProviderStateMixin {
  TextStyle tabStyle = TextStyle(fontSize: sp(36), fontWeight: FontWeight.w400);
  TabController _tabController2;
  List tabs = ["全部", "男生", "女生"];
  List list=["确认","取消"];
  TabController _tabController;//初始化、、、

  @override
  void initState() {
    super.initState();
    // 创建Controller
    _tabController = TabController(length: tabs.length, vsync: this);//初始化
   // _tabController2=TabController(length: list.length, vsync: this);
   //设置点击事件
    _tabController.addListener(() {
      switch (_tabController.index) {
        case 1:
          break;
        case 2:
          break;
        case 3:
          break;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("附近搜索"),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.settings, color: Colors.white), //自定义图标
            onPressed: () {
              // 打开抽屉菜单
              // Scaffold.of(context).openDrawer();
              showModalBottomSheet(
                  context: context,
                  isScrollControlled: false,
                  backgroundColor: Colors.white,
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(10))),
                  builder: (BuildContext context) {
                    return Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Text("筛选设置"),
                        Align(
                            alignment: Alignment.centerLeft,
                         // left:1.0,
                            child: Text("想看到的用户")),
                        Center(
                          child: TabBar(
                            controller: _tabController,
                            tabs: tabs.map((e) => Tab(text: e)).toList()


                            ,
                            indicator: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(w(100))),//圆角
                                color: Color.fromARGB(255, 0x15, 0x15, 0x15)),
                            labelColor: Colors.white,
                            unselectedLabelColor:
                                Color.fromARGB(255, 0x15, 0x15, 0x15),
                          ),
//                    child: Row(
//                        crossAxisAlignment: CrossAxisAlignment.center,
//                        children: <Widget>[
//                          Expanded(flex: 1, child:
//                          OutlineButton(
//                            child: Text("全部"),
//                            shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
//                            onPressed: () {},
//                          )),
//                          Expanded(flex: 1, child:
//                          OutlineButton(
//                            child: Text("男性"),
//                            shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
//                            onPressed: () {},
//                          )),
//                          Expanded(
//                              flex: 1,
//                              child: OutlineButton(
//                                child: Text("女性"),
//                               //  highlightColor :Colors.black,
//                                shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
//                                onPressed: () {},
//                              )),
//                        ]
//
//                    ),
                        ),
                        Center(
                          child:
//                          TabBar(
//                            controller: _tabController2,
//                            tabs: list.map((e) => Tab(text: e)).toList()
//
//
//                            ,
//                            indicator: BoxDecoration(
//                                borderRadius:
//                                BorderRadius.all(Radius.circular(w(100))),
//                                color: Color.fromARGB(255, 0x15, 0x15, 0x15)),
//                            labelColor: Colors.white,
//                            unselectedLabelColor:
//                            Color.fromARGB(255, 0x15, 0x15, 0x15),
//                          ),

                          Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Expanded(
                                  flex: 1,
                                  child: Align(
                                      alignment: Alignment.bottomLeft,
                                      child: OutlineButton(
                                        child: Text("取消"),
                                        shape: RoundedRectangleBorder(
                                            borderRadius:
                                                BorderRadius.circular(20.0)),
                                        onPressed: () {},
                                      ))),
                              Expanded(
                                  flex: 1,
                                  child: Align(
                                      alignment: Alignment.bottomRight,
                                      child: OutlineButton(
                                        disabledBorderColor: Colors.black,
                                        shape: RoundedRectangleBorder(
                                            borderRadius: BorderRadius.circular(
                                                20.0)), //圆角
                                        child: Text("确认"),
                                        onPressed: () {},
                                      )))
                            ],
                          ),
                        ),
                      ],
                    );
                  });
            },
          )
        ],
      ),
      body:AmapView()//Text("1")// AmapView(),
    );
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值