settings_view.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import 'dart:ffi';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:trackoffical_app/service/app.dart';
  5. import 'package:trackoffical_app/service/sport_wear.dart';
  6. import 'package:trackoffical_app/service/user_profile.dart';
  7. import 'package:trackoffical_app/widget/app_top_bar.dart';
  8. import '../sport_wear_select_view.dart';
  9. import 'in_game_controller.dart';
  10. class SettingsView extends GetView<InGameController> {
  11. SettingsView({super.key});
  12. final SportWearService _sp = Get.find();
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. appBar:
  17. AppTopBar(title: const Text('设置'), automaticallyImplyLeading: true),
  18. body: ListView(
  19. children: [
  20. // ListTile(
  21. // title: const Text('无图模式'),
  22. // trailing: Obx(() => Switch(
  23. // value: controller.isNoMapMode.value,
  24. // onChanged: (v) {
  25. // controller.isNoMapMode.value = v;
  26. // }))),
  27. ListTile(
  28. title: const Text('心率带'),
  29. trailing: Row(
  30. mainAxisSize: MainAxisSize.min,
  31. children: [
  32. Obx(() {
  33. final wear = _sp.connectedSportWear.value;
  34. return wear != null ? Text(wear.name) : const Text('未连接');
  35. }),
  36. const Icon(Icons.keyboard_arrow_right)
  37. ],
  38. ),
  39. onTap: showSportWearSelectDialog,
  40. ),
  41. ListTile(
  42. title: const Text('精简模式'),
  43. trailing: Obx(() => Switch(
  44. value: controller.isInGameUISimplifyMode,
  45. onChanged: (v) {
  46. controller.isInGameUISimplifyMode = v;
  47. }))),
  48. ListTile(
  49. title: const Text('边界报警'),
  50. trailing: Obx(() => Switch(
  51. value: controller.isEnableOutBoundaryWarn,
  52. onChanged: (v) {
  53. controller.isEnableOutBoundaryWarn = v;
  54. }))),
  55. const ListTile(
  56. title: Text('轨迹长度(秒)'), trailing: DropdownMenuTrajectory()),
  57. ListTile(
  58. title: const Text('定位'), trailing: Obx(() => Switch(
  59. value: controller.isEnableUserLocation,
  60. onChanged: (v) {
  61. controller.isEnableUserLocation = v;
  62. }))),
  63. ListTile(
  64. title: const Text('开始提示'), trailing: Obx(() => Switch(
  65. value: controller.isStartShowWarn.value,
  66. onChanged: (v) {
  67. controller.isStartShowWarn.value = v;
  68. }))),
  69. ListTile(
  70. title: const Text('声音提示'), trailing: Obx(() => Switch(
  71. value: controller.isEnableGameSound.value,
  72. onChanged: (v) {
  73. controller.isEnableGameSound.value = v;
  74. }))),
  75. ListTile(
  76. title: const Text('震动提示'), trailing: Obx(() => Switch(
  77. value: controller.isEnableGameVibrate.value,
  78. onChanged: (v) {
  79. controller.isEnableGameVibrate.value = v;
  80. }))),
  81. ListTile(
  82. title: const Text('打点文创'), trailing: Obx(() => Switch(
  83. value: controller.isEnableGameCulture.value,
  84. onChanged: (v) {
  85. controller.isEnableGameCulture.value = v;
  86. }))),
  87. ListTile(
  88. title: const Text('指北针真北'),
  89. trailing: Obx(() => Switch(
  90. value: controller.isUseRealNorth,
  91. onChanged: (v) {
  92. controller.isUseRealNorth = v;
  93. }))),
  94. ],
  95. ),
  96. );
  97. }
  98. }
  99. class DropdownMenuTrajectory extends StatefulWidget {
  100. const DropdownMenuTrajectory({super.key});
  101. @override
  102. State<DropdownMenuTrajectory> createState() => _DropdownMenuTrajectoryState();
  103. }
  104. class _DropdownMenuTrajectoryState extends State<DropdownMenuTrajectory> {
  105. var selectedValue = App.to.userProfile.inGameTrajectorySeconds.val;
  106. @override
  107. Widget build(BuildContext context) {
  108. const l = UserProfile.inGameTrajectorySecondsList;
  109. final menus = l.map((e) => MenuItemButton(
  110. onPressed: ()=>setState(() {
  111. App.to.userProfile.inGameTrajectorySeconds.val=e;
  112. selectedValue=e;
  113. }),
  114. child: MenuAcceleratorLabel(e.toString()),
  115. )).toList();
  116. return SizedBox(
  117. height: 46, width: 80,
  118. child:
  119. SubmenuButton(menuChildren: menus,
  120. trailingIcon: const Icon(Icons.arrow_drop_down, size: 20,),
  121. child:
  122. Text('$selectedValue'),
  123. ),
  124. ) ;
  125. }
  126. }