layer_front_ui.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import 'package:get/get.dart';
  2. import 'package:trackoffical_app/service/game/game.dart';
  3. import '../../model/m_control_point.dart';
  4. import '../../service/game/game_model.dart';
  5. import 'in_game_controller.dart';
  6. import 'package:flutter/material.dart';
  7. import 'button_bar.dart';
  8. import 'bottom_bar.dart';
  9. import 'package:trackoffical_app/appcore/ffi.dart' as ffi;
  10. class LayerFrontUI extends GetView<InGameController> {
  11. LayerFrontUI({super.key});
  12. final service = Get.find<GameService>();
  13. final _model = Get.find<GameModel>();
  14. @override
  15. Widget build(BuildContext context) {
  16. return Column(
  17. children: [
  18. Container(
  19. width: context.width,
  20. height: context.mediaQueryPadding.top,
  21. decoration: BoxDecoration(color: Colors.grey.withAlpha(150)),
  22. ),
  23. // _TopBar(),
  24. Expanded(
  25. child: Container(
  26. padding: const EdgeInsets.only(top: 12),
  27. width: double.infinity,
  28. child: Stack(
  29. alignment: AlignmentDirectional.center,
  30. children: [
  31. Obx(() {
  32. final next = service.getNextWantPoint(0);
  33. final nextPlan = _model.nextPlanPoint;
  34. var isShowCheckCPButton = controller.isNfcScanUseDialog ||
  35. next?.type == MControlPointType.gps ||
  36. nextPlan?.type == MControlPointType.gps;
  37. return MButtonBar(
  38. isShowCheckCPButton: isShowCheckCPButton,
  39. isCheckCPButtonEnable:
  40. controller.isCheckCPButtonEnable,
  41. );
  42. }),
  43. // _PhoneHorizontalWarn(),
  44. ],
  45. ))),
  46. // _BottomBar(),
  47. BottomBar(),
  48. ],
  49. );
  50. }
  51. }
  52. class _PhoneHorizontalWarn extends GetView<InGameController> {
  53. @override
  54. Widget build(BuildContext context) {
  55. final model = Get.find<GameModel>();
  56. return Obx(() {
  57. String? warn;
  58. if(controller.isShowPhoneHorizontalWarn){
  59. warn = '请水平放置手机\n以获取准确方向';
  60. }
  61. final zone = model.zone.value;
  62. switch (zone){
  63. case ffi.ZoneType.Road:
  64. warn = '正在穿过道路\n请小心车辆';
  65. break;
  66. case ffi.ZoneType.River:
  67. warn = '正在经过河流\n请小心';
  68. break;
  69. default:
  70. break;
  71. }
  72. return warn != null
  73. ? Column(
  74. crossAxisAlignment: CrossAxisAlignment.center,
  75. children: [
  76. const SizedBox(height: 20),
  77. Container(
  78. padding: const EdgeInsets.all(6),
  79. decoration: BoxDecoration(
  80. color: Colors.orangeAccent.withAlpha(80),
  81. borderRadius: BorderRadius.circular(7)),
  82. child: Text(
  83. warn,
  84. style: context.textTheme.bodyLarge
  85. ?.copyWith(color: context.theme.colorScheme.error),
  86. ),
  87. )
  88. ],
  89. )
  90. : const Positioned(child: SizedBox());
  91. });
  92. // return Obx(() => controller.isShowPhoneHorizontalWarn
  93. // ? Column(
  94. // crossAxisAlignment: CrossAxisAlignment.center,
  95. // children: [
  96. // const SizedBox(height: 20),
  97. // Container(
  98. // padding: const EdgeInsets.all(6),
  99. // decoration: BoxDecoration(
  100. // color: Colors.orangeAccent.withAlpha(80),
  101. // borderRadius: BorderRadius.circular(7)),
  102. // child: Text(
  103. // '请水平放置手机\n以获取准确方向',
  104. // style: context.textTheme.bodyLarge
  105. // ?.copyWith(color: context.theme.colorScheme.error),
  106. // ),
  107. // )
  108. // ],
  109. // )
  110. // : const Positioned(child: SizedBox()));
  111. }
  112. }
  113. class _InWantControlPointAreaShow extends GetView<GameModel> {
  114. @override
  115. Widget build(BuildContext context) {
  116. final InGameController service = Get.find();
  117. return Obx(() {
  118. if (!controller.isInWantControlPointArea) {
  119. return const SizedBox();
  120. }
  121. return Column(
  122. crossAxisAlignment: CrossAxisAlignment.center,
  123. children: [
  124. const SizedBox(height: 220),
  125. SizedBox(
  126. height: 120,
  127. width: 120,
  128. child: ElevatedButton(
  129. onPressed: service.onCheckGpsControlPoint,
  130. child: const Text(
  131. '打卡',
  132. style: TextStyle(fontSize: 30),
  133. )),
  134. )
  135. ],
  136. );
  137. });
  138. }
  139. }