root_page_view.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import 'package:bbyyy/my_tools/event_bus.dart';
  2. import 'package:bbyyy/my_tools/my_colors.dart';
  3. import 'package:bbyyy/my_tools/my_tools.dart';
  4. import 'package:bbyyy/paegs/release_goods_page/release_goods_page.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter_svg/svg.dart';
  7. class RootPageView1 {
  8. //私有构造函数
  9. RootPageView1._internal();
  10. //保存单例
  11. static RootPageView1 _singleton = RootPageView1._internal();
  12. //工厂构造函数
  13. factory RootPageView1() => _singleton;
  14. bool toTop = false;
  15. var bNText = ['首页', '货帮', '消息', '我的', '顶部'];
  16. var bNTextIcon = [
  17. ['images/svg/发现1.svg', 'images/svg/发现2.svg', 'images/svg/顶部.svg'],
  18. ['images/svg/货帮1.svg', 'images/svg/货帮2.svg'],
  19. ['images/svg/消息1.svg', 'images/svg/消息2.svg'],
  20. ['images/svg/我的1.svg', 'images/svg/我的2.svg']
  21. ];
  22. int bNIndex = 0;
  23. bottomNavigationBar1() {
  24. return StatefulBuilder(
  25. builder: (BuildContext context, void Function(void Function()) setState) {
  26. EventBus().on('ChangePage', (arg) {
  27. setState(() {});
  28. });
  29. return Stack(
  30. alignment: Alignment.bottomCenter,
  31. children: [
  32. Container(
  33. height: 51,
  34. decoration: BoxDecoration(boxShadow: [
  35. BoxShadow(
  36. color: MyColors.c7FE1E1E1,
  37. blurRadius: 5.0,
  38. ),
  39. ]),
  40. ),
  41. Container(
  42. decoration: BoxDecoration(
  43. color: Colors.white,
  44. borderRadius: BorderRadius.all(Radius.circular(30)),
  45. boxShadow: [
  46. BoxShadow(
  47. color: MyColors.c7FE1E1E1,
  48. blurRadius: 5.0,
  49. ),
  50. ]),
  51. height: 60,
  52. width: 60,
  53. ),
  54. Container(
  55. color: Colors.white,
  56. height: 51,
  57. alignment: Alignment.center,
  58. child: Row(
  59. children: [
  60. Expanded(
  61. child: Row(
  62. children: [
  63. getButton(0),
  64. getButton(1),
  65. ],
  66. mainAxisAlignment: MainAxisAlignment.spaceAround,
  67. ),
  68. ),
  69. Container(
  70. width: 60,
  71. ),
  72. Expanded(
  73. child: Row(
  74. children: [
  75. getButton(2),
  76. getButton(3),
  77. ],
  78. mainAxisAlignment: MainAxisAlignment.spaceAround,
  79. ),
  80. )
  81. ],
  82. ),
  83. ),
  84. GestureDetector(
  85. onTap: () {
  86. MyTools().toPage(context, ReleaseGoodsPage(null,''), (then) {});
  87. },
  88. child: Container(
  89. decoration: BoxDecoration(
  90. color: Colors.white,
  91. borderRadius: BorderRadius.all(Radius.circular(30))),
  92. height: 60,
  93. width: 60,
  94. alignment: Alignment.center,
  95. child: SvgPicture.asset(
  96. 'images/svg/发布.svg',
  97. height: 44,
  98. width: 44,
  99. ),
  100. ),
  101. behavior: HitTestBehavior.translucent,
  102. )
  103. ],
  104. );
  105. },
  106. );
  107. }
  108. bottomNavigationBar() {
  109. return StatefulBuilder(
  110. builder: (BuildContext context, void Function(void Function()) setState) {
  111. EventBus().on('ChangePage', (arg) {
  112. setState(() {});
  113. });
  114. return Container(
  115. height: 51,
  116. decoration: BoxDecoration(
  117. boxShadow: [
  118. BoxShadow(
  119. color: MyColors.c7FE1E1E1,
  120. blurRadius: 5.0,
  121. ),
  122. ],
  123. color: Colors.white,
  124. ),
  125. alignment: Alignment.center,
  126. child: Row(
  127. children: [
  128. getButton(0),
  129. getButton(1),
  130. getButton(2),
  131. getButton(3),
  132. ],
  133. ),
  134. );
  135. },
  136. );
  137. }
  138. getButton(int i) {
  139. return Expanded(
  140. child: GestureDetector(
  141. onTap: () {
  142. if (bNIndex == 0 && toTop && i == 0) {
  143. toTop = false;
  144. EventBus().emit('toTop');
  145. }
  146. if (i != 0) {
  147. EventBus().emit('toLogin');
  148. }
  149. },
  150. behavior: HitTestBehavior.translucent,
  151. child: Padding(
  152. padding: EdgeInsets.only(left: 10, right: 10),
  153. child: Column(
  154. children: [
  155. Container(
  156. child: SvgPicture.asset(bNIndex == 0 && toTop && i == 0
  157. ? bNTextIcon[i][2]
  158. : bNTextIcon[i][bNIndex == i ? 0 : 1]),
  159. height: 20,
  160. width: 20,
  161. ),
  162. Text(
  163. bNIndex == 0 && toTop && i == 0 ? bNText[4] : bNText[i],
  164. style: TextStyle(
  165. color: bNIndex == i ? MyColors.cFF4233 : MyColors.c999999,
  166. fontSize: 10),
  167. )
  168. ],
  169. mainAxisAlignment: MainAxisAlignment.center,
  170. ),
  171. ),
  172. ),
  173. );
  174. }
  175. }