新提交
This commit is contained in:
parent
ece7aa270c
commit
f41e6a8c96
File diff suppressed because one or more lines are too long
@ -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,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
Real(),
|
Real(),
|
||||||
PassTrack(
|
PassTrack(
|
||||||
date: '',
|
// date: '',
|
||||||
),
|
),
|
||||||
TaskManagePage(),
|
TaskManagePage(),
|
||||||
HistoryRecord(),
|
HistoryRecord(),
|
||||||
@ -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(
|
||||||
|
@ -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];
|
||||||
|
|
||||||
|
@ -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),
|
||||||
|
@ -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,7 +122,7 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Form(
|
Form(
|
||||||
key: _formKey,
|
key: controller.formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// 账号输入框
|
// 账号输入框
|
||||||
@ -123,7 +130,8 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: '用户名:',
|
labelText: '用户名:',
|
||||||
),
|
),
|
||||||
onSaved: (String? value) => username = value!,
|
onSaved: (String? value) =>
|
||||||
|
controller.username.value = value!,
|
||||||
validator: (String? value) {
|
validator: (String? value) {
|
||||||
String str = "";
|
String str = "";
|
||||||
|
|
||||||
@ -140,23 +148,22 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
|
|||||||
const SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
|
|
||||||
// 密码输入框
|
// 密码输入框
|
||||||
TextFormField(
|
Obx(() => TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: '密码:',
|
labelText: '密码:',
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_obscureText
|
controller.obscureText.value
|
||||||
? Icons.visibility
|
? Icons.visibility
|
||||||
: Icons.visibility_off,
|
: Icons.visibility_off,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
controller.obscureText.toggle(); // 切换密码可见状态
|
||||||
_obscureText = !_obscureText; // 切换密码可见状态
|
|
||||||
});
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
obscureText: _obscureText,
|
obscureText: controller.obscureText.value,
|
||||||
onSaved: (String? value) => password = value!,
|
onSaved: (String? value) =>
|
||||||
|
controller.password.value = value!,
|
||||||
validator: (String? value) {
|
validator: (String? value) {
|
||||||
String str = "";
|
String str = "";
|
||||||
RegExp regex = RegExp(r'^[a-zA-Z0-9@#$]+$');
|
RegExp regex = RegExp(r'^[a-zA-Z0-9@#$]+$');
|
||||||
@ -169,7 +176,7 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
|
|||||||
|
|
||||||
return str == "" ? null : str;
|
return str == "" ? null : str;
|
||||||
},
|
},
|
||||||
),
|
)),
|
||||||
const SizedBox(height: 24.0),
|
const SizedBox(height: 24.0),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -188,46 +195,51 @@ class _AccountLoginPageState extends State<AccountLoginPage> {
|
|||||||
|
|
||||||
return str == "" ? null : str;
|
return str == "" ? null : str;
|
||||||
},
|
},
|
||||||
onSaved: (String? value) => verifyCode = value!,
|
onSaved: (String? value) =>
|
||||||
|
controller.verifyCode.value = value!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
changeCaptcha();
|
controller.changeCaptcha();
|
||||||
},
|
},
|
||||||
child: svgString.isNotEmpty
|
child: Obx(() => controller.svgString.isNotEmpty
|
||||||
? SvgPicture.string(
|
? SvgPicture.string(
|
||||||
svgString,
|
controller.svgString.value,
|
||||||
width: 70, // 设置宽度
|
width: 70, // 设置宽度
|
||||||
height: 40, // 设置高度
|
height: 40, // 设置高度
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
)
|
)
|
||||||
: const Text(""))
|
: const Text("")))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// 登录按钮
|
// 登录按钮
|
||||||
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (controller.formKey.currentState!.validate()) {
|
||||||
_formKey.currentState!.save(); //必须
|
controller.formKey.currentState!.save(); //必须
|
||||||
var res = await GetServices().getAccountLogin(
|
var res = await GetServices().getAccountLogin(
|
||||||
captchaId, password, username, verifyCode);
|
controller.captchaId.value,
|
||||||
setState(() {
|
controller.password.value,
|
||||||
|
controller.username.value,
|
||||||
|
controller.verifyCode.value);
|
||||||
|
|
||||||
if (res['code'] != 1000) {
|
if (res['code'] != 1000) {
|
||||||
changeCaptcha();
|
controller.changeCaptcha();
|
||||||
showErrorSnackbar(context, res["message"]);
|
controller.showErrorSnackbar(res["message"]);
|
||||||
} else {
|
} else {
|
||||||
loginPrefs.saveExpire((res["data"]["expire"]));
|
loginPrefs.saveExpire((res["data"]["expire"]));
|
||||||
loginPrefs.saveToken((res["data"]["token"]));
|
loginPrefs.saveToken((res["data"]["token"]));
|
||||||
Navigator.pushNamed(context, 'home'); //跳转至首页
|
Navigator.pushNamed(context, 'home'); //跳转至首页
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('登录'),
|
child: const Text('登录'),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
))
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -235,69 +247,92 @@ 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(
|
||||||
// 手机号输入框
|
|
||||||
Column(
|
|
||||||
children: [
|
children: [
|
||||||
|
// 手机号输入框
|
||||||
TextFormField(
|
TextFormField(
|
||||||
maxLength: 11,
|
maxLength: 11,
|
||||||
initialValue: phoneNumber,
|
initialValue: controller.phoneNumber.value,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: '手机号',
|
labelText: '手机号',
|
||||||
),
|
),
|
||||||
@ -313,7 +348,8 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
|
|||||||
|
|
||||||
return str == "" ? null : str;
|
return str == "" ? null : str;
|
||||||
},
|
},
|
||||||
onSaved: (String? value) => phoneNumber = value!,
|
onSaved: (String? value) =>
|
||||||
|
controller.phoneNumber.value = value!,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -330,27 +366,21 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
|
|||||||
str = '验证码不能为空';
|
str = '验证码不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issmsCode) {
|
if (controller.issmsCode.value) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return str == "" ? null : str;
|
return str == "" ? null : str;
|
||||||
},
|
},
|
||||||
onSaved: (val) => smsCode = val!,
|
onSaved: (String? value) =>
|
||||||
|
controller.smsCode.value = value!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 获取验证码按钮
|
// 获取验证码按钮
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
issmsCode = true;
|
controller.getSmsCode();
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
// 收回键盘
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
await GetServices().getsmsCode(phoneNumber);
|
|
||||||
startTimer(); // 开始定时器
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: Text(smsText),
|
child: Obx(() => Text(controller.smsText.value)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -359,32 +389,13 @@ class _PhoneLoginPageState extends State<PhoneLoginPage> {
|
|||||||
// 登录按钮
|
// 登录按钮
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
issmsCode = false;
|
controller.login();
|
||||||
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'); //跳转至首页
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: const Text('登录'),
|
child: const Text('登录'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
48
lib/pages/login/my_routes.dart
Normal file
48
lib/pages/login/my_routes.dart
Normal 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;
|
||||||
|
}
|
@ -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;
|
||||||
|
@ -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("当前项目没有设置中央子午线");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user