root_page_view.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. decoration: BoxDecoration(boxShadow: [
  116. BoxShadow(
  117. color: MyColors.c7FE1E1E1,
  118. blurRadius: 5.0,
  119. ),
  120. ],color: Colors.white,),
  121. child: SafeArea(
  122. top: false,
  123. child: Container(
  124. height: 51,
  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. );
  139. }
  140. getButton(int i) {
  141. return Expanded(
  142. child: GestureDetector(
  143. onTap: () {
  144. if (bNIndex == 0 && toTop && i == 0) {
  145. toTop = false;
  146. EventBus().emit('toTop');
  147. }
  148. bNIndex = i;
  149. EventBus().emit('ChangePage');
  150. },
  151. behavior: HitTestBehavior.translucent,
  152. child: Padding(
  153. padding: EdgeInsets.only(left: 10, right: 10),
  154. child: Column(
  155. children: [
  156. Container(
  157. child: SvgPicture.asset(bNIndex == 0 && toTop && i == 0
  158. ? bNTextIcon[i][2]
  159. : bNTextIcon[i][bNIndex == i ? 0 : 1]),
  160. height: 20,
  161. width: 20,
  162. ),
  163. Text(
  164. bNIndex == 0 && toTop && i == 0 ? bNText[4] : bNText[i],
  165. style: TextStyle(
  166. color: bNIndex == i ? MyColors.cFF4233 : MyColors.c999999,
  167. fontSize: 10),
  168. )
  169. ],
  170. mainAxisAlignment: MainAxisAlignment.center,
  171. ),
  172. ),
  173. ),
  174. );
  175. }
  176. }