123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import 'package:farmer_client/pages/home/widgets/home/widgets/headers.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:get/get.dart';
  5. import '../../models/entities/CardTypeModel.dart';
  6. import '../../services/homeAPI.dart';
  7. import '../../widgets/CarsCard.dart';
  8. import '../../widgets/Search.dart';
  9. class MoreCars extends StatefulWidget {
  10. const MoreCars({Key? key}) : super(key: key);
  11. @override
  12. State<MoreCars> createState() => _MoreCarsState();
  13. }
  14. class _MoreCarsState extends State<MoreCars> with TickerProviderStateMixin {
  15. late TabController _controller = TabController(length: tabText.value.length, vsync: this);
  16. final tabText = Rx<List<CardTypeModel>>([]);
  17. @override
  18. void initState() {
  19. // TODO: implement initState
  20. super.initState();
  21. }
  22. void _geList (){
  23. getMachineryType().then((value) {
  24. final list = <CardTypeModel>[];
  25. List<String> newTabs =['全部'];
  26. value['records'].forEach((item) {
  27. list.add(CardTypeModel.fromJson(item));
  28. });
  29. tabText(list);
  30. });
  31. }
  32. @override
  33. Widget build(BuildContext context) {
  34. // _controller=TabController(length: tabText.length, vsync: this);
  35. return Scaffold(
  36. resizeToAvoidBottomInset: false,
  37. appBar: AppBar(
  38. centerTitle: true,
  39. backgroundColor: Colors.transparent,
  40. foregroundColor: const Color(0xFF333333),
  41. elevation: 0,
  42. toolbarHeight: 44.w,
  43. title: Text(
  44. '更多',
  45. style: TextStyle(
  46. color: const Color(0xFF333333),
  47. fontWeight: FontWeight.bold,
  48. fontSize: 17.sp,
  49. letterSpacing: 2),
  50. ),
  51. ),
  52. body: SafeArea(
  53. child: Container(
  54. decoration: BoxDecoration(color: Colors.white),
  55. child: ListView(children: [
  56. Column(
  57. children: [
  58. Container(
  59. padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
  60. width: 350.w,
  61. child: TypeHeader(
  62. type: false,
  63. ),
  64. ),
  65. TabBar(
  66. labelStyle: TextStyle(
  67. fontSize: ScreenUtil().setSp(19),
  68. fontWeight: FontWeight.bold), //选中的样式
  69. unselectedLabelStyle:
  70. TextStyle(fontSize: ScreenUtil().setSp(16)), //未选中的样式
  71. controller: _controller,
  72. isScrollable: true, //可滚动
  73. indicatorColor: Colors.black, //指示器的颜色
  74. labelColor: Colors.black, //选中文字颜色
  75. unselectedLabelColor: Color(0xffadadad),
  76. // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
  77. tabs: tabText.value.map((e) => Tab(text: e.name.toString())).toList(),
  78. onTap: (int i) {
  79. print('当前+${i}');
  80. },
  81. ),
  82. Container(
  83. child: Column(
  84. children: [],
  85. ),
  86. )
  87. ],
  88. )
  89. ]),
  90. )));
  91. }
  92. }