2024-08-29 17:45:39 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
import 'child_pages/XyChange/xy_change.dart';
|
2024-08-30 17:57:33 +08:00
|
|
|
import 'child_pages/antenna/antenna_setting.dart';
|
2024-08-29 17:45:39 +08:00
|
|
|
import 'child_pages/connect/bluetooth_page.dart';
|
|
|
|
import 'child_pages/persondetail/person_details.dart';
|
|
|
|
import 'child_pages/connect/wifi_page.dart';
|
|
|
|
|
|
|
|
import 'component/list_view_item.dart';
|
|
|
|
import 'child_pages/connect/config/app_config.dart';
|
|
|
|
import 'child_pages/connect/config/connect_type.dart';
|
|
|
|
import 'child_pages/connect/controllers/blueToothController.dart';
|
|
|
|
|
|
|
|
//字体
|
|
|
|
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<SettingPortrait> createState() => _SettingPortraitState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingPortraitState extends State<SettingPortrait> {
|
|
|
|
String userName = "";
|
|
|
|
List<ListItem> 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: <Widget>[
|
|
|
|
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, () {
|
2024-08-30 17:57:33 +08:00
|
|
|
Navigator.push(context,
|
|
|
|
MaterialPageRoute(builder: (context) => const AntennaSetting()));
|
2024-08-29 17:45:39 +08:00
|
|
|
}),
|
|
|
|
];
|
|
|
|
SchedulerBinding.instance.addPostFrameCallback((_) async {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: items.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Obx(() {
|
|
|
|
blueToothController.connectedType.value;
|
|
|
|
return SizedBox(
|
|
|
|
height: 40,
|
|
|
|
child: ListTileButton(
|
|
|
|
item: items[index],
|
|
|
|
));
|
|
|
|
}),
|
|
|
|
const Divider(), // 在每个列表项下方添加一条线
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|