page_frame.dart 5.7 KB

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