page_frame.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import '../generated/assets.dart';
  4. import '../route.dart';
  5. import '../screen.dart';
  6. class PageFrame extends GetView {
  7. // final List<Widget> children;
  8. final Widget child;
  9. const PageFrame({super.key, required this.child});
  10. @override
  11. Widget build(BuildContext context) {
  12. // final List<Widget> modifiedChildren = List.from(children);
  13. // modifiedChildren.insert(0, const PageTop());
  14. return Scaffold(
  15. body: Container(
  16. // color: Color(0xffffab00),
  17. width: 100.wp,
  18. decoration: const BoxDecoration(
  19. image: DecorationImage(
  20. image: AssetImage(Assets.commonPageBg), fit: BoxFit.cover)
  21. ),
  22. child: Column(
  23. children: [
  24. PageTop(),
  25. Expanded(
  26. child: child,
  27. )
  28. ],
  29. ),
  30. ));
  31. }
  32. }
  33. class PageTopController extends GetxController {
  34. var mapName = "".obs;
  35. }
  36. class PageTop extends GetView<PageTopController> {
  37. const PageTop({super.key});
  38. static TextStyle textStyle = TextStyle(color: Colors.white, fontSize: 11.rpx);
  39. static Bindings bindings() {
  40. return BindingsBuilder(() {
  41. Get.lazyPut<PageTopController>(() => PageTopController());
  42. });
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. return Container(
  47. // color: Color(0xffffab00),
  48. width: 100.wp,
  49. height: 5.28.wp,
  50. decoration: BoxDecoration(
  51. image: const DecorationImage(
  52. image: AssetImage(Assets.commonPageBg),
  53. fit: BoxFit.cover,
  54. opacity: 0.9
  55. ),
  56. gradient: const LinearGradient(
  57. begin: Alignment.centerLeft,
  58. end: Alignment.centerRight,
  59. colors: [Color(0xff017dc7), Color(0xff005d94)]
  60. ),
  61. boxShadow: [
  62. BoxShadow(
  63. color: const Color(0x33000000),
  64. offset: Offset(0.wp, 0.28.wp),
  65. blurRadius: 0.42.wp)
  66. ],
  67. ),
  68. child: Row(
  69. mainAxisAlignment: MainAxisAlignment.center,
  70. children: [
  71. Expanded(
  72. flex: 5,
  73. child: wNavList(),
  74. ),
  75. Expanded(
  76. flex: 4,
  77. child: wMapSpan(),
  78. ),
  79. wBroadcastSpan("广播")
  80. ],
  81. ));
  82. }
  83. Widget wNavList() {
  84. return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
  85. wNavText('地图', RouteName.mapsList),
  86. wNavText('场控', RouteName.mapTO),
  87. wNavText('用户管理', RouteName.userAdmin),
  88. wNavText('个人排名', RouteName.personRank),
  89. wNavText('分组排名', RouteName.groupRank),
  90. wNavText('数据详情', RouteName.sportData),
  91. wNavText('设置', RouteName.setting),
  92. // const Spacer(),
  93. ]);
  94. }
  95. Widget wNavText(String text, String routeName) {
  96. final children = <Widget>[];
  97. children.add(Container());
  98. children.add(Text.rich(TextSpan(
  99. text: text,
  100. style: textStyle,
  101. // 设置点击事件
  102. // recognizer: TapGestureRecognizer()
  103. // ..onTap = () {
  104. // debugPrint("next Route == $routeName");
  105. // },
  106. )));
  107. // if (true) {
  108. if (Get.currentRoute == routeName) {
  109. children.add(Align(
  110. alignment: Alignment.bottomCenter,
  111. child:
  112. SizedBox(height: 1.wp, child: Image.asset(Assets.imagesIcTopArrow)),
  113. ));
  114. }
  115. return Padding(
  116. padding: const EdgeInsets.only(left: 2, right: 2),
  117. child: GestureDetector(
  118. behavior: HitTestBehavior.opaque,
  119. onTap: () {
  120. debugPrint("Get.currentRoute == ${Get.currentRoute}");
  121. debugPrint("next Route == $routeName");
  122. },
  123. child: Stack(
  124. alignment: Alignment.center,
  125. children: children,
  126. ),
  127. ),
  128. );
  129. }
  130. Widget wMapSpan() {
  131. final children = <Widget>[];
  132. if (controller.mapName.value.isNotEmpty) {
  133. children.add(Container(
  134. margin: const EdgeInsets.only(left: 15, right: 6),
  135. height: 2.36.wp,
  136. width: 0.69.wp,
  137. decoration: const BoxDecoration(
  138. color: Color(0xff52bfff),
  139. borderRadius: BorderRadius.all(Radius.circular(35.0)),
  140. // border: Border.all(width: 1, color: Colors.red),
  141. ),
  142. ));
  143. children.add(SizedBox(
  144. width: 35.wp,
  145. child: Obx(() => Text(
  146. controller.mapName.value,
  147. textAlign: TextAlign.left,
  148. softWrap: false,
  149. maxLines: 1,
  150. overflow: TextOverflow.ellipsis,
  151. style: textStyle,
  152. ))));
  153. }
  154. return Row(children: children);
  155. }
  156. Widget wBroadcastSpan(String text) {
  157. return SizedBox(
  158. width: 11.wp,
  159. child: Row(
  160. mainAxisAlignment: MainAxisAlignment.center,
  161. children: [
  162. Container(
  163. margin: const EdgeInsets.only(right: 6),
  164. child: Image.asset(
  165. Assets.imagesIcBroadcast,
  166. height: 1.7.wp,
  167. fit: BoxFit.fitHeight,
  168. ),
  169. ),
  170. Text(
  171. text,
  172. textAlign: TextAlign.center,
  173. style: textStyle,
  174. )
  175. ],
  176. ),
  177. );
  178. }
  179. }
  180. void main() {
  181. PageTopController pageTopController = Get.put(PageTopController());
  182. // pageTopController.mapName.value = "济南泉城公园";
  183. pageTopController.mapName.value = "济南森林公园风景区定向运动济南森林公园风景区定向运动";
  184. // runPreview(const Material(child: Column(children: [PageTop()])));
  185. // runPreview(const PageFrame(children: []));
  186. runPreview(const PageFrame(child: Spacer()));
  187. }