import 'package:trackoffical_app/screen.dart'; import 'package:trackoffical_app/service/app.dart'; import 'game_std_controller.dart'; import 'package:trackoffical_app/appcore/ffi.dart' as ffi; class LayerWarn extends LayerView { const LayerWarn({super.key}); @override Widget build(BuildContext context) { return Obx(() { String? warnTitle; String? warnContent; Color background = Colors.transparent; final mask = Colors.white.withAlpha((255 * 0.7).toInt()); if (viewModel.isShowPhoneHorizontalWarn && !viewModel.instance.isPersonMoving) { warnContent = '请水平放置手机\n以获取准确方向'; } if(App.to.userProfile.gameSettingsHotZonePrompt.value){ final zone = viewModel.instance.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 (viewModel.isShowOutBoundaryWarn) { warnTitle = '您已离开场地'; warnContent = '请返回'; background = const Color(0x80ff870d); } final style = TextStyle(color: Colors.red, fontSize: 5.11.wp); return warnContent != null ? Container( width: double.infinity, height: double.infinity, color: background, alignment: Alignment.topCenter, child: Container( width: 44.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()); }); } }