root_page_view.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 RootPageView {
  8. //私有构造函数
  9. RootPageView._internal();
  10. //保存单例
  11. static RootPageView _singleton = RootPageView._internal();
  12. //工厂构造函数
  13. factory RootPageView() => _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(boxShadow: [
  117. BoxShadow(
  118. color: MyColors.c7FE1E1E1,
  119. blurRadius: 5.0,
  120. ),
  121. ],color: Colors.white,),
  122. alignment: Alignment.center,
  123. child: Row(
  124. children: [
  125. getButton(0),
  126. getButton(1),
  127. getButton(2),
  128. getButton(3),
  129. ],
  130. ),
  131. );
  132. },
  133. );
  134. }
  135. getButton(int i) {
  136. return Expanded(
  137. child: GestureDetector(
  138. onTap: () {
  139. if (bNIndex == 0 && toTop && i == 0) {
  140. toTop = false;
  141. EventBus().emit('toTop');
  142. }
  143. bNIndex = i;
  144. EventBus().emit('ChangePage');
  145. },
  146. behavior: HitTestBehavior.translucent,
  147. child: Padding(
  148. padding: EdgeInsets.only(left: 10, right: 10),
  149. child: Column(
  150. children: [
  151. Container(
  152. child: SvgPicture.asset(bNIndex == 0 && toTop && i == 0
  153. ? bNTextIcon[i][2]
  154. : bNTextIcon[i][bNIndex == i ? 0 : 1]),
  155. height: 20,
  156. width: 20,
  157. ),
  158. Text(
  159. bNIndex == 0 && toTop && i == 0 ? bNText[4] : bNText[i],
  160. style: TextStyle(
  161. color: bNIndex == i ? MyColors.cFF4233 : MyColors.c999999,
  162. fontSize: 10),
  163. )
  164. ],
  165. mainAxisAlignment: MainAxisAlignment.center,
  166. ),
  167. ),
  168. ),
  169. );
  170. }
  171. }