in_game_view.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:trackoffical_app/service/game/game_model.dart';
  4. import 'package:trackoffical_app/service/user_profile.dart';
  5. import 'package:trackoffical_app/view/ingame/layer_cp_touch.dart';
  6. import 'package:trackoffical_app/view/ingame/layer_map.dart';
  7. import '../../service/game/game.dart';
  8. import 'package:trackoffical_app/widget/will_exit_after_2_back.dart';
  9. import '../../service/app.dart';
  10. import '../../service/mock.dart';
  11. import './in_game_controller.dart';
  12. import '../../styles/color_schemes.g.dart';
  13. import 'in_game_no_map_view.dart';
  14. import 'layer_front_ui.dart';
  15. import 'layer_warn.dart';
  16. class InGameView extends GetView<InGameController> {
  17. const InGameView({super.key});
  18. static Bindings bindings() {
  19. return BindingsBuilder(() {
  20. Get.lazyPut<InGameController>(() => InGameController());
  21. });
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return WillExitAfter2Back(
  26. child: Obx(() => controller.uiMode.value!=GameUIMode.electronicMap? InGameNoMapView(): Scaffold(
  27. backgroundColor: const Color(0xffd6d6d6),
  28. body: Stack(
  29. children: [
  30. const LayerMap(),
  31. const LayerWarn(),
  32. _LayerMapTouch(),
  33. const LayerCPTouch(),
  34. LayerFrontUI(),
  35. ],
  36. ),
  37. )) );
  38. }
  39. }
  40. class _LayerMapTouch extends GetView<GameService> {
  41. @override
  42. Widget build(BuildContext context) {
  43. return GestureDetector(
  44. onScaleStart: (v) => controller.mapStatus.onMapTouchScaleStart(v),
  45. onScaleUpdate: (v) => controller.mapStatus
  46. .onMapTouchScaleUpdate(v, Size(context.width, context.height)),
  47. onScaleEnd: (v) => controller.mapStatus.isTouching = false,
  48. child: SizedBox.expand(
  49. child: Container(color: Colors.transparent),
  50. ),
  51. );
  52. }
  53. }
  54. void main() async {
  55. Mock.initServices();
  56. await App.to.init();
  57. Get.put(GameModel());
  58. Get.put(GameService());
  59. await GameService.to.gameStart();
  60. // await GameService.to.gameLoad();
  61. var c = InGameControllerMock();
  62. Get.put<InGameController>(c);
  63. runApp(GetMaterialApp(
  64. theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
  65. home: const InGameView()));
  66. }