game_std_view_compass.dart 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'package:trackoffical_app/view/ingame/game_std/utils.dart';
  2. import '../../../model/game_person_data.dart';
  3. import 'button_punch.dart';
  4. import '../game_compass/game_compass_button.dart';
  5. import '../game_compass/game_compass_top4_data.dart';
  6. import 'game_std_controller.dart';
  7. import 'info_view.dart';
  8. export 'game_std_controller.dart';
  9. abstract class GameStdViewCompass extends LayerView<GameStdController> {
  10. const GameStdViewCompass({super.key});
  11. GamePersonData get model => viewModel.instance.model;
  12. List<GameCompassTop4Data> top4Data() {
  13. return [
  14. GameCompassTop4Data(
  15. title: '目标',
  16. child: Obx(() => model.nextPlanPoint.display(
  17. textStyle: const TextStyle(
  18. fontSize: 21.78, fontWeight: FontWeight.w500))) ),
  19. GameCompassTop4Data(
  20. title: '里程',
  21. child: Padding(
  22. padding: const EdgeInsets.only(left: 16, right: 16),
  23. child: Obx(()=>model.widgetDistance(
  24. withTrip: !viewModel.isSimpleDashboard.value))) ),
  25. GameCompassTop4Data(
  26. title: '点距',
  27. child: Obx(()=>_nextCPDistance())),
  28. GameCompassTop4Data(
  29. title: '配速',
  30. child: Padding(
  31. padding: const EdgeInsets.only(left: 16, right: 16),
  32. child: Obx(()=>model.widgetPace(
  33. withTrip: !viewModel.isSimpleDashboard.value)))),
  34. ];
  35. }
  36. Widget _nextCPDistance() {
  37. var unit = ' km';
  38. var value = '--';
  39. final dis = model.nextPlanCPDistanceKmShow;
  40. if(dis!= null){
  41. (value, unit) = dis.toStringValueAndUnit();
  42. }
  43. return RichText(
  44. text: TextSpan(
  45. text: value,
  46. style:
  47. const TextStyle(fontSize: 28.31, fontWeight: FontWeight.w500),
  48. children: [
  49. TextSpan(
  50. text: unit,
  51. style:
  52. const TextStyle(fontSize: 13.07, fontWeight: FontWeight.w500))
  53. ]));
  54. }
  55. List<Widget> topButtons(){
  56. return [
  57. buttonInfo(onPressed: () => Get.to(() => InfoView())),
  58. buttonCheckedCP(onPressed: viewModel.showCheckedCP),
  59. buttonBrightness(onPressed: _onBrightness),
  60. buttonSettings(onPressed: viewModel.toSettings),
  61. buttonExit(onPressed: ()=>onButtonExit(viewModel)),
  62. ];
  63. }
  64. void _onBrightness()async{
  65. await viewModel.setIsBrightnessMax(!viewModel.isBrightnessMax);
  66. }
  67. Widget process() {
  68. return Obx(() => Text('${model.checkedCount}/${model.validCPAllNum}',
  69. maxLines: 1,
  70. style: const TextStyle(
  71. fontSize: 32,
  72. )));
  73. }
  74. Widget punchButton() {
  75. return Obx(
  76. () => SizedBox(
  77. width: 56,
  78. height: 56,
  79. child: ButtonPunch(
  80. onPressed: viewModel.isCheckCPButtonEnable
  81. ? viewModel.onCheckControlPoint
  82. : null,
  83. isWarn: viewModel.isCheckCPButtonWarn,
  84. ),
  85. ),
  86. );
  87. }
  88. }