layer_warn.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import 'package:trackoffical_app/screen.dart';
  2. import 'package:trackoffical_app/service/app.dart';
  3. import 'game_std_controller.dart';
  4. import 'package:trackoffical_app/appcore/ffi.dart' as ffi;
  5. class LayerWarn extends LayerView<GameStdController> {
  6. const LayerWarn({super.key});
  7. @override
  8. Widget build(BuildContext context) {
  9. return Obx(() {
  10. String? warnTitle;
  11. String? warnContent;
  12. Color background = Colors.transparent;
  13. final mask = Colors.white.withAlpha((255 * 0.7).toInt());
  14. if (viewModel.isShowPhoneHorizontalWarn && !viewModel.instance.isPersonMoving) {
  15. warnContent = '请水平放置手机\n以获取准确方向';
  16. }
  17. if(App.to.userProfile.gameSettingsHotZonePrompt.value){
  18. final zone = viewModel.instance.model.zone.value;
  19. if (zone != null) {
  20. background = mask;
  21. }
  22. switch (zone) {
  23. case ffi.ZoneType.Road:
  24. warnTitle = '道路';
  25. warnContent = '您在穿越车行道路,请抬头注意安全!';
  26. break;
  27. case ffi.ZoneType.River:
  28. warnTitle = '靠近河流';
  29. warnContent = '您正在靠近河流,请抬头注意安全!';
  30. break;
  31. case ffi.ZoneType.Lake:
  32. warnTitle = '靠近湖泊';
  33. warnContent = '您正在靠近湖泊,请抬头注意安全!';
  34. break;
  35. case ffi.ZoneType.ParkingLot:
  36. warnTitle = '停车场';
  37. warnContent = '您在停车场区域,请抬头注意安全!';
  38. break;
  39. case ffi.ZoneType.ForbiddenZone:
  40. warnTitle = '禁区';
  41. warnContent = '您正在穿行禁区,请尽快离开!';
  42. break;
  43. case ffi.ZoneType.Lawn:
  44. warnTitle = '草坪';
  45. warnContent = '请勿踩踏草坪,请尽快离开!';
  46. break;
  47. default:
  48. break;
  49. }
  50. }
  51. if (viewModel.isShowOutBoundaryWarn) {
  52. warnTitle = '您已离开场地';
  53. warnContent = '请返回';
  54. background = const Color(0x80ff870d);
  55. }
  56. final style = TextStyle(color: Colors.red, fontSize: 5.11.wp);
  57. return warnContent != null
  58. ? Container(
  59. width: double.infinity,
  60. height: double.infinity,
  61. color: background,
  62. alignment: Alignment.topCenter,
  63. child:
  64. Container(
  65. width: 44.0.wp ,
  66. margin: EdgeInsets.only(top: 30.0.wp),
  67. padding: const EdgeInsets.all(6),
  68. decoration: BoxDecoration(
  69. border: Border.all(color: const Color(0xffff870d)),
  70. color: Colors.orangeAccent.withAlpha(80),
  71. borderRadius: BorderRadius.circular(7)),
  72. child: Column(
  73. mainAxisSize: MainAxisSize.min,
  74. children: [
  75. warnTitle != null
  76. ? Text(warnTitle, style: style)
  77. : const SizedBox(),
  78. Text(
  79. warnContent,
  80. style: style.copyWith(fontSize: 4.58.wp),
  81. ),
  82. ],
  83. ))
  84. )
  85. : const Positioned(child: SizedBox());
  86. });
  87. }
  88. }