新提交

This commit is contained in:
tanlinxing 2024-10-29 17:55:04 +08:00
parent ece7aa270c
commit f41e6a8c96
11 changed files with 698 additions and 394 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,11 @@ import 'package:scence_map/controllers/plumController.dart';
import 'appbar.dart';
import 'pages/aim_point/aimpointController.dart';
import 'pages/history/history_record.dart';
import 'pages/login/login_page.dart';
import 'pages/login/my_routes.dart';
import 'pages/pass_track/view.dart';
import 'pages/setting/child_pages/XyChange/xy_change.dart';
import 'pages/setting/child_pages/persondetail/person_details.dart';
import 'pages/task/pile/pileNav/view.dart';
// import 'pages/pile/rightDra/pileGenerate.dart';
import 'pages/real/index.dart';
@ -29,11 +33,15 @@ void main() async {
Get.put(GnssController());
Get.put(AntennaController());
Get.put(AppController());
Get.put(LoginPageController());
Get.put(AccountLoginController());
Get.put(PhoneLoginController());
LoginPrefs loginPrefs = LoginPrefs();
String value =
await loginPrefs.init(); // await await等待异步方法执行完毕
if ('ok' == value) {
connect.init();
loginPrefs.removeToken(); //
runApp(const MyApp());
}
}
@ -48,7 +56,10 @@ class MyApp extends StatelessWidget {
theme: appcontroller.isDarkMode.value
? ThemeData.dark()
: ThemeData.light(),
debugShowCheckedModeBanner: false,
home: MyHomePage(title: 'Flutter Demo Home Page'),
initialRoute: "home",
onGenerateRoute: onGenerateRoute,
);
});
}
@ -68,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
final List<Widget> _pages = [
Real(),
PassTrack(
date: '',
// date: '',
),
TaskManagePage(),
HistoryRecord(),
@ -81,12 +92,6 @@ class _MyHomePageState extends State<MyHomePage> {
return Scaffold(
resizeToAvoidBottomInset: false,
drawerEdgeDragWidth: 0.0, // drawer
// endDrawer: appcontroller.currentIndex.value == 1
// ? Drawer(
// width: size.width * .8,
// child: const PileGenerate(),
// )
// : null,
appBar: PreferredSize(
preferredSize: Size.fromHeight(appBarHeight),
child: CustomAppBar(

View File

@ -1,5 +1,6 @@
import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class PageNumber extends StatefulWidget {
const PageNumber({
@ -46,6 +47,8 @@ class PageNumberState extends State<PageNumber> {
}
}
class CustomPager extends StatefulWidget {
const CustomPager(this.controller, {super.key});
@ -55,6 +58,7 @@ class CustomPager extends StatefulWidget {
CustomPagerState createState() => CustomPagerState();
}
class CustomPagerState extends State<CustomPager> {
static const List<int> _availableSizes = [10, 20, 30, 50, 100];

View File

@ -12,7 +12,6 @@ import 'tableCol.dart';
// import 'record_data_source.dart'; // bug proj_type
int currentPage = 1;
List dataList = [];
List constructionData = [];
@ -170,8 +169,7 @@ class _HistoryRecordState extends State<HistoryRecord> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final isDarkMode =
Theme.of(context).brightness == Brightness.dark;
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Container(
height: size.height,
padding: const EdgeInsets.all(3),

View File

@ -1,5 +1,5 @@
import 'dart:async';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_svg/flutter_svg.dart';
@ -7,28 +7,27 @@ import 'package:cpnav/service/base.dart';
import '../../service/user/loginprefs.dart';
class Login extends StatefulWidget {
const Login({super.key});
class LoginPageController extends GetxController
with SingleGetTickerProviderMixin {
late TabController _tabController;
@override
State<Login> createState() => _LoginState();
void onInit() {
super.onInit();
_tabController = TabController(length: 2, vsync: this);
}
@override
void onClose() {
_tabController.dispose();
super.onClose();
}
TabController get tabController => _tabController;
}
class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
//with SingleTickerProviderStateMixin 使this
late TabController _tabController;
//
@override
void initState() {
_tabController = TabController(length: 2, vsync: this);
super.initState();
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
class Login extends GetView<LoginPageController> {
const Login({super.key});
@override
Widget build(BuildContext context) {
@ -44,7 +43,7 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
labelStyle: const TextStyle(color: Colors.black), //
unselectedLabelStyle:
const TextStyle(color: Colors.grey), //
controller: _tabController,
controller: controller.tabController,
tabs: const [
Tab(text: '手机号登录', icon: Icon(Icons.phone_android)),
Tab(text: '账号登录', icon: Icon(Icons.account_box_outlined)),
@ -52,7 +51,7 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
),
Expanded(
child: TabBarView(
controller: _tabController,
controller: controller.tabController,
children: const [
PhoneLoginPage(),
AccountLoginPage(),
@ -65,48 +64,56 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
}
}
class AccountLoginPage extends StatefulWidget {
const AccountLoginPage({super.key});
class AccountLoginController extends GetxController {
final formKey = GlobalKey<FormState>();
final username = ''.obs;
final password = ''.obs;
final verifyCode = ''.obs;
final svgString = ''.obs;
final captchaId = ''.obs;
final obscureText = false.obs;
@override
State<AccountLoginPage> createState() => _AccountLoginPageState();
}
class _AccountLoginPageState extends State<AccountLoginPage> {
//FormState
final _formKey = GlobalKey<FormState>();
String username = "";
String password = "";
String verifyCode = "";
String svgString = "";
String captchaId = "";
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
await changeCaptcha();
});
void onInit() {
super.onInit();
changeCaptcha();
}
changeCaptcha() async {
Future<void> changeCaptcha() async {
var captcha = await GetServices().getCaptcha();
setState(() {
svgString = captcha['data'];
captchaId = captcha['captchaId'];
});
svgString.value = captcha['data'];
captchaId.value = captcha['captchaId'];
}
showErrorSnackbar(BuildContext context, String text) {
void showErrorSnackbar(String text) {
final snackBar = SnackBar(
content: Text(text),
backgroundColor: Colors.red,
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
ScaffoldMessenger.of(Get.context!).showSnackBar(snackBar);
}
LoginPrefs loginPrefs = LoginPrefs();
bool _obscureText = false;
// Future<void> login() async {
// if (formKey.currentState!.validate()) {
// formKey.currentState!.save();
// var res = await GetServices().getAccountLogin(
// captchaId.value, password.value, username.value, verifyCode.value);
// if (res['code'] != 1000) {
// changeCaptcha();
// showErrorSnackbar(res["message"]);
// } else {
// LoginPrefs().saveExpire(res["data"]["expire"]);
// LoginPrefs().saveToken(res["data"]["token"]);
// Get.offNamed('home'); //
// }
// }
// }
}
class AccountLoginPage extends GetView<AccountLoginController> {
const AccountLoginPage({super.key});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
@ -115,7 +122,7 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
child: Column(
children: [
Form(
key: _formKey,
key: controller.formKey,
child: Column(
children: [
//
@ -123,7 +130,8 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
decoration: const InputDecoration(
labelText: '用户名:',
),
onSaved: (String? value) => username = value!,
onSaved: (String? value) =>
controller.username.value = value!,
validator: (String? value) {
String str = "";
@ -140,23 +148,22 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
const SizedBox(height: 16.0),
//
TextFormField(
Obx(() => TextFormField(
decoration: InputDecoration(
labelText: '密码:',
suffixIcon: IconButton(
icon: Icon(
_obscureText
controller.obscureText.value
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscureText = !_obscureText; //
});
controller.obscureText.toggle(); //
}),
),
obscureText: _obscureText,
onSaved: (String? value) => password = value!,
obscureText: controller.obscureText.value,
onSaved: (String? value) =>
controller.password.value = value!,
validator: (String? value) {
String str = "";
RegExp regex = RegExp(r'^[a-zA-Z0-9@#$]+$');
@ -169,7 +176,7 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
return str == "" ? null : str;
},
),
)),
const SizedBox(height: 24.0),
Row(
children: [
@ -188,46 +195,51 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
return str == "" ? null : str;
},
onSaved: (String? value) => verifyCode = value!,
onSaved: (String? value) =>
controller.verifyCode.value = value!,
),
),
ElevatedButton(
onPressed: () async {
changeCaptcha();
controller.changeCaptcha();
},
child: svgString.isNotEmpty
child: Obx(() => controller.svgString.isNotEmpty
? SvgPicture.string(
svgString,
controller.svgString.value,
width: 70, //
height: 40, //
color: Colors.black,
)
: const Text(""))
: const Text("")))
],
),
//
ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save(); //
if (controller.formKey.currentState!.validate()) {
controller.formKey.currentState!.save(); //
var res = await GetServices().getAccountLogin(
captchaId, password, username, verifyCode);
setState(() {
controller.captchaId.value,
controller.password.value,
controller.username.value,
controller.verifyCode.value);
if (res['code'] != 1000) {
changeCaptcha();
showErrorSnackbar(context, res["message"]);
controller.changeCaptcha();
controller.showErrorSnackbar(res["message"]);
} else {
loginPrefs.saveExpire((res["data"]["expire"]));
loginPrefs.saveToken((res["data"]["token"]));
Navigator.pushNamed(context, 'home'); //
}
});
}
},
child: const Text('登录'),
),
)
],
))
),
)
],
),
),
@ -235,69 +247,92 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
}
}
class PhoneLoginPage extends StatefulWidget {
const PhoneLoginPage({super.key});
@override
State<PhoneLoginPage> createState() => _PhoneLoginPageState();
}
class _PhoneLoginPageState extends State<PhoneLoginPage> {
String phoneNumber = "";
String smsCode = "";
bool issmsCode = false;
String smsText = "获取验证码";
int _seconds = 60;
late Timer _timer;
//FormState
class PhoneLoginController extends GetxController {
final _formKey = GlobalKey<FormState>();
LoginPrefs loginPrefs = LoginPrefs();
@override
void initState() {
super.initState();
final phoneNumber = ''.obs;
final smsCode = ''.obs;
final issmsCode = false.obs;
final smsText = '获取验证码'.obs;
final _seconds = 60.obs;
late Timer _timer;
phoneNumber = loginPrefs.getPhone();
@override
void onInit() {
super.onInit();
phoneNumber.value = LoginPrefs().getPhone();
}
void startTimer() {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_seconds > 0) {
_seconds -= 1;
smsText = "重新获取(${_seconds}s)";
if (_seconds.value > 0) {
_seconds.value -= 1;
smsText.value = "重新获取(${_seconds.value}s)";
} else {
_timer.cancel(); // 0
smsText = "获取验证码";
smsText.value = "获取验证码";
}
});
}
showErrorSnackbar(BuildContext context, String text) {
void showErrorSnackbar(String text) {
final snackBar = SnackBar(
content: Text(text),
backgroundColor: Colors.red,
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
ScaffoldMessenger.of(Get.context!).showSnackBar(snackBar);
}
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
Future<void> getSmsCode() async {
issmsCode.value = true;
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
FocusScope.of(Get.context!).unfocus();
await GetServices().getsmsCode(phoneNumber.value);
startTimer(); //
}
}
Future<void> login() async {
issmsCode.value = false;
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
// ...
//
FocusScope.of(Get.context!).unfocus();
var res =
await GetServices().phoneLogin(phoneNumber.value, smsCode.value);
if (res['code'] != 1000) {
showErrorSnackbar(res["message"]);
} else {
LoginPrefs().savePhone(phoneNumber.value);
LoginPrefs().saveExpire(res["data"]["expire"]);
LoginPrefs().saveToken(res["data"]["token"]);
Get.offNamed('home'); //
}
}
}
}
class PhoneLoginPage extends GetView<PhoneLoginController> {
const PhoneLoginPage({super.key});
@override
Widget build(BuildContext context) {
return Container(
key: _scaffoldKey,
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Form(
key: _formKey,
child:
//
Column(
key: controller._formKey,
child: Column(
children: [
//
TextFormField(
maxLength: 11,
initialValue: phoneNumber,
initialValue: controller.phoneNumber.value,
decoration: const InputDecoration(
labelText: '手机号',
),
@ -313,7 +348,8 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
return str == "" ? null : str;
},
onSaved: (String? value) => phoneNumber = value!,
onSaved: (String? value) =>
controller.phoneNumber.value = value!,
),
Row(
children: [
@ -330,27 +366,21 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
str = '验证码不能为空';
}
if (issmsCode) {
if (controller.issmsCode.value) {
return null;
}
return str == "" ? null : str;
},
onSaved: (val) => smsCode = val!,
onSaved: (String? value) =>
controller.smsCode.value = value!,
),
),
//
ElevatedButton(
onPressed: () async {
issmsCode = true;
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
FocusScope.of(context).unfocus();
await GetServices().getsmsCode(phoneNumber);
startTimer(); //
}
controller.getSmsCode();
},
child: Text(smsText),
child: Obx(() => Text(controller.smsText.value)),
),
],
),
@ -359,32 +389,13 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
//
ElevatedButton(
onPressed: () async {
issmsCode = false;
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
// ...
//
FocusScope.of(context).unfocus();
var res = await GetServices()
.phoneLogin(phoneNumber, smsCode);
setState(() {
if (res['code'] != 1000) {
showErrorSnackbar(
_scaffoldKey.currentContext!, res["message"]);
} else {
loginPrefs.savePhone(phoneNumber);
loginPrefs.saveExpire(res["data"]["expire"]);
loginPrefs.saveToken(res["data"]["token"]);
Navigator.pushNamed(
_scaffoldKey.currentContext!, 'home'); //
}
});
}
controller.login();
},
child: const Text('登录'),
),
],
)),
),
),
],
),
),

