| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:trackoffical_app/screen.dart';
- import '../../service/game/game_model.dart';
- import 'in_game_controller.dart';
- import 'package:trackoffical_app/appcore/ffi.dart' as ffi;
- class LayerWarn extends GetView<InGameController> {
- const LayerWarn({super.key});
- @override
- Widget build(BuildContext context) {
- final model = Get.find<GameModel>();
- return Obx(() {
- String? warnTitle;
- String? warnContent;
- Color background = Colors.transparent;
- final mask = Colors.white.withAlpha((255 * 0.7).toInt());
- if (controller.isShowPhoneHorizontalWarn) {
- warnContent = '请水平放置手机\n以获取准确方向';
- }
- final zone = model.zone.value;
- if (zone != null) {
- background = mask;
- }
- switch (zone) {
- case ffi.ZoneType.Road:
- warnTitle = '道路';
- warnContent = '您在穿越车行道路,请抬头注意安全!';
- break;
- case ffi.ZoneType.River:
- warnTitle = '靠近河流';
- warnContent = '您正在靠近河流,请抬头注意安全!';
- break;
- case ffi.ZoneType.Lake:
- warnTitle = '靠近湖泊';
- warnContent = '您正在靠近湖泊,请抬头注意安全!';
- break;
- case ffi.ZoneType.ParkingLot:
- warnTitle = '停车场';
- warnContent = '您在停车场区域,请抬头注意安全!';
- break;
- case ffi.ZoneType.ForbiddenZone:
- warnTitle = '禁区';
- warnContent = '您正在穿行禁区,请尽快离开!';
- break;
- case ffi.ZoneType.Lawn:
- warnTitle = '草坪';
- warnContent = '请勿踩踏草坪,请尽快离开!';
- break;
- default:
- break;
- }
- if (controller.isShowOutBoundaryWarn) {
- warnTitle = '您已离开场地';
- warnContent = '请返回';
- background = mask;
- }
- final style = TextStyle(color: Colors.red, fontSize: 6.11.wp);
- return warnContent != null
- ? Container(
- width: double.infinity,
- height: double.infinity,
- color: background,
- alignment: Alignment.topCenter,
- child:
- Container(
- width: 40.0.wp ,
- margin: EdgeInsets.only(top: 30.0.wp),
- padding: const EdgeInsets.all(6),
- decoration: BoxDecoration(
- border: Border.all(color: const Color(0xffff870d)),
- color: Colors.orangeAccent.withAlpha(80),
- borderRadius: BorderRadius.circular(7)),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- warnTitle != null
- ? Text(warnTitle, style: style)
- : const SizedBox(),
- Text(
- warnContent,
- style: style.copyWith(fontSize: 4.58.wp),
- ),
- ],
- ))
- )
- : const Positioned(child: SizedBox());
- });
- }
- }
|