From f41e6a8c96d57a484cbc4b9aff18902b43df58f8 Mon Sep 17 00:00:00 2001 From: tanlinxing Date: Tue, 29 Oct 2024 17:55:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flutter-plugins-dependencies | 2 +- lib/main.dart | 21 +- lib/pages/history/component/custom_pager.dart | 4 + lib/pages/history/history_record.dart | 4 +- lib/pages/login/login_page.dart | 555 +++++++++--------- lib/pages/login/my_routes.dart | 48 ++ lib/pages/pass_track/view.dart | 78 +-- .../child_pages/XyChange/xy_change.dart | 372 +++++++++--- lib/pages/setting/setting_page.dart | 2 +- .../pileGenerateCard/pileGenerController.dart | 2 + .../pile/pileGenerateCard/pileGenerate.dart | 4 +- 11 files changed, 698 insertions(+), 394 deletions(-) create mode 100644 lib/pages/login/my_routes.dart diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index ef14601..eead3b9 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"open_settings","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\open_settings-2.0.2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_apple-9.4.5\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]},{"name":"wifi_iot","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_iot-0.3.19+1\\\\","native_build":true,"dependencies":[]},{"name":"wifi_scan","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_scan-0.4.1+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"open_settings","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\open_settings-2.0.2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_android-12.0.12\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]},{"name":"wifi_iot","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_iot-0.3.19+1\\\\","native_build":true,"dependencies":[]},{"name":"wifi_scan","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_scan-0.4.1+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_windows-0.2.1\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"permission_handler_html","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_html-0.1.3+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"libserialport","dependencies":[]},{"name":"open_settings","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"quick_blue","dependencies":[]},{"name":"wifi_iot","dependencies":[]},{"name":"wifi_scan","dependencies":[]}],"date_created":"2024-09-05 12:00:53.082263","version":"3.24.0","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"open_settings","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\open_settings-2.0.2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_apple-9.4.5\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]},{"name":"wifi_iot","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_iot-0.3.19+1\\\\","native_build":true,"dependencies":[]},{"name":"wifi_scan","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_scan-0.4.1+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"open_settings","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\open_settings-2.0.2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_android-12.0.12\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]},{"name":"wifi_iot","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_iot-0.3.19+1\\\\","native_build":true,"dependencies":[]},{"name":"wifi_scan","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\wifi_scan-0.4.1+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_windows-0.2.1\\\\","native_build":true,"dependencies":[]},{"name":"quick_blue","path":"D:\\\\workspace\\\\pile_NAV_new\\\\plugins\\\\quick_blue\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"permission_handler_html","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler_html-0.1.3+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"libserialport","dependencies":[]},{"name":"open_settings","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"quick_blue","dependencies":[]},{"name":"wifi_iot","dependencies":[]},{"name":"wifi_scan","dependencies":[]}],"date_created":"2024-09-12 10:36:05.495652","version":"3.24.0","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 28ab9c4..f1fdabc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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,8 +79,8 @@ class _MyHomePageState extends State { final List _pages = [ Real(), PassTrack( - date: '', - ), + // date: '', + ), TaskManagePage(), HistoryRecord(), SettingPortrait() @@ -81,12 +92,6 @@ class _MyHomePageState extends State { 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( diff --git a/lib/pages/history/component/custom_pager.dart b/lib/pages/history/component/custom_pager.dart index f3f498b..02de0a6 100644 --- a/lib/pages/history/component/custom_pager.dart +++ b/lib/pages/history/component/custom_pager.dart @@ -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 { } } + + 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 { static const List _availableSizes = [10, 20, 30, 50, 100]; diff --git a/lib/pages/history/history_record.dart b/lib/pages/history/history_record.dart index 52ce3e2..83615b9 100644 --- a/lib/pages/history/history_record.dart +++ b/lib/pages/history/history_record.dart @@ -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 { @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), diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index dba0400..2501164 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -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 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 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 { + const Login({super.key}); @override Widget build(BuildContext context) { @@ -44,7 +43,7 @@ class _LoginState extends State 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 with SingleTickerProviderStateMixin { ), Expanded( child: TabBarView( - controller: _tabController, + controller: controller.tabController, children: const [ PhoneLoginPage(), AccountLoginPage(), @@ -65,48 +64,56 @@ class _LoginState extends State with SingleTickerProviderStateMixin { } } -class AccountLoginPage extends StatefulWidget { - const AccountLoginPage({super.key}); +class AccountLoginController extends GetxController { + final formKey = GlobalKey(); + final username = ''.obs; + final password = ''.obs; + final verifyCode = ''.obs; + final svgString = ''.obs; + final captchaId = ''.obs; + final obscureText = false.obs; @override - State createState() => _AccountLoginPageState(); -} - -class _AccountLoginPageState extends State { - //初始化FormState - final _formKey = GlobalKey(); - 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 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 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 { + const AccountLoginPage({super.key}); + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -115,119 +122,124 @@ class _AccountLoginPageState extends State { child: Column( children: [ Form( - key: _formKey, - child: Column( - children: [ - // 账号输入框 - TextFormField( - decoration: const InputDecoration( - 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; - }, + key: controller.formKey, + child: Column( + children: [ + // 账号输入框 + TextFormField( + decoration: const InputDecoration( + labelText: '用户名:', ), - const SizedBox(height: 16.0), + onSaved: (String? value) => + controller.username.value = value!, + validator: (String? value) { + String str = ""; - // 密码输入框 - TextFormField( - decoration: InputDecoration( - labelText: '密码:', - suffixIcon: IconButton( - 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@#$]+$'); + RegExp regex = RegExp(r'^[a-zA-Z0-9]+$'); + if (value!.isEmpty) { + str = '用户名不能为空'; + } else if (!regex.hasMatch(value)) { + str = '请输入有效的账号'; + } - if (value!.isEmpty) { - str = '密码不能为空'; - } else if (!regex.hasMatch(value)) { - str = '请输入有效的密码'; - } + return str == "" ? null : str; + }, + ), + const SizedBox(height: 16.0), - return str == "" ? null : str; - }, - ), - const SizedBox(height: 24.0), - Row( - children: [ - Expanded( - child: TextFormField( - decoration: const InputDecoration( - labelText: '验证码:', - ), - keyboardType: TextInputType.phone, - validator: (String? value) { - String str = ""; - - if (value!.isEmpty) { - str = '验证码不能为空'; - } - - return str == "" ? null : str; - }, - onSaved: (String? value) => verifyCode = value!, - ), + // 密码输入框 + Obx(() => TextFormField( + decoration: InputDecoration( + labelText: '密码:', + suffixIcon: IconButton( + icon: Icon( + controller.obscureText.value + ? Icons.visibility + : Icons.visibility_off, + ), + onPressed: () { + controller.obscureText.toggle(); // 切换密码可见状态 + }), ), - ElevatedButton( - onPressed: () async { - changeCaptcha(); - }, - child: svgString.isNotEmpty - ? SvgPicture.string( - svgString, - width: 70, // 设置宽度 - height: 40, // 设置高度 - color: Colors.black, - ) - : const Text("")) - ], - ), - // 登录按钮 - ElevatedButton( - onPressed: () async { - if (_formKey.currentState!.validate()) { - _formKey.currentState!.save(); //必须 - var res = await GetServices().getAccountLogin( - captchaId, password, username, verifyCode); - setState(() { - if (res['code'] != 1000) { - changeCaptcha(); - showErrorSnackbar(context, res["message"]); - } else { - loginPrefs.saveExpire((res["data"]["expire"])); - loginPrefs.saveToken((res["data"]["token"])); - Navigator.pushNamed(context, 'home'); //跳转至首页 + obscureText: controller.obscureText.value, + onSaved: (String? value) => + controller.password.value = 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: 24.0), + Row( + children: [ + Expanded( + child: TextFormField( + decoration: const InputDecoration( + labelText: '验证码:', + ), + keyboardType: TextInputType.phone, + validator: (String? value) { + String str = ""; + + 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 { } } -class PhoneLoginPage extends StatefulWidget { - const PhoneLoginPage({super.key}); - - @override - State createState() => _PhoneLoginPageState(); -} - -class _PhoneLoginPageState extends State { - String phoneNumber = ""; - String smsCode = ""; - bool issmsCode = false; - String smsText = "获取验证码"; - int _seconds = 60; - late Timer _timer; - //初始化FormState +class PhoneLoginController extends GetxController { final _formKey = GlobalKey(); - 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 _scaffoldKey = GlobalKey(); + Future getSmsCode() async { + issmsCode.value = true; + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + // 收回键盘 + FocusScope.of(Get.context!).unfocus(); + await GetServices().getsmsCode(phoneNumber.value); + startTimer(); // 开始定时器 + } + } + + Future 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 { + const PhoneLoginPage({super.key}); + @override Widget build(BuildContext context) { return Container( - key: _scaffoldKey, padding: const EdgeInsets.all(16.0), child: SingleChildScrollView( child: Column( children: [ Form( - key: _formKey, - child: - // 手机号输入框 - Column( - children: [ - TextFormField( - maxLength: 11, - initialValue: phoneNumber, - decoration: const InputDecoration( - 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!, + key: controller._formKey, + child: Column( + children: [ + // 手机号输入框 + TextFormField( + maxLength: 11, + initialValue: controller.phoneNumber.value, + decoration: const InputDecoration( + labelText: '手机号', ), - Row( - children: [ - Expanded( - child: TextFormField( - maxLength: 6, - decoration: const InputDecoration( - labelText: '验证码', - ), - keyboardType: TextInputType.phone, - validator: (String? value) { - String str = ""; - if (value!.isEmpty) { - str = '验证码不能为空'; - } + 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 = '请输入有效的手机号'; + } - if (issmsCode) { - return null; - } - return str == "" ? null : str; - }, - onSaved: (val) => smsCode = val!, + return str == "" ? null : str; + }, + onSaved: (String? value) => + controller.phoneNumber.value = value!, + ), + Row( + children: [ + Expanded( + child: TextFormField( + maxLength: 6, + decoration: const InputDecoration( + labelText: '验证码', ), - ), - // 获取验证码按钮 - ElevatedButton( - onPressed: () async { - issmsCode = true; - if (_formKey.currentState!.validate()) { - _formKey.currentState!.save(); - // 收回键盘 - FocusScope.of(context).unfocus(); - await GetServices().getsmsCode(phoneNumber); - startTimer(); // 开始定时器 + keyboardType: TextInputType.phone, + validator: (String? value) { + String str = ""; + if (value!.isEmpty) { + str = '验证码不能为空'; } - }, - child: Text(smsText), - ), - ], - ), - const SizedBox(height: 16.0), - // 登录按钮 - 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'); //跳转至首页 + if (controller.issmsCode.value) { + return null; } - }); - } - }, - child: const Text('登录'), - ), - ], - )), + return str == "" ? null : str; + }, + onSaved: (String? value) => + 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('登录'), + ), + ], + ), + ), ], ), ), diff --git a/lib/pages/login/my_routes.dart b/lib/pages/login/my_routes.dart new file mode 100644 index 0000000..af72a02 --- /dev/null +++ b/lib/pages/login/my_routes.dart @@ -0,0 +1,48 @@ +//配置路由 + +import 'package:flutter/material.dart'; + +import '../../main.dart'; +import '../../service/user/loginprefs.dart'; +import 'login_page.dart'; + +/* + * 这个方法是固定写法,功能就像是一个拦截器。 + */ +Route? onGenerateRoute(RouteSettings settings) { + Map routes = { + 'home': MyHomePage(title: 'Flutter Demo Home Page'), //定义app路径 + 'login': const Login(), //定义login路径 + }; + + String routerName = routeBeforeHook(settings); + bool mathMap = false; + Route? 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; +} diff --git a/lib/pages/pass_track/view.dart b/lib/pages/pass_track/view.dart index 6febc2e..bc8f8b6 100644 --- a/lib/pages/pass_track/view.dart +++ b/lib/pages/pass_track/view.dart @@ -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 createState() => _PasstrackState(); -} +// @override +// State createState() => _PasstrackState(); +// } -class _PasstrackState extends State { +class PassTrack extends GetView { final GlobalKey> _popupMenuKey = GlobalKey>(); final controller = Get.put(PassTrackController("TEST", "pile_cm")); @@ -42,39 +42,39 @@ class _PasstrackState extends State { 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 initPlatformState() async { // String platformVersion; diff --git a/lib/pages/setting/child_pages/XyChange/xy_change.dart b/lib/pages/setting/child_pages/XyChange/xy_change.dart index 417a020..a01a0b1 100644 --- a/lib/pages/setting/child_pages/XyChange/xy_change.dart +++ b/lib/pages/setting/child_pages/XyChange/xy_change.dart @@ -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 createState() => _XyChangeViewState(); -} +// @override +// State createState() => _XyChangeViewState(); +// } -class _XyChangeViewState extends State { - List 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 { +// List 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 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 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 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: [ +// 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 { 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 list1 = [ Flexible( child: TextFormField( @@ -99,7 +298,7 @@ class _XyChangeViewState extends State { border: InputBorder.none, ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -112,7 +311,7 @@ class _XyChangeViewState extends State { prefixText: '投影高程:', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), ]; @@ -126,7 +325,7 @@ class _XyChangeViewState extends State { prefixText: 'x平移(m):', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -139,7 +338,7 @@ class _XyChangeViewState extends State { border: InputBorder.none, ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -152,7 +351,7 @@ class _XyChangeViewState extends State { border: InputBorder.none, ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -167,7 +366,7 @@ class _XyChangeViewState extends State { prefixText: 'X轴旋转(秒):', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -180,7 +379,7 @@ class _XyChangeViewState extends State { prefixText: 'Y轴旋转(秒):', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -193,7 +392,7 @@ class _XyChangeViewState extends State { prefixText: 'Z轴旋转(秒):', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -232,7 +431,7 @@ class _XyChangeViewState extends State { prefixText: '尺度:', ), onChanged: (String value) { - // coorTrans.L0 =(value); + // _controller.coorTrans.value.L0 =(value); }, )), const Divider(), @@ -240,7 +439,7 @@ class _XyChangeViewState extends State { onPressed: () { Connect().writeCoorTransValue( blueToothController.connectedDeviceID.value, - coorTrans); + _controller.coorTrans.value); }, child: const Text("更新设置")) ], @@ -250,3 +449,40 @@ class _XyChangeViewState extends State { )); } } + +class XYChangeController extends GetxController { + List 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("当前项目没有设置中央子午线"); + } + }); + } +} diff --git a/lib/pages/setting/setting_page.dart b/lib/pages/setting/setting_page.dart index dce3397..546bb01 100644 --- a/lib/pages/setting/setting_page.dart +++ b/lib/pages/setting/setting_page.dart @@ -100,7 +100,7 @@ class _SettingPortraitState extends State { // }), ListItem('坐标转换', Icons.settings, () { Navigator.push(context, - MaterialPageRoute(builder: (context) => const XyChangeView())); + MaterialPageRoute(builder: (context) => XyChangeView())); }), ListItem('个人中心', Icons.person_outline_outlined, () { Navigator.push(context, diff --git a/lib/pages/task/pile/pileGenerateCard/pileGenerController.dart b/lib/pages/task/pile/pileGenerateCard/pileGenerController.dart index 787063d..c5a7b99 100644 --- a/lib/pages/task/pile/pileGenerateCard/pileGenerController.dart +++ b/lib/pages/task/pile/pileGenerateCard/pileGenerController.dart @@ -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; diff --git a/lib/pages/task/pile/pileGenerateCard/pileGenerate.dart b/lib/pages/task/pile/pileGenerateCard/pileGenerate.dart index bcd388a..09ef7a2 100644 --- a/lib/pages/task/pile/pileGenerateCard/pileGenerate.dart +++ b/lib/pages/task/pile/pileGenerateCard/pileGenerate.dart @@ -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,