View File

@ -0,0 +1,48 @@
//
import 'package:flutter/material.dart';
import '../../main.dart';
import '../../service/user/loginprefs.dart';
import 'login_page.dart';
/*
*
*/
Route<dynamic>? onGenerateRoute(RouteSettings settings) {
Map<String, Widget> routes = {
'home': MyHomePage(title: 'Flutter Demo Home Page'), //app路径
'login': const Login(), //login路径
};
String routerName = routeBeforeHook(settings);
bool mathMap = false;
Route<dynamic>? mathWidget;
routes.forEach((key, v) {
if (key == routerName) {
mathMap = true;
mathWidget = MaterialPageRoute(builder: (BuildContext context) => v);
}
});
if (mathMap) {
return mathWidget;
}
return MaterialPageRoute(
builder: (BuildContext context) => const Text('404'));
}
String routeBeforeHook(RouteSettings settings) {
if (checkToken() == false) {
return 'login';
} else {
return settings.name!;
}
}
bool checkToken() {
LoginPrefs loginPrefs = LoginPrefs();
String token = loginPrefs.getToken();
if ('' != token) return true;
return false;
}

View File

@ -19,17 +19,17 @@ import "controller.dart";
ScenceMapController mapcontroller = Get.put(ScenceMapController());
class PassTrack extends StatefulWidget {
final String date;
final controller;
// class PassTrack extends StatefulWidget {
// final String date;
// final controller;
const PassTrack({super.key, required this.date, this.controller});
// const PassTrack({super.key, required this.date, this.controller});
@override
State<PassTrack> createState() => _PasstrackState();
}
// @override
// State<PassTrack> createState() => _PasstrackState();
// }
class _PasstrackState extends State<PassTrack> {
class PassTrack extends GetView<PassTrackController> {
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
GlobalKey<PopupMenuButtonState<int>>();
final controller = Get.put(PassTrackController("TEST", "pile_cm"));
@ -42,39 +42,39 @@ class _PasstrackState extends State<PassTrack> {
int maxLength = 200;
SfRangeValues _rangevalues = const SfRangeValues(0.0, 200.0);
@override
initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
// .ceil();
// @override
// initState() {
// super.initState();
// SchedulerBinding.instance.addPostFrameCallback((_) async {
// // sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
// // .ceil();
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
// fileHandle.date = widget.date;
// await fileHandle.init();
// //
// // await initPlatformState();
// if (fileHandle.pointData.isNotEmpty) {
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
// }
// // // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
// // fileHandle.date = widget.date;
// // await fileHandle.init();
// // //
// // // await initPlatformState();
// // if (fileHandle.pointData.isNotEmpty) {
// // DecodeDataObj obj = fileHandle.pointData[0].obj!;
// // scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
// // }
// for (var item in fileHandle.deviceList) {
// if (item["point"] != null) {
// bits = item["bits"];
// break;
// }
// }
// // passTrackPlugin.map_setCenterDevice(bits);
// setState(() {
// if (fileHandle.pointData.isNotEmpty) {
// maxLength = fileHandle.pointData.length;
// // _value = maxLength;
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
// }
// // for (var item in fileHandle.deviceList) {
// // if (item["point"] != null) {
// // bits = item["bits"];
// // break;
// // }
// // }
// // // passTrackPlugin.map_setCenterDevice(bits);
// // setState(() {
// // if (fileHandle.pointData.isNotEmpty) {
// // maxLength = fileHandle.pointData.length;
// // // _value = maxLength;
// // _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
// // }
// // });
// });
});
}
// }
Future<void> initPlatformState() async {
// String platformVersion;

View File

@ -12,50 +12,249 @@ import 'coor_trans.dart';
final BlueToothController blueToothController = Get.put(BlueToothController());
BlueSetting blueSetting = BlueSetting();
class XyChangeView extends StatefulWidget {
const XyChangeView({super.key});
// class XyChangeView extends StatefulWidget {
// const XyChangeView({super.key});
@override
State<XyChangeView> createState() => _XyChangeViewState();
}
// @override
// State<XyChangeView> createState() => _XyChangeViewState();
// }
class _XyChangeViewState extends State<XyChangeView> {
List<Widget> list = [];
CoorTransModel coorTrans = CoorTransModel(
name: "",
L0: 0,
belt: "",
dstEllipsoid: "",
dx: 0,
dy: 0,
dz: 0,
id: 0,
wx: 0,
wy: 0,
wz: 0,
k: 0,
elevation: 0,
isMain: 0,
rota: 0,
srcEllipsoid: "");
// class _XyChangeViewState extends State<XyChangeView> {
// List<Widget> list = [];
// CoorTransModel coorTrans = CoorTransModel(
// name: "",
// L0: 0,
// belt: "",
// dstEllipsoid: "",
// dx: 0,
// dy: 0,
// dz: 0,
// id: 0,
// wx: 0,
// wy: 0,
// wz: 0,
// k: 0,
// elevation: 0,
// isMain: 0,
// rota: 0,
// srcEllipsoid: "");
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async {
List coordTransmap = await GetServices().getCoordTrans();
if (coordTransmap.isNotEmpty) {
var mianBelt =
coordTransmap.firstWhere((element) => element['belt'] == 'main');
coorTrans = CoorTransModel.fromJson(mianBelt);
setState(() {});
} else {
print("当前项目没有设置中央子午线");
return;
}
});
}
// @override
// void initState() {
// super.initState();
// SchedulerBinding.instance.addPostFrameCallback((_) async {
// List coordTransmap = await GetServices().getCoordTrans();
// if (coordTransmap.isNotEmpty) {
// var mianBelt =
// coordTransmap.firstWhere((element) => element['belt'] == 'main');
// coorTrans = CoorTransModel.fromJson(mianBelt);
// setState(() {});
// } else {
// print("当前项目没有设置中央子午线");
// return;
// }
// });
// }
// @override
// Widget build(BuildContext context) {
// final deviceType = getDeviceType(context);
// final size = MediaQuery.of(context).size;
// return Scaffold(
// appBar: AppBar(
// title: const Text("坐标转换"),
// toolbarHeight: 40,
// ),
// body: Container(
// margin: const EdgeInsets.all(5),
// child: ListView.builder(
// itemCount: 1,
// itemBuilder: (BuildContext context, int index) {
// TextEditingController l0Controller =
// TextEditingController(text: coorTrans.L0.toString());
// TextEditingController elevationController =
// TextEditingController(text: coorTrans.elevation.toString());
// TextEditingController dxController =
// TextEditingController(text: coorTrans.dx.toString());
// TextEditingController dyController =
// TextEditingController(text: coorTrans.dy.toString());
// TextEditingController dzController =
// TextEditingController(text: coorTrans.dz.toString());
// TextEditingController wxController =
// TextEditingController(text: coorTrans.wx.toString());
// TextEditingController wyController =
// TextEditingController(text: coorTrans.wy.toString());
// TextEditingController wzController =
// TextEditingController(text: coorTrans.wz.toString());
// TextEditingController kController =
// TextEditingController(text: coorTrans.k.toString());
// List<Widget> list1 = [
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: l0Controller,
// decoration: const InputDecoration(
// prefixText: '中央子午线:',
// border: InputBorder.none,
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: elevationController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: '投影高程:',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// ];
// List<Widget> list2 = [
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: dxController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: 'x平移(m):',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: dyController,
// decoration: const InputDecoration(
// prefixText: 'Y平移(米):',
// border: InputBorder.none,
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: dzController,
// decoration: const InputDecoration(
// prefixText: 'Z平移(米):',
// border: InputBorder.none,
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// ];
// List<Widget> list3 = [
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: wxController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: 'X轴旋转(秒):',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: wyController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: 'Y轴旋转(秒):',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// Flexible(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: wzController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: 'Z轴旋转(秒):',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// ];
// return Column(
// children: <Widget>[
// deviceType == DeviceType.mobile && size.width < 350
// ? Column(
// children: list1,
// )
// : Row(
// children: list1,
// ),
// const Divider(),
// deviceType == DeviceType.mobile && size.width < 350
// ? Column(
// children: list2,
// )
// : Row(children: list2),
// const Divider(),
// deviceType == DeviceType.mobile && size.width < 350
// ? Column(
// children: list3,
// )
// : Row(
// children: list3,
// ),
// const Divider(),
// SizedBox(
// child: TextFormField(
// keyboardType: TextInputType.number,
// controller: kController,
// decoration: const InputDecoration(
// border: InputBorder.none,
// prefixText: '尺度:',
// ),
// onChanged: (String value) {
// // coorTrans.L0 =(value);
// },
// )),
// const Divider(),
// TextButton(
// onPressed: () {
// Connect().writeCoorTransValue(
// blueToothController.connectedDeviceID.value,
// coorTrans);
// },
// child: const Text("更新设置"))
// ],
// );
// },
// ),
// ));
// }
// }
class XyChangeView extends StatelessWidget {
XyChangeView({super.key});
final XYChangeController _controller = Get.put(XYChangeController());
@override
Widget build(BuildContext context) {
final deviceType = getDeviceType(context);
@ -71,24 +270,24 @@ class _XyChangeViewState extends State<XyChangeView> {
child: ListView.builder(
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
TextEditingController l0Controller =
TextEditingController(text: coorTrans.L0.toString());
TextEditingController elevationController =
TextEditingController(text: coorTrans.elevation.toString());
TextEditingController dxController =
TextEditingController(text: coorTrans.dx.toString());
TextEditingController dyController =
TextEditingController(text: coorTrans.dy.toString());
TextEditingController dzController =
TextEditingController(text: coorTrans.dz.toString());
TextEditingController wxController =
TextEditingController(text: coorTrans.wx.toString());
TextEditingController wyController =
TextEditingController(text: coorTrans.wy.toString());
TextEditingController wzController =
TextEditingController(text: coorTrans.wz.toString());
TextEditingController kController =
TextEditingController(text: coorTrans.k.toString());
TextEditingController l0Controller = TextEditingController(
text: _controller.coorTrans.value.L0.toString());
TextEditingController elevationController = TextEditingController(
text: _controller.coorTrans.value.elevation.toString());
TextEditingController dxController = TextEditingController(
text: _controller.coorTrans.value.dx.toString());
TextEditingController dyController = TextEditingController(
text: _controller.coorTrans.value.dy.toString());
TextEditingController dzController = TextEditingController(
text: _controller.coorTrans.value.dz.toString());
TextEditingController wxController = TextEditingController(
text: _controller.coorTrans.value.wx.toString());
TextEditingController wyController = TextEditingController(
text: _controller.coorTrans.value.wy.toString());
TextEditingController wzController = TextEditingController(
text: _controller.coorTrans.value.wz.toString());
TextEditingController kController = TextEditingController(
text: _controller.coorTrans.value.k.toString());
List<Widget> list1 = [
Flexible(
child: TextFormField(
@ -99,7 +298,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none,
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -112,7 +311,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: '投影高程:',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
];
@ -126,7 +325,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'x平移(m):',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -139,7 +338,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none,
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -152,7 +351,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none,
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -167,7 +366,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'X轴旋转(秒):',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -180,7 +379,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'Y轴旋转(秒):',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -193,7 +392,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'Z轴旋转(秒):',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -232,7 +431,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: '尺度:',
),
onChanged: (String value) {
// coorTrans.L0 =(value);
// _controller.coorTrans.value.L0 =(value);
},
)),
const Divider(),
@ -240,7 +439,7 @@ class _XyChangeViewState extends State<XyChangeView> {
onPressed: () {
Connect().writeCoorTransValue(
blueToothController.connectedDeviceID.value,
coorTrans);
_controller.coorTrans.value);
},
child: const Text("更新设置"))
],
@ -250,3 +449,40 @@ class _XyChangeViewState extends State<XyChangeView> {
));
}
}
class XYChangeController extends GetxController {
List<Widget> list = [];
var coorTrans = CoorTransModel(
name: "",
L0: 0,
belt: "",
dstEllipsoid: "",
dx: 0,
dy: 0,
dz: 0,
id: 0,
wx: 0,
wy: 0,
wz: 0,
k: 0,
elevation: 0,
isMain: 0,
rota: 0,
srcEllipsoid: "",
).obs;
@override
void onInit() {
super.onInit();
SchedulerBinding.instance.addPostFrameCallback((_) async {
List coordTransmap = await GetServices().getCoordTrans();
if (coordTransmap.isNotEmpty) {
var mianBelt =
coordTransmap.firstWhere((element) => element['belt'] == 'main');
coorTrans.value = CoorTransModel.fromJson(mianBelt);
} else {
print("当前项目没有设置中央子午线");
}
});
}
}

View File

@ -100,7 +100,7 @@ class _SettingPortraitState extends State<SettingPortrait> {
// }),
ListItem('坐标转换', Icons.settings, () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const XyChangeView()));
MaterialPageRoute(builder: (context) => XyChangeView()));
}),
ListItem('个人中心', Icons.person_outline_outlined, () {
Navigator.push(context,

View File

@ -3,10 +3,12 @@ import 'package:get/get.dart';
class PileGenerController extends GetxController {
var isPileCardVisible = false.obs; //
var isRealViewCardVisible = false.obs; //
@override
void onInit() {
super.onInit();
// isRealViewCardVisible
ever(isRealViewCardVisible, (bool isVisible) {
if (isVisible) {
isPileCardVisible.value = false;

View File

@ -303,7 +303,7 @@ class PileGenerateCard extends StatelessWidget {
child: Stack(children: [
Container(
decoration: const BoxDecoration(color: Colors.transparent),
child: Stack(children: [
child: const Stack(children: [
Card(
color: Colors.transparent,
elevation: 5.0,
@ -348,7 +348,7 @@ class PileGenerateCard1 extends StatelessWidget {
child: Stack(children: [
Container(
decoration: const BoxDecoration(color: Colors.transparent),
child: Stack(children: [
child: const Stack(children: [
Card(
color: Colors.transparent,
elevation: 5.0,