//字体 import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import '../login_in/connect/bluetooth_page.dart'; import '../login_in/connect/config.dart'; import '../login_in/connect/connect_type.dart'; import '../login_in/getx/blue_tooth.dart'; import '../setting/antenna_setting.dart'; import '../setting/person_details.dart'; import '../setting/wifi_page.dart'; import '../setting/xy_change.dart'; class ListTileButton extends StatelessWidget { final ListItem item; const ListTileButton({super.key, required this.item, isInput = false}); @override Widget build(BuildContext context) { return InkWell( onTap: () => item.onPressed(), child: ListTile( leading: Icon(item.icon), title: Text(item.text), ), ); } } class ListItem { String text; final IconData icon; final Function onPressed; ListItem(this.text, this.icon, this.onPressed); } TextStyle textStyle = const TextStyle(fontSize: 15); // //是否有获取地址权限 // PermissionStatus? _status; final BlueToothController blueToothController = Get.put(BlueToothController()); String connectedID = ""; //竖屏 class SettingPortrait extends StatefulWidget { const SettingPortrait({super.key}); @override State createState() => _SettingPortraitState(); } class _SettingPortraitState extends State { String userName = ""; List items = []; void readID() { setState(() { connectedID = blueToothController.connectedDeviceID.value; }); } @override void initState() { super.initState(); items = [ ListItem('连接设置', Icons.change_circle_outlined, () { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text("选择连接方式"), content: Column( mainAxisSize: MainAxisSize.min, children: [ ListTile( title: const Text("蓝牙连接"), onTap: () { // items[0].text = "连接设置(蓝牙)"; AppConfig.updateConfig("connectType", "bluetooth"); Navigator.push( context, MaterialPageRoute( builder: (context) => const BlueTooth()), ); }, ), ListTile( title: const Text("WiFi连接"), onTap: () { blueToothController.connectedType.value = ConnectType.wifi; AppConfig.updateConfig("connectType", "wifi"); // items[0].text = "连接设置(WiFi)"; // Connectivity() // .checkConnectivity() // .then((connectivityResult) { // if (connectivityResult != ConnectivityResult.wifi) { // OpenSettings.openWIFISetting(); // } else { // } // }); Navigator.push( context, MaterialPageRoute( builder: (context) => const WifiPage()), ); }, ), ], ), ); }, ); }), // ListItem('规划点', Icons.download_outlined, () { // Navigator.push(context, // MaterialPageRoute(builder: (context) => const PlanPoint())); // }), ListItem('坐标转换', Icons.settings, () { Navigator.push(context, MaterialPageRoute(builder: (context) => const XyChangeView())); }), ListItem('个人中心', Icons.person_outline_outlined, () { Navigator.push(context, MaterialPageRoute(builder: (context) => const PersonDetails())); }), ListItem('天线位置设置', Icons.settings_input_antenna, () { Navigator.push(context, MaterialPageRoute(builder: (context) => const AntennaSetting())); }), ]; SchedulerBinding.instance.addPostFrameCallback((_) async {}); } @override Widget build(BuildContext context) { return ListView.builder( itemCount: items.length, itemBuilder: (BuildContext context, int index) { return Column( children: [ Obx(() { blueToothController.connectedType.value; return SizedBox( height: 40, child: ListTileButton( item: items[index], )); }), const Divider(), // 在每个列表项下方添加一条线 ], ); }, ); } }