import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:trackoffical_app/service/app.dart'; import 'package:trackoffical_app/service/sport_wear.dart'; import 'package:trackoffical_app/service/user_profile.dart'; import 'package:trackoffical_app/widget/app_top_bar.dart'; import '../sport_wear_select_view.dart'; import 'in_game_controller.dart'; class SettingsView extends GetView { SettingsView({super.key}); final SportWearService _sp = Get.find(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppTopBar(title: const Text('设置'), automaticallyImplyLeading: true), body: ListView( children: [ // ListTile( // title: const Text('无图模式'), // trailing: Obx(() => Switch( // value: controller.isNoMapMode.value, // onChanged: (v) { // controller.isNoMapMode.value = v; // }))), ListTile( title: const Text('心率带'), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ Obx(() { final wear = _sp.connectedSportWear.value; return wear != null ? Text(wear.name) : const Text('未连接'); }), const Icon(Icons.keyboard_arrow_right) ], ), onTap: showSportWearSelectDialog, ), ListTile( title: const Text('精简模式'), trailing: Obx(() => Switch( value: controller.isInGameUISimplifyMode, onChanged: (v) { controller.isInGameUISimplifyMode = v; }))), ListTile( title: const Text('边界报警'), trailing: Obx(() => Switch( value: controller.isEnableOutBoundaryWarn, onChanged: (v) { controller.isEnableOutBoundaryWarn = v; }))), const ListTile( title: Text('轨迹长度(秒)'), trailing: DropdownMenuTrajectory()), ListTile( title: const Text('定位'), trailing: Obx(() => Switch( value: controller.isEnableUserLocation, onChanged: (v) { controller.isEnableUserLocation = v; }))), ListTile( title: const Text('开始提示'), trailing: Obx(() => Switch( value: controller.isStartShowWarn.value, onChanged: (v) { controller.isStartShowWarn.value = v; }))), ListTile( title: const Text('声音提示'), trailing: Obx(() => Switch( value: controller.isEnableGameSound.value, onChanged: (v) { controller.isEnableGameSound.value = v; }))), ListTile( title: const Text('震动提示'), trailing: Obx(() => Switch( value: controller.isEnableGameVibrate.value, onChanged: (v) { controller.isEnableGameVibrate.value = v; }))), ListTile( title: const Text('打点文创'), trailing: Obx(() => Switch( value: controller.isEnableGameCulture.value, onChanged: (v) { controller.isEnableGameCulture.value = v; }))), ListTile( title: const Text('指北针真北'), trailing: Obx(() => Switch( value: controller.isUseRealNorth, onChanged: (v) { controller.isUseRealNorth = v; }))), ], ), ); } } class DropdownMenuTrajectory extends StatefulWidget { const DropdownMenuTrajectory({super.key}); @override State createState() => _DropdownMenuTrajectoryState(); } class _DropdownMenuTrajectoryState extends State { var selectedValue = App.to.userProfile.inGameTrajectorySeconds.val; @override Widget build(BuildContext context) { const l = UserProfile.inGameTrajectorySecondsList; final menus = l.map((e) => MenuItemButton( onPressed: ()=>setState(() { App.to.userProfile.inGameTrajectorySeconds.val=e; selectedValue=e; }), child: MenuAcceleratorLabel(e.toString()), )).toList(); return SizedBox( height: 46, width: 80, child: SubmenuButton(menuChildren: menus, trailingIcon: const Icon(Icons.arrow_drop_down, size: 20,), child: Text('$selectedValue'), ), ) ; } }