product_list.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:jmrh/constant/styles.dart';
  4. class ProductList extends StatefulWidget {
  5. ProductList({Key key}) : super(key: key);
  6. @override
  7. _ProductListState createState() => _ProductListState();
  8. }
  9. class _ProductListState extends State<ProductList> with SingleTickerProviderStateMixin {
  10. TabController _tabController;
  11. List<String> _tabs = ['全部', '智能', '能源', '兵器', '电子', '海洋', '生物', '工业'];
  12. @override
  13. void initState() {
  14. super.initState();
  15. _tabController = TabController(initialIndex: 0, vsync: this, length: _tabs.length);
  16. }
  17. @override
  18. void dispose() {
  19. super.dispose();
  20. _tabController.dispose();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return Scaffold(
  25. body: CustomScrollView(
  26. slivers: [
  27. SliverAppBar(
  28. pinned: true,
  29. backgroundColor: Colors.white,
  30. iconTheme: IconTheme.of(context).copyWith(color: Colors.black),
  31. brightness: Brightness.light,
  32. title: appbarTitle('产品展示'),
  33. elevation: 0,
  34. bottom: PreferredSize(
  35. preferredSize: Size.fromHeight(86),
  36. child: Container(
  37. width: double.infinity,
  38. child: Column(
  39. children: [
  40. Container(
  41. height: 44,
  42. padding: EdgeInsets.symmetric(vertical: 10),
  43. child: TabBar(
  44. controller: _tabController,
  45. isScrollable: true,
  46. indicatorSize: TabBarIndicatorSize.label,
  47. indicatorColor: Color(0xFFEA2D2F),
  48. labelColor: COLOR_PRIMARY,
  49. unselectedLabelColor: Color(0xFF939599),
  50. labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
  51. unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 13),
  52. tabs: _tabs.map<Widget>((e) => Tab(text: e)).toList(),
  53. ),
  54. ),
  55. InkWell(
  56. child: Container(
  57. height: 32,
  58. margin: EdgeInsets.only(left: 16, right: 16, bottom: 10),
  59. decoration:
  60. BoxDecoration(color: COLOR_INPUT_BG, borderRadius: BorderRadius.all(Radius.circular(2))),
  61. padding: EdgeInsets.symmetric(horizontal: 10),
  62. child: Row(
  63. children: [
  64. Image.asset('img/icon_search.png'),
  65. Container(
  66. margin: EdgeInsets.only(left: 6),
  67. child: Text(
  68. '搜索...',
  69. style: TextStyle(color: COLOR_TEXT_3, fontSize: 12),
  70. ),
  71. )
  72. ],
  73. ),
  74. ),
  75. onTap: () {
  76. Navigator.of(context).pushNamed('/search');
  77. },
  78. )
  79. ],
  80. ),
  81. ),
  82. ),
  83. ),
  84. SliverList(
  85. delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
  86. return _item();
  87. }, childCount: 10),
  88. )
  89. ],
  90. ),
  91. );
  92. }
  93. Widget _item() {
  94. return InkWell(
  95. child: Container(
  96. padding: EdgeInsets.symmetric(horizontal: 16, vertical: 15),
  97. child: Column(
  98. crossAxisAlignment: CrossAxisAlignment.start,
  99. children: [
  100. AspectRatio(
  101. aspectRatio: 1.8,
  102. child: CachedNetworkImage(
  103. fit: BoxFit.cover,
  104. imageUrl:
  105. 'https://pics4.baidu.com/feed/a044ad345982b2b7b4c4ae3d8b4464e974099be4.jpeg?token=91e6d6e69e51bd9ac35c0f1137aeea2c',
  106. ),
  107. ),
  108. Container(
  109. margin: EdgeInsets.only(top: 12),
  110. child: Text(
  111. '消防无人机系统',
  112. maxLines: 2,
  113. style: TextStyle(fontSize: 15, color: COLOR_TEXT_1),
  114. overflow: TextOverflow.ellipsis,
  115. ),
  116. ),
  117. ],
  118. ),
  119. ),
  120. onTap: () {
  121. Navigator.of(context).pushNamed('/productDetail');
  122. },
  123. );
  124. }
  125. }