新提交

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

View File

@ -1,5 +1,6 @@
import 'package:data_table_2/data_table_2.dart'; import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
class PageNumber extends StatefulWidget { class PageNumber extends StatefulWidget {
const PageNumber({ const PageNumber({
@ -46,6 +47,8 @@ class PageNumberState extends State<PageNumber> {
} }
} }
class CustomPager extends StatefulWidget { class CustomPager extends StatefulWidget {
const CustomPager(this.controller, {super.key}); const CustomPager(this.controller, {super.key});
@ -55,6 +58,7 @@ class CustomPager extends StatefulWidget {
CustomPagerState createState() => CustomPagerState(); CustomPagerState createState() => CustomPagerState();
} }
class CustomPagerState extends State<CustomPager> { class CustomPagerState extends State<CustomPager> {
static const List<int> _availableSizes = [10, 20, 30, 50, 100]; 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 // import 'record_data_source.dart'; // bug proj_type
int currentPage = 1; int currentPage = 1;
List dataList = []; List dataList = [];
List constructionData = []; List constructionData = [];
@ -170,8 +169,7 @@ class _HistoryRecordState extends State<HistoryRecord> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final size = MediaQuery.of(context).size; final size = MediaQuery.of(context).size;
final isDarkMode = final isDarkMode = Theme.of(context).brightness == Brightness.dark;
Theme.of(context).brightness == Brightness.dark;
return Container( return Container(
height: size.height, height: size.height,
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),

View File

@ -1,5 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
@ -7,28 +7,27 @@ import 'package:cpnav/service/base.dart';
import '../../service/user/loginprefs.dart'; import '../../service/user/loginprefs.dart';
class Login extends StatefulWidget { class LoginPageController extends GetxController
const Login({super.key}); with SingleGetTickerProviderMixin {
late TabController _tabController;
@override @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 { class Login extends GetView<LoginPageController> {
//with SingleTickerProviderStateMixin 使this const Login({super.key});
late TabController _tabController;
//
@override
void initState() {
_tabController = TabController(length: 2, vsync: this);
super.initState();
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -44,7 +43,7 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
labelStyle: const TextStyle(color: Colors.black), // labelStyle: const TextStyle(color: Colors.black), //
unselectedLabelStyle: unselectedLabelStyle:
const TextStyle(color: Colors.grey), // const TextStyle(color: Colors.grey), //
controller: _tabController, controller: controller.tabController,
tabs: const [ tabs: const [
Tab(text: '手机号登录', icon: Icon(Icons.phone_android)), Tab(text: '手机号登录', icon: Icon(Icons.phone_android)),
Tab(text: '账号登录', icon: Icon(Icons.account_box_outlined)), Tab(text: '账号登录', icon: Icon(Icons.account_box_outlined)),
@ -52,7 +51,7 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
), ),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
controller: _tabController, controller: controller.tabController,
children: const [ children: const [
PhoneLoginPage(), PhoneLoginPage(),
AccountLoginPage(), AccountLoginPage(),
@ -65,48 +64,56 @@ class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
} }
} }
class AccountLoginPage extends StatefulWidget { class AccountLoginController extends GetxController {
const AccountLoginPage({super.key}); final formKey = GlobalKey<FormState>();
final username = ''.obs;
final password = ''.obs;
final verifyCode = ''.obs;
final svgString = ''.obs;
final captchaId = ''.obs;
final obscureText = false.obs;
@override @override
State<AccountLoginPage> createState() => _AccountLoginPageState(); void onInit() {
} super.onInit();
changeCaptcha();
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();
});
} }
changeCaptcha() async { Future<void> changeCaptcha() async {
var captcha = await GetServices().getCaptcha(); var captcha = await GetServices().getCaptcha();
setState(() { svgString.value = captcha['data'];
svgString = captcha['data']; captchaId.value = captcha['captchaId'];
captchaId = captcha['captchaId'];
});
} }
showErrorSnackbar(BuildContext context, String text) { void showErrorSnackbar(String text) {
final snackBar = SnackBar( final snackBar = SnackBar(
content: Text(text), content: Text(text),
backgroundColor: Colors.red, backgroundColor: Colors.red,
); );
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(Get.context!).showSnackBar(snackBar);
} }
LoginPrefs loginPrefs = LoginPrefs(); // Future<void> login() async {
bool _obscureText = false; // 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return SingleChildScrollView(
@ -115,119 +122,124 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
child: Column( child: Column(
children: [ children: [
Form( Form(
key: _formKey, key: controller.formKey,
child: Column( child: Column(
children: [ children: [
// //
TextFormField( TextFormField(
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: '用户名:', labelText: '用户名:',
),
onSaved: (String? value) => username = value!,
validator: (String? value) {
String str = "";
RegExp regex = RegExp(r'^[a-zA-Z0-9]+$');
if (value!.isEmpty) {
str = '用户名不能为空';
} else if (!regex.hasMatch(value)) {
str = '请输入有效的账号';
}
return str == "" ? null : str;
},
), ),
const SizedBox(height: 16.0), onSaved: (String? value) =>
controller.username.value = value!,
validator: (String? value) {
String str = "";
// RegExp regex = RegExp(r'^[a-zA-Z0-9]+$');
TextFormField( if (value!.isEmpty) {
decoration: InputDecoration( str = '用户名不能为空';
labelText: '密码:', } else if (!regex.hasMatch(value)) {
suffixIcon: IconButton( str = '请输入有效的账号';
icon: Icon( }
_obscureText
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscureText = !_obscureText; //
});
}),
),
obscureText: _obscureText,
onSaved: (String? value) => password = value!,
validator: (String? value) {
String str = "";
RegExp regex = RegExp(r'^[a-zA-Z0-9@#$]+$');
if (value!.isEmpty) { return str == "" ? null : str;
str = '密码不能为空'; },
} else if (!regex.hasMatch(value)) { ),
str = '请输入有效的密码'; const SizedBox(height: 16.0),
}
return str == "" ? null : str; //
}, Obx(() => TextFormField(
), decoration: InputDecoration(
const SizedBox(height: 24.0), labelText: '密码:',
Row( suffixIcon: IconButton(
children: [ icon: Icon(
Expanded( controller.obscureText.value
child: TextFormField( ? Icons.visibility
decoration: const InputDecoration( : Icons.visibility_off,
labelText: '验证码:', ),
), onPressed: () {
keyboardType: TextInputType.phone, controller.obscureText.toggle(); //
validator: (String? value) { }),
String str = "";
if (value!.isEmpty) {
str = '验证码不能为空';
}
return str == "" ? null : str;
},
onSaved: (String? value) => verifyCode = value!,
),
), ),
ElevatedButton( obscureText: controller.obscureText.value,
onPressed: () async { onSaved: (String? value) =>
changeCaptcha(); controller.password.value = value!,
}, validator: (String? value) {
child: svgString.isNotEmpty String str = "";
? SvgPicture.string( RegExp regex = RegExp(r'^[a-zA-Z0-9@#$]+$');
svgString,
width: 70, // if (value!.isEmpty) {
height: 40, // str = '密码不能为空';
color: Colors.black, } else if (!regex.hasMatch(value)) {
) str = '请输入有效的密码';
: const Text("")) }
],
), return str == "" ? null : str;
// },
ElevatedButton( )),
onPressed: () async { const SizedBox(height: 24.0),
if (_formKey.currentState!.validate()) { Row(
_formKey.currentState!.save(); // children: [
var res = await GetServices().getAccountLogin( Expanded(
captchaId, password, username, verifyCode); child: TextFormField(
setState(() { decoration: const InputDecoration(
if (res['code'] != 1000) { labelText: '验证码:',
changeCaptcha(); ),
showErrorSnackbar(context, res["message"]); keyboardType: TextInputType.phone,
} else { validator: (String? value) {
loginPrefs.saveExpire((res["data"]["expire"])); String str = "";
loginPrefs.saveToken((res["data"]["token"]));
Navigator.pushNamed(context, 'home'); // if (value!.isEmpty) {
str = '验证码不能为空';
} }
});
return str == "" ? null : str;
},
onSaved: (String? value) =>
controller.verifyCode.value = value!,
),
),
ElevatedButton(
onPressed: () async {
controller.changeCaptcha();
},
child: Obx(() => controller.svgString.isNotEmpty
? SvgPicture.string(
controller.svgString.value,
width: 70, //
height: 40, //
color: Colors.black,
)
: const Text("")))
],
),
//
ElevatedButton(
onPressed: () async {
if (controller.formKey.currentState!.validate()) {
controller.formKey.currentState!.save(); //
var res = await GetServices().getAccountLogin(
controller.captchaId.value,
controller.password.value,
controller.username.value,
controller.verifyCode.value);
if (res['code'] != 1000) {
controller.changeCaptcha();
controller.showErrorSnackbar(res["message"]);
} else {
loginPrefs.saveExpire((res["data"]["expire"]));
loginPrefs.saveToken((res["data"]["token"]));
Navigator.pushNamed(context, 'home'); //
} }
}, }
child: const Text('登录'), },
), child: const Text('登录'),
], )
)) ],
),
)
], ],
), ),
), ),
@ -235,156 +247,155 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
} }
} }
class PhoneLoginPage extends StatefulWidget { class PhoneLoginController extends GetxController {
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
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
LoginPrefs loginPrefs = LoginPrefs(); final phoneNumber = ''.obs;
@override final smsCode = ''.obs;
void initState() { final issmsCode = false.obs;
super.initState(); final smsText = '获取验证码'.obs;
final _seconds = 60.obs;
late Timer _timer;
phoneNumber = loginPrefs.getPhone(); @override
void onInit() {
super.onInit();
phoneNumber.value = LoginPrefs().getPhone();
} }
void startTimer() { void startTimer() {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) { _timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_seconds > 0) { if (_seconds.value > 0) {
_seconds -= 1; _seconds.value -= 1;
smsText = "重新获取(${_seconds}s)"; smsText.value = "重新获取(${_seconds.value}s)";
} else { } else {
_timer.cancel(); // 0 _timer.cancel(); // 0
smsText = "获取验证码"; smsText.value = "获取验证码";
} }
}); });
} }
showErrorSnackbar(BuildContext context, String text) { void showErrorSnackbar(String text) {
final snackBar = SnackBar( final snackBar = SnackBar(
content: Text(text), content: Text(text),
backgroundColor: Colors.red, 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
key: _scaffoldKey,
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Form( Form(
key: _formKey, key: controller._formKey,
child: child: Column(
// children: [
Column( //
children: [ TextFormField(
TextFormField( maxLength: 11,
maxLength: 11, initialValue: controller.phoneNumber.value,
initialValue: phoneNumber, decoration: const InputDecoration(
decoration: const InputDecoration( labelText: '手机号',
labelText: '手机号',
),
keyboardType: TextInputType.phone,
validator: (String? value) {
String str = "";
final RegExp phoneRegex = RegExp(r'^[1-9]\d{10}$');
if (value!.isEmpty) {
str = '手机号不能为空';
} else if (!phoneRegex.hasMatch(value)) {
str = '请输入有效的手机号';
}
return str == "" ? null : str;
},
onSaved: (String? value) => phoneNumber = value!,
), ),
Row( keyboardType: TextInputType.phone,
children: [ validator: (String? value) {
Expanded( String str = "";
child: TextFormField( final RegExp phoneRegex = RegExp(r'^[1-9]\d{10}$');
maxLength: 6, if (value!.isEmpty) {
decoration: const InputDecoration( str = '手机号不能为空';
labelText: '验证码', } else if (!phoneRegex.hasMatch(value)) {
), str = '请输入有效的手机号';
keyboardType: TextInputType.phone, }
validator: (String? value) {
String str = "";
if (value!.isEmpty) {
str = '验证码不能为空';
}
if (issmsCode) { return str == "" ? null : str;
return null; },
} onSaved: (String? value) =>
return str == "" ? null : str; controller.phoneNumber.value = value!,
}, ),
onSaved: (val) => smsCode = val!, Row(
children: [
Expanded(
child: TextFormField(
maxLength: 6,
decoration: const InputDecoration(
labelText: '验证码',
), ),
), keyboardType: TextInputType.phone,
// validator: (String? value) {
ElevatedButton( String str = "";
onPressed: () async { if (value!.isEmpty) {
issmsCode = true; str = '验证码不能为空';
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
FocusScope.of(context).unfocus();
await GetServices().getsmsCode(phoneNumber);
startTimer(); //
} }
},
child: Text(smsText),
),
],
),
const SizedBox(height: 16.0),
// if (controller.issmsCode.value) {
ElevatedButton( return null;
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'); //
} }
}); return str == "" ? null : str;
} },
}, onSaved: (String? value) =>
child: const Text('登录'), controller.smsCode.value = value!,
), ),
], ),
)), //
ElevatedButton(
onPressed: () async {
controller.getSmsCode();
},
child: Obx(() => Text(controller.smsText.value)),
),
],
),
const SizedBox(height: 16.0),
//
ElevatedButton(
onPressed: () async {
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()); ScenceMapController mapcontroller = Get.put(ScenceMapController());
class PassTrack extends StatefulWidget { // class PassTrack extends StatefulWidget {
final String date; // final String date;
final controller; // final controller;
const PassTrack({super.key, required this.date, this.controller}); // const PassTrack({super.key, required this.date, this.controller});
@override // @override
State<PassTrack> createState() => _PasstrackState(); // State<PassTrack> createState() => _PasstrackState();
} // }
class _PasstrackState extends State<PassTrack> { class PassTrack extends GetView<PassTrackController> {
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey = final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
GlobalKey<PopupMenuButtonState<int>>(); GlobalKey<PopupMenuButtonState<int>>();
final controller = Get.put(PassTrackController("TEST", "pile_cm")); final controller = Get.put(PassTrackController("TEST", "pile_cm"));
@ -42,39 +42,39 @@ class _PasstrackState extends State<PassTrack> {
int maxLength = 200; int maxLength = 200;
SfRangeValues _rangevalues = const SfRangeValues(0.0, 200.0); SfRangeValues _rangevalues = const SfRangeValues(0.0, 200.0);
@override // @override
initState() { // initState() {
super.initState(); // super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async { // SchedulerBinding.instance.addPostFrameCallback((_) async {
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height) // // sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
// .ceil(); // // .ceil();
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0; // // // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
// fileHandle.date = widget.date; // // fileHandle.date = widget.date;
// await fileHandle.init(); // // await fileHandle.init();
// // // // //
// // await initPlatformState(); // // // await initPlatformState();
// if (fileHandle.pointData.isNotEmpty) { // // if (fileHandle.pointData.isNotEmpty) {
// DecodeDataObj obj = fileHandle.pointData[0].obj!; // // DecodeDataObj obj = fileHandle.pointData[0].obj!;
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20); // // scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
// } // // }
// for (var item in fileHandle.deviceList) { // // for (var item in fileHandle.deviceList) {
// if (item["point"] != null) { // // if (item["point"] != null) {
// bits = item["bits"]; // // bits = item["bits"];
// break; // // break;
// } // // }
// } // // }
// // passTrackPlugin.map_setCenterDevice(bits); // // // passTrackPlugin.map_setCenterDevice(bits);
// setState(() { // // setState(() {
// if (fileHandle.pointData.isNotEmpty) { // // if (fileHandle.pointData.isNotEmpty) {
// maxLength = fileHandle.pointData.length; // // maxLength = fileHandle.pointData.length;
// // _value = maxLength; // // // _value = maxLength;
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble()); // // _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
// } // // }
// }); // // });
}); // });
} // }
Future<void> initPlatformState() async { Future<void> initPlatformState() async {
// String platformVersion; // String platformVersion;

View File

@ -12,50 +12,249 @@ import 'coor_trans.dart';
final BlueToothController blueToothController = Get.put(BlueToothController()); final BlueToothController blueToothController = Get.put(BlueToothController());
BlueSetting blueSetting = BlueSetting(); BlueSetting blueSetting = BlueSetting();
class XyChangeView extends StatefulWidget { // class XyChangeView extends StatefulWidget {
const XyChangeView({super.key}); // const XyChangeView({super.key});
@override // @override
State<XyChangeView> createState() => _XyChangeViewState(); // State<XyChangeView> createState() => _XyChangeViewState();
} // }
class _XyChangeViewState extends State<XyChangeView> { // class _XyChangeViewState extends State<XyChangeView> {
List<Widget> list = []; // List<Widget> list = [];
CoorTransModel coorTrans = CoorTransModel( // CoorTransModel coorTrans = CoorTransModel(
name: "", // name: "",
L0: 0, // L0: 0,
belt: "", // belt: "",
dstEllipsoid: "", // dstEllipsoid: "",
dx: 0, // dx: 0,
dy: 0, // dy: 0,
dz: 0, // dz: 0,
id: 0, // id: 0,
wx: 0, // wx: 0,
wy: 0, // wy: 0,
wz: 0, // wz: 0,
k: 0, // k: 0,
elevation: 0, // elevation: 0,
isMain: 0, // isMain: 0,
rota: 0, // rota: 0,
srcEllipsoid: ""); // srcEllipsoid: "");
@override // @override
void initState() { // void initState() {
super.initState(); // super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) async { // SchedulerBinding.instance.addPostFrameCallback((_) async {
List coordTransmap = await GetServices().getCoordTrans(); // List coordTransmap = await GetServices().getCoordTrans();
if (coordTransmap.isNotEmpty) { // if (coordTransmap.isNotEmpty) {
var mianBelt = // var mianBelt =
coordTransmap.firstWhere((element) => element['belt'] == 'main'); // coordTransmap.firstWhere((element) => element['belt'] == 'main');
coorTrans = CoorTransModel.fromJson(mianBelt); // coorTrans = CoorTransModel.fromJson(mianBelt);
setState(() {}); // setState(() {});
} else { // } else {
print("当前项目没有设置中央子午线"); // print("当前项目没有设置中央子午线");
return; // 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final deviceType = getDeviceType(context); final deviceType = getDeviceType(context);
@ -71,24 +270,24 @@ class _XyChangeViewState extends State<XyChangeView> {
child: ListView.builder( child: ListView.builder(
itemCount: 1, itemCount: 1,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
TextEditingController l0Controller = TextEditingController l0Controller = TextEditingController(
TextEditingController(text: coorTrans.L0.toString()); text: _controller.coorTrans.value.L0.toString());
TextEditingController elevationController = TextEditingController elevationController = TextEditingController(
TextEditingController(text: coorTrans.elevation.toString()); text: _controller.coorTrans.value.elevation.toString());
TextEditingController dxController = TextEditingController dxController = TextEditingController(
TextEditingController(text: coorTrans.dx.toString()); text: _controller.coorTrans.value.dx.toString());
TextEditingController dyController = TextEditingController dyController = TextEditingController(
TextEditingController(text: coorTrans.dy.toString()); text: _controller.coorTrans.value.dy.toString());
TextEditingController dzController = TextEditingController dzController = TextEditingController(
TextEditingController(text: coorTrans.dz.toString()); text: _controller.coorTrans.value.dz.toString());
TextEditingController wxController = TextEditingController wxController = TextEditingController(
TextEditingController(text: coorTrans.wx.toString()); text: _controller.coorTrans.value.wx.toString());
TextEditingController wyController = TextEditingController wyController = TextEditingController(
TextEditingController(text: coorTrans.wy.toString()); text: _controller.coorTrans.value.wy.toString());
TextEditingController wzController = TextEditingController wzController = TextEditingController(
TextEditingController(text: coorTrans.wz.toString()); text: _controller.coorTrans.value.wz.toString());
TextEditingController kController = TextEditingController kController = TextEditingController(
TextEditingController(text: coorTrans.k.toString()); text: _controller.coorTrans.value.k.toString());
List<Widget> list1 = [ List<Widget> list1 = [
Flexible( Flexible(
child: TextFormField( child: TextFormField(
@ -99,7 +298,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none, border: InputBorder.none,
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -112,7 +311,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: '投影高程:', prefixText: '投影高程:',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
]; ];
@ -126,7 +325,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'x平移(m):', prefixText: 'x平移(m):',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -139,7 +338,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none, border: InputBorder.none,
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -152,7 +351,7 @@ class _XyChangeViewState extends State<XyChangeView> {
border: InputBorder.none, border: InputBorder.none,
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -167,7 +366,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'X轴旋转(秒):', prefixText: 'X轴旋转(秒):',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -180,7 +379,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'Y轴旋转(秒):', prefixText: 'Y轴旋转(秒):',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -193,7 +392,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: 'Z轴旋转(秒):', prefixText: 'Z轴旋转(秒):',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -232,7 +431,7 @@ class _XyChangeViewState extends State<XyChangeView> {
prefixText: '尺度:', prefixText: '尺度:',
), ),
onChanged: (String value) { onChanged: (String value) {
// coorTrans.L0 =(value); // _controller.coorTrans.value.L0 =(value);
}, },
)), )),
const Divider(), const Divider(),
@ -240,7 +439,7 @@ class _XyChangeViewState extends State<XyChangeView> {
onPressed: () { onPressed: () {
Connect().writeCoorTransValue( Connect().writeCoorTransValue(
blueToothController.connectedDeviceID.value, blueToothController.connectedDeviceID.value,
coorTrans); _controller.coorTrans.value);
}, },
child: const Text("更新设置")) 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, () { ListItem('坐标转换', Icons.settings, () {
Navigator.push(context, Navigator.push(context,
MaterialPageRoute(builder: (context) => const XyChangeView())); MaterialPageRoute(builder: (context) => XyChangeView()));
}), }),
ListItem('个人中心', Icons.person_outline_outlined, () { ListItem('个人中心', Icons.person_outline_outlined, () {
Navigator.push(context, Navigator.push(context,

View File

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

View File

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