Compare commits
7 Commits
playWithSp
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
cd260e1044 | ||
|
680afe5b41 | ||
|
42fb5c2193 | ||
|
90bb63a532 | ||
|
7f6e0bd0c7 | ||
|
261d77afa0 | ||
27ce92e6ee |
85
.vscode/launch.json
vendored
Normal file
85
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "cpnav",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cpnav (profile mode)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cpnav (release mode)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pass_track",
|
||||||
|
"cwd": "plugins\\pass_track",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pass_track (profile mode)",
|
||||||
|
"cwd": "plugins\\pass_track",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pass_track (release mode)",
|
||||||
|
"cwd": "plugins\\pass_track",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scence_map",
|
||||||
|
"cwd": "plugins\\scence_map",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scence_map (profile mode)",
|
||||||
|
"cwd": "plugins\\scence_map",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scence_map (release mode)",
|
||||||
|
"cwd": "plugins\\scence_map",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "example",
|
||||||
|
"cwd": "plugins\\pass_track\\example",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "example (profile mode)",
|
||||||
|
"cwd": "plugins\\pass_track\\example",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "example (release mode)",
|
||||||
|
"cwd": "plugins\\pass_track\\example",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,14 +1,26 @@
|
|||||||
import 'package:cpnav/appbar.dart';
|
import 'package:cpnav/appbar.dart';
|
||||||
|
import 'package:cpnav/pages/login/loginprefs.dart';
|
||||||
|
import 'package:cpnav/pages/pass_track/controller.dart';
|
||||||
|
import 'package:cpnav/pages/pass_track/bottomIcon/iconController.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:scence_map/controller.dart';
|
import 'package:scence_map/controller.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 'service/pile_cm.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
||||||
|
Get.put(PassTrackController('WXLMB', 'cp_road'));
|
||||||
|
Get.put(IconController());
|
||||||
|
Get.put(LoginPageController());
|
||||||
|
Get.put(AccountLoginController());
|
||||||
|
Get.put(PhoneLoginController());
|
||||||
|
LoginPrefs loginPrefs = LoginPrefs();
|
||||||
|
loginPrefs.removeToken();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,25 +33,12 @@ class MyApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
// This is the theme of your application.
|
|
||||||
//
|
|
||||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
|
||||||
// the application has a purple toolbar. Then, without quitting the app,
|
|
||||||
// try changing the seedColor in the colorScheme below to Colors.green
|
|
||||||
// and then invoke "hot reload" (save your changes or press the "hot
|
|
||||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
|
||||||
// the command line to start the app).
|
|
||||||
//
|
|
||||||
// Notice that the counter didn't reset back to zero; the application
|
|
||||||
// state is not lost during the reload. To reset the state, use hot
|
|
||||||
// restart instead.
|
|
||||||
//
|
|
||||||
// This works for code too, not just values: Most code changes can be
|
|
||||||
// tested with just a hot reload.
|
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||||
|
initialRoute: "home",
|
||||||
|
onGenerateRoute: onGenerateRoute,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,9 +67,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
final _currentIndex = 0.obs;
|
final _currentIndex = 0.obs;
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
PassTrackWidget(
|
PassTrackView(
|
||||||
date: '',
|
// date: '',
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
),
|
),
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:get_storage/get_storage.dart';
|
|
||||||
|
|
||||||
import 'package:cpnav/models/user.dart';
|
|
||||||
|
|
||||||
class LoginPrefs extends GetxController {
|
|
||||||
static const String expireStr = "expire"; //用户名
|
|
||||||
static const String tokenStr = "token"; //token
|
|
||||||
static const String phoneStr = "phone";
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
Future<String> init() async {
|
|
||||||
await GetStorage.init(); // 初始化 GetStorage
|
|
||||||
return 'ok';
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveExpire(int expire) {
|
|
||||||
box.write(expireStr, expire);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getExpire() {
|
|
||||||
return box.read(expireStr) ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveToken(String token) {
|
|
||||||
box.write(tokenStr, token);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getToken() {
|
|
||||||
return box.read(tokenStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeExpire() {
|
|
||||||
box.remove(expireStr);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeToken() {
|
|
||||||
box.remove(tokenStr);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void savePhone(String phone) {
|
|
||||||
box.write(phoneStr, phone);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPhone() {
|
|
||||||
return box.read(phoneStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearLogin() {
|
|
||||||
box.erase(); // 清除所有数据
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserController extends GetxController {
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
UserModel? getUser() {
|
|
||||||
final userMap = box.read('user');
|
|
||||||
if (userMap != null) {
|
|
||||||
return UserModel.fromJson(userMap);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUser(Map user) {
|
|
||||||
box.write('user', user);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
|
|
||||||
import 'package:cpnav/models/user.dart';
|
import 'package:cpnav/pages/login/user.dart';
|
||||||
|
|
||||||
class LoginPrefs extends GetxController {
|
class LoginPrefs extends GetxController {
|
||||||
static const String expireStr = "expire"; //用户名
|
static const String expireStr = "expire"; //用户名
|
||||||
|
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 'login_page.dart';
|
||||||
|
import 'loginprefs.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;
|
||||||
|
}
|
@ -4,49 +4,17 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:scence_map/controller.dart';
|
import 'package:scence_map/controller.dart';
|
||||||
|
|
||||||
|
import 'iconController.dart';
|
||||||
|
|
||||||
ScenceMapController mapController = Get.put(ScenceMapController());
|
ScenceMapController mapController = Get.put(ScenceMapController());
|
||||||
|
|
||||||
class IconContainer extends StatefulWidget {
|
// class IconContainer extends StatefulWidget {
|
||||||
@override
|
// @override
|
||||||
_IconContainerState createState() => _IconContainerState();
|
// _IconContainerState createState() => _IconContainerState();
|
||||||
}
|
// }
|
||||||
|
|
||||||
class _IconContainerState extends State<IconContainer> {
|
|
||||||
final Map<IconData, Color> _iconColors = {
|
|
||||||
Icons.article: Colors.green,
|
|
||||||
Icons.speed: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
Icons.thermostat: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
Icons.zoom_in: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
Icons.zoom_out: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
Icons.refresh: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
Icons.place: const Color.fromARGB(255, 166, 182, 149),
|
|
||||||
};
|
|
||||||
IconData? _selectedIcon;
|
|
||||||
|
|
||||||
void _handleTap1(IconData icon, VoidCallback onTap) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIcon = icon;
|
|
||||||
_iconColors.forEach((key, value) {
|
|
||||||
_iconColors[key] = key == icon
|
|
||||||
? Colors.green // 点击后变浅的颜色
|
|
||||||
: const Color.fromARGB(255, 166, 182, 149); // 其他图标恢复原色
|
|
||||||
});
|
|
||||||
});
|
|
||||||
onTap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleTap2(IconData icon, VoidCallback onTap) {
|
|
||||||
setState(() {
|
|
||||||
_iconColors[icon] = Colors.green; // 点击后变浅的颜色
|
|
||||||
});
|
|
||||||
onTap();
|
|
||||||
Future.delayed(Duration(milliseconds: 200), () {
|
|
||||||
setState(() {
|
|
||||||
_iconColors[icon] = const Color.fromARGB(255, 166, 182, 149); // 恢复原色
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// class _IconContainerState extends State<IconContainer> {
|
||||||
|
class IconContainer extends GetView<IconController> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
||||||
@ -62,7 +30,7 @@ class _IconContainerState extends State<IconContainer> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Color.fromARGB(255, 54, 52, 52),
|
color: const Color.fromARGB(255, 54, 52, 52),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
@ -134,7 +102,7 @@ class _IconContainerState extends State<IconContainer> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Color.fromARGB(255, 54, 52, 52),
|
color: const Color.fromARGB(255, 54, 52, 52),
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
@ -203,47 +171,51 @@ class _IconContainerState extends State<IconContainer> {
|
|||||||
|
|
||||||
//前三个单选
|
//前三个单选
|
||||||
Widget _singleChange(IconData icon, VoidCallback onTap) {
|
Widget _singleChange(IconData icon, VoidCallback onTap) {
|
||||||
return Container(
|
return Obx(() {
|
||||||
width: 33,
|
return Container(
|
||||||
height: 33,
|
width: 33,
|
||||||
margin: EdgeInsets.symmetric(vertical: 2.0),
|
height: 33,
|
||||||
decoration: BoxDecoration(
|
margin: const EdgeInsets.symmetric(vertical: 2.0),
|
||||||
color: _iconColors[icon],
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
color: controller.iconColors[icon],
|
||||||
color: Colors.white,
|
border: Border.all(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
child: InkWell(
|
||||||
),
|
child: Icon(
|
||||||
child: InkWell(
|
icon,
|
||||||
child: Icon(
|
color: Colors.white,
|
||||||
icon,
|
),
|
||||||
color: Colors.white,
|
onTap: () => controller.handleTap1(icon, onTap),
|
||||||
),
|
),
|
||||||
onTap: () => _handleTap1(icon, onTap),
|
);
|
||||||
),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//后三个自动恢复
|
//后三个自动恢复
|
||||||
Widget _automChange(IconData icon, VoidCallback onTap) {
|
Widget _automChange(IconData icon, VoidCallback onTap) {
|
||||||
return Container(
|
return Obx(() {
|
||||||
width: 33,
|
return Container(
|
||||||
height: 33,
|
width: 33,
|
||||||
margin: EdgeInsets.symmetric(vertical: 2.0),
|
height: 33,
|
||||||
decoration: BoxDecoration(
|
margin: const EdgeInsets.symmetric(vertical: 2.0),
|
||||||
color: _iconColors[icon],
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
color: controller.iconColors[icon],
|
||||||
color: Colors.white,
|
border: Border.all(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
child: InkWell(
|
||||||
),
|
child: Icon(
|
||||||
child: InkWell(
|
icon,
|
||||||
child: Icon(
|
color: Colors.white,
|
||||||
icon,
|
),
|
||||||
color: Colors.white,
|
onTap: () => controller.handleTap2(icon, onTap),
|
||||||
),
|
),
|
||||||
onTap: () => _handleTap2(icon, onTap),
|
);
|
||||||
),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
41
lib/pages/pass_track/bottomIcon/iconController.dart
Normal file
41
lib/pages/pass_track/bottomIcon/iconController.dart
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
class IconController extends GetxController {
|
||||||
|
final RxMap<IconData, Color> iconColors = {
|
||||||
|
Icons.article: Colors.green,
|
||||||
|
Icons.speed: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
Icons.thermostat: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
Icons.zoom_in: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
Icons.zoom_out: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
Icons.refresh: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
Icons.place: const Color.fromARGB(255, 166, 182, 149),
|
||||||
|
}.obs;
|
||||||
|
// IconData? _selectedIcon;
|
||||||
|
late IconData selectedIcon;
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
handleTap1(Icons.close, () {}); // 初始时,默认第一个图标为选中状态,并触发onTap事件(空函数, onTap)
|
||||||
|
handleTap2(Icons.close, () {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleTap1(IconData icon, VoidCallback onTap) {
|
||||||
|
selectedIcon = icon;
|
||||||
|
iconColors.forEach((key, value) {
|
||||||
|
iconColors[key] = key == icon
|
||||||
|
? Colors.green // 点击后变浅的颜色
|
||||||
|
: const Color.fromARGB(255, 166, 182, 149); // 其他图标恢复原色
|
||||||
|
});
|
||||||
|
onTap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleTap2(IconData icon, VoidCallback onTap) {
|
||||||
|
iconColors[icon] = Colors.green; // 点击后变浅的颜色
|
||||||
|
|
||||||
|
onTap();
|
||||||
|
Future.delayed(Duration(milliseconds: 200), () {
|
||||||
|
iconColors[icon] = const Color.fromARGB(255, 166, 182, 149); // 恢复原色
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,30 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
import "dart:ffi" as ffi;
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:scence_map/controller.dart';
|
import 'package:scence_map/controller.dart';
|
||||||
import 'package:cpnav/service/base.dart';
|
import 'package:cpnav/service/base.dart';
|
||||||
import 'package:pass_track/pass_track.dart';
|
import 'package:pass_track/pass_track.dart';
|
||||||
import 'sevice/file_handle.dart';
|
import 'sevice/file_handle.dart';
|
||||||
|
|
||||||
|
|
||||||
FileHandle fileHandle = FileHandle();
|
FileHandle fileHandle = FileHandle();
|
||||||
|
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||||||
|
|
||||||
class PassTrackController extends GetxController {
|
class PassTrackController extends GetxController {
|
||||||
int allLen = 0;
|
var tileCount = 0.obs;
|
||||||
|
var tileFirst = 0.obs;
|
||||||
|
var tileLast = 0.obs;
|
||||||
final mapController = Get.put(ScenceMapController());
|
final mapController = Get.put(ScenceMapController());
|
||||||
|
|
||||||
String projCode;
|
String projCode;
|
||||||
String projType;
|
String projType;
|
||||||
|
var speed = 1.obs;
|
||||||
late final GetServices service;
|
late final GetServices service;
|
||||||
// final PassTrack _passTrackPlugin;
|
|
||||||
PassTrackController(this.projCode, this.projType);
|
PassTrackController(this.projCode, this.projType);
|
||||||
Map<String, int> deviceMap = {};
|
Map<String, int> deviceMap = {};
|
||||||
Map<String, int> coorTransMap = {};
|
Map<String, int> coorTransMap = {};
|
||||||
|
// final PassTrack _passTrackPlugin;
|
||||||
|
final PassTrack _passTrackPlugin = PassTrack();
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@ -29,6 +33,72 @@ class PassTrackController extends GetxController {
|
|||||||
// loadSideLine();
|
// loadSideLine();
|
||||||
loadBindDevice();
|
loadBindDevice();
|
||||||
// getHisFileList();
|
// getHisFileList();
|
||||||
|
var future = getHisFileList(_passTrackPlugin);
|
||||||
|
|
||||||
|
// var maxLen =
|
||||||
|
// controller.allLen > 0 ? controller.allLen : 1.0; // 确保 maxLen 大于 0
|
||||||
|
// _rangevalues = SfRangeValues(0.0, maxLen);
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
var f = initPlatformState();
|
||||||
|
|
||||||
|
f.then((void _) {
|
||||||
|
_passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
|
||||||
|
_passTrackPlugin.drawGrid();
|
||||||
|
|
||||||
|
future.then((value) {
|
||||||
|
_passTrackPlugin.setScale(1);
|
||||||
|
for (var TID in deviceMap.keys) {
|
||||||
|
_passTrackPlugin.addDevice(int.parse(TID), 0);
|
||||||
|
}
|
||||||
|
for (var item in coorTransMap.entries) {
|
||||||
|
print("tid:${item.key} value:${item.value}");
|
||||||
|
}
|
||||||
|
// 统计用时 获取当前时间
|
||||||
|
var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
// _passTrackPlugin.generateTile(0, value);
|
||||||
|
_passTrackPlugin.waitForTile(() {
|
||||||
|
var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
print("len: ${_passTrackPlugin.allTileCnt()}");
|
||||||
|
tileCount.value = _passTrackPlugin.allTileCnt();
|
||||||
|
// _rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
|
||||||
|
_passTrackPlugin.playTrack(
|
||||||
|
0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
|
||||||
|
var end = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
print("play: ${end - start}");
|
||||||
|
});
|
||||||
|
// _passTrackPlugin.drawGrid();
|
||||||
|
// 获取当前时间
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBindDevice() async {
|
loadBindDevice() async {
|
||||||
@ -90,12 +160,34 @@ class PassTrackController extends GetxController {
|
|||||||
var jsData = await GetServices().getHisFil1(file);
|
var jsData = await GetServices().getHisFil1(file);
|
||||||
print("have message");
|
print("have message");
|
||||||
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
|
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
|
||||||
allLen += len;
|
tileCount.value += len;
|
||||||
if (allLen >= 20000) {
|
if (tileCount.value >= 20000) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
coorTransMap = fileHandle.pointsMap;
|
coorTransMap = fileHandle.pointsMap;
|
||||||
return allLen;
|
return tileCount.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initPlatformState() async {
|
||||||
|
String platformVersion;
|
||||||
|
try {
|
||||||
|
platformVersion = await _passTrackPlugin.getPlatformVersion() ??
|
||||||
|
'Unknown platform version';
|
||||||
|
} on Exception {
|
||||||
|
platformVersion = 'Failed to get platform version.';
|
||||||
|
}
|
||||||
|
await _passTrackPlugin.create(
|
||||||
|
mapcontroller.height.toInt(), mapcontroller.width.toInt());
|
||||||
|
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
|
||||||
|
print("textureId: ${fileHandle.textureId}");
|
||||||
|
print("${mapcontroller.height.toInt()}");
|
||||||
|
|
||||||
|
// if (!mounted) Exception('Failed to get textureId.');
|
||||||
|
|
||||||
|
// setState(() {
|
||||||
|
// platformVersion = platformVersion;
|
||||||
|
// });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,13 @@ import 'package:scence_map/controller.dart';
|
|||||||
import 'package:scence_map/scence_map.dart';
|
import 'package:scence_map/scence_map.dart';
|
||||||
|
|
||||||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||||||
import 'iconContainer.dart';
|
import 'bottomIcon/iconContainer.dart';
|
||||||
import "controller.dart";
|
import "controller.dart";
|
||||||
import "package:pass_track/pass_track.dart";
|
import "package:pass_track/pass_track.dart";
|
||||||
import "package:pass_track/pass_track_platform_interface.dart";
|
import "package:pass_track/pass_track_platform_interface.dart";
|
||||||
import "controller.dart";
|
import "controller.dart";
|
||||||
import "dart:ffi" as ffi;
|
import "dart:ffi" as ffi;
|
||||||
|
|
||||||
// import '../login_in/connect/bluetooth_page.dart';
|
// import '../login_in/connect/bluetooth_page.dart';
|
||||||
// import '../login_in/connect/config.dart';
|
// import '../login_in/connect/config.dart';
|
||||||
// import '../login_in/connect/connect_type.dart';
|
// import '../login_in/connect/connect_type.dart';
|
||||||
@ -26,132 +27,126 @@ import "dart:ffi" as ffi;
|
|||||||
|
|
||||||
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||||||
|
|
||||||
class PassTrackWidget extends StatefulWidget {
|
class PassTrackView extends GetView<PassTrackController> {
|
||||||
final String date;
|
|
||||||
final controller;
|
|
||||||
|
|
||||||
const PassTrackWidget({super.key, required this.date, this.controller});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<PassTrackWidget> createState() => _PasstrackState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PasstrackState extends State<PassTrackWidget> {
|
|
||||||
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
|
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
|
||||||
GlobalKey<PopupMenuButtonState<int>>();
|
GlobalKey<PopupMenuButtonState<int>>();
|
||||||
final controller = Get.put(PassTrackController("WXLMB", "cp_road"));
|
// final controller = Get.put(PassTrackController("WXLMB", "cp_road"));
|
||||||
String str = "播放";
|
final String str = "播放";
|
||||||
int sWidth = 800;
|
// int sWidth = 800;
|
||||||
int sHeight = 800;
|
// int sHeight = 800;
|
||||||
int bits = -1;
|
// int bits = -1;
|
||||||
int speed = 50;
|
// int speed = 50;
|
||||||
List<int> speedList = [1, 2, 10, 20, 50, 100, 200, 500];
|
|
||||||
// int maxLength = 200;
|
// int maxLength = 200;
|
||||||
late SfRangeValues _rangevalues;
|
// late SfRangeValues _rangevalues;
|
||||||
final PassTrack _passTrackPlugin = PassTrack();
|
final PassTrack _passTrackPlugin = PassTrack();
|
||||||
|
|
||||||
@override
|
PassTrackView({Key? key}) : super(key: key);
|
||||||
initState() {
|
|
||||||
super.initState();
|
|
||||||
var maxLen =
|
|
||||||
controller.allLen > 0 ? controller.allLen : 1.0; // 确保 maxLen 大于 0
|
|
||||||
_rangevalues = SfRangeValues(0.0, maxLen);
|
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
|
|
||||||
// .ceil();
|
|
||||||
|
|
||||||
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
|
// @override
|
||||||
// fileHandle.date = widget.date;
|
// initState() {
|
||||||
// await fileHandle.init();
|
// super.initState();
|
||||||
// //在帧绘制完成后执行数据渲染
|
// var maxLen =
|
||||||
// // await initPlatformState();
|
// controller.allLen > 0 ? controller.allLen : 1.0; // 确保 maxLen 大于 0
|
||||||
// if (fileHandle.pointData.isNotEmpty) {
|
// _rangevalues = SfRangeValues(0.0, maxLen);
|
||||||
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
|
// SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||||
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
|
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
|
||||||
// }
|
// .ceil();
|
||||||
|
|
||||||
// for (var item in fileHandle.deviceList) {
|
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
|
||||||
// if (item["point"] != null) {
|
// fileHandle.date = widget.date;
|
||||||
// bits = item["bits"];
|
// await fileHandle.init();
|
||||||
// break;
|
// //在帧绘制完成后执行数据渲染
|
||||||
// }
|
// // await initPlatformState();
|
||||||
// }
|
// if (fileHandle.pointData.isNotEmpty) {
|
||||||
// // passTrackPlugin.map_setCenterDevice(bits);
|
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
|
||||||
// setState(() {
|
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
|
||||||
// if (fileHandle.pointData.isNotEmpty) {
|
// }
|
||||||
// maxLength = fileHandle.pointData.length;
|
|
||||||
// // _value = maxLength;
|
|
||||||
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
var f = initPlatformState();
|
|
||||||
var future = controller.getHisFileList(_passTrackPlugin);
|
|
||||||
f.then((void _) {
|
|
||||||
_passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
|
|
||||||
_passTrackPlugin.drawGrid();
|
|
||||||
|
|
||||||
future.then((value) {
|
// for (var item in fileHandle.deviceList) {
|
||||||
_passTrackPlugin.setScale(1);
|
// if (item["point"] != null) {
|
||||||
for (var TID in controller.deviceMap.keys) {
|
// bits = item["bits"];
|
||||||
_passTrackPlugin.addDevice(int.parse(TID), 0);
|
// break;
|
||||||
}
|
// }
|
||||||
for (var item in controller.coorTransMap.entries) {
|
// }
|
||||||
print("tid:${item.key} value:${item.value}");
|
// // passTrackPlugin.map_setCenterDevice(bits);
|
||||||
}
|
// setState(() {
|
||||||
// 统计用时 获取当前时间
|
// if (fileHandle.pointData.isNotEmpty) {
|
||||||
var start = DateTime.now().millisecondsSinceEpoch;
|
// maxLength = fileHandle.pointData.length;
|
||||||
// _passTrackPlugin.generateTile(0, value);
|
// // _value = maxLength;
|
||||||
_passTrackPlugin.waitForTile(() {
|
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
|
||||||
var start = DateTime.now().millisecondsSinceEpoch;
|
// }
|
||||||
print("len: ${_passTrackPlugin.allTileCnt()}");
|
// });
|
||||||
controller.allLen = _passTrackPlugin.allTileCnt();
|
// });
|
||||||
_rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
|
// var f = initPlatformState();
|
||||||
_passTrackPlugin.playTrack(0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
|
// var future = controller.getHisFileList(_passTrackPlugin);
|
||||||
var end = DateTime.now().millisecondsSinceEpoch;
|
// f.then((void _) {
|
||||||
print("play: ${end - start}");
|
// _passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
|
||||||
});
|
// _passTrackPlugin.drawGrid();
|
||||||
// _passTrackPlugin.drawGrid();
|
|
||||||
// 获取当前时间
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> initPlatformState() async {
|
// future.then((value) {
|
||||||
String platformVersion;
|
// _passTrackPlugin.setScale(1);
|
||||||
try {
|
// for (var TID in controller.deviceMap.keys) {
|
||||||
platformVersion = await _passTrackPlugin.getPlatformVersion() ??
|
// _passTrackPlugin.addDevice(int.parse(TID), 0);
|
||||||
'Unknown platform version';
|
// }
|
||||||
} on Exception {
|
// for (var item in controller.coorTransMap.entries) {
|
||||||
platformVersion = 'Failed to get platform version.';
|
// print("tid:${item.key} value:${item.value}");
|
||||||
}
|
// }
|
||||||
await _passTrackPlugin.create(sWidth, sWidth);
|
// // 统计用时 获取当前时间
|
||||||
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
|
// var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
print("textureId: ${fileHandle.textureId}");
|
// // _passTrackPlugin.generateTile(0, value);
|
||||||
|
// _passTrackPlugin.waitForTile(() {
|
||||||
|
// var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
// print("len: ${_passTrackPlugin.allTileCnt()}");
|
||||||
|
// _rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
|
||||||
|
// _passTrackPlugin.playTrack(
|
||||||
|
// 0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
|
||||||
|
// var end = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
// print("play: ${end - start}");
|
||||||
|
// });
|
||||||
|
// // _passTrackPlugin.drawGrid();
|
||||||
|
// // 获取当前时间
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
if (!mounted) Exception('Failed to get textureId.');
|
// Future<void> initPlatformState() async {
|
||||||
|
// String platformVersion;
|
||||||
|
// try {
|
||||||
|
// platformVersion = await _passTrackPlugin.getPlatformVersion() ??
|
||||||
|
// 'Unknown platform version';
|
||||||
|
// } on Exception {
|
||||||
|
// platformVersion = 'Failed to get platform version.';
|
||||||
|
// }
|
||||||
|
// await _passTrackPlugin.create(
|
||||||
|
// mapcontroller.height.toInt(), mapcontroller.width.toInt());
|
||||||
|
// fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
|
||||||
|
// print("textureId: ${fileHandle.textureId}");
|
||||||
|
|
||||||
setState(() {
|
// if (!mounted) Exception('Failed to get textureId.');
|
||||||
platformVersion = platformVersion;
|
|
||||||
});
|
// setState(() {
|
||||||
return;
|
// platformVersion = platformVersion;
|
||||||
}
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
||||||
|
var controller = this.controller;
|
||||||
return OrientationBuilder(builder: (context, orientation) {
|
return OrientationBuilder(builder: (context, orientation) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
ScenceMapView(
|
ScenceMapView(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 0,
|
top: mapcontroller.top,
|
||||||
left: 0,
|
left: mapcontroller.left,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: sWidth * 1.0,
|
width: mapcontroller.width,
|
||||||
height: sWidth * 1.0,
|
height: mapcontroller.height,
|
||||||
// child: Text('Running on: $_platformVersion\n'),
|
// child: Text('Running on: $_platformVersion\n'),
|
||||||
child: Texture(textureId: fileHandle.textureId))),
|
child: Texture(textureId: fileHandle.textureId))),
|
||||||
],
|
],
|
||||||
@ -165,25 +160,25 @@ class _PasstrackState extends State<PassTrackWidget> {
|
|||||||
bottom: 30,
|
bottom: 30,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(bottom: 5),
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
child: SfRangeSlider(
|
child: Obx(
|
||||||
min: 0.0,
|
() => SfRangeSlider(
|
||||||
// max: maxLength,
|
min: 0.0,
|
||||||
max:
|
// max: maxLength,
|
||||||
controller.allLen > 0
|
max: controller.tileCount.value > 0
|
||||||
? controller.allLen
|
? controller.tileCount.value
|
||||||
: 1.0, // 确保 max 大于 0
|
: 1.0, // 确保 max 大于 0
|
||||||
values: _rangevalues,
|
values: SfRangeValues(
|
||||||
showTicks: false,
|
controller.tileFirst.value, controller.tileLast.value),
|
||||||
showLabels: false,
|
showTicks: false,
|
||||||
enableTooltip: true,
|
showLabels: false,
|
||||||
minorTicksPerInterval: 1,
|
enableTooltip: true,
|
||||||
stepSize: 1,
|
minorTicksPerInterval: 1,
|
||||||
onChanged: (SfRangeValues values) {
|
stepSize: 1,
|
||||||
setState(() {
|
onChanged: (SfRangeValues values) {
|
||||||
_rangevalues = SfRangeValues(values.start.roundToDouble(),
|
controller.tileFirst.value = values.start.toInt();
|
||||||
values.end.roundToDouble());
|
controller.tileLast.value = values.end.toInt();
|
||||||
});
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -197,20 +192,20 @@ class _PasstrackState extends State<PassTrackWidget> {
|
|||||||
width: 74,
|
width: 74,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all<Color?>(
|
backgroundColor: WidgetStateProperty.all<Color?>(
|
||||||
str == "播放" ? Colors.blue : Colors.red,
|
str == "播放" ? Colors.blue : Colors.red,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (str == "播放") {
|
if (str == "播放") {
|
||||||
_passTrackPlugin.playTrack(0, 10000, true, 50, ffi.nullptr);
|
_passTrackPlugin.playTrack(
|
||||||
|
0, 10000, true, 50, ffi.nullptr);
|
||||||
} else {
|
} else {
|
||||||
_passTrackPlugin.playPause();
|
_passTrackPlugin.playPause();
|
||||||
}
|
}
|
||||||
setState(() {
|
// setState(() {
|
||||||
str = str == "播放" ? "暂停" : "播放";
|
// str = str == "播放" ? "暂停" : "播放";
|
||||||
});
|
// });
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
str,
|
str,
|
||||||
@ -236,12 +231,14 @@ class _PasstrackState extends State<PassTrackWidget> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Obx(
|
||||||
"$speed X",
|
() => Text(
|
||||||
style: const TextStyle(
|
"${controller.speed.value} X",
|
||||||
fontSize: 11, color: Colors.black),
|
style: const TextStyle(
|
||||||
|
fontSize: 11, color: Colors.black),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Container(
|
SizedBox(
|
||||||
width: 25,
|
width: 25,
|
||||||
child: PopupMenuButton<int>(
|
child: PopupMenuButton<int>(
|
||||||
key: _popupMenuKey,
|
key: _popupMenuKey,
|
||||||
@ -249,9 +246,7 @@ class _PasstrackState extends State<PassTrackWidget> {
|
|||||||
icon: const Icon(Icons.arrow_drop_up,
|
icon: const Icon(Icons.arrow_drop_up,
|
||||||
color: Color.fromARGB(255, 47, 48, 47)),
|
color: Color.fromARGB(255, 47, 48, 47)),
|
||||||
onSelected: (int value) {
|
onSelected: (int value) {
|
||||||
setState(() {
|
controller.speed.value = value;
|
||||||
speed = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// style: ButtonStyle(
|
// style: ButtonStyle(
|
||||||
// minimumSize: MaterialStateProperty.all<Size>(
|
// minimumSize: MaterialStateProperty.all<Size>(
|
||||||
@ -264,7 +259,8 @@ class _PasstrackState extends State<PassTrackWidget> {
|
|||||||
return PopupMenuItem<int>(
|
return PopupMenuItem<int>(
|
||||||
height: 30,
|
height: 30,
|
||||||
value: speed,
|
value: speed,
|
||||||
child: Text("$speed X速度"),
|
child: Obx(() =>
|
||||||
|
Text("${controller.speed.value} X速度")),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,8 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'loginprefs.dart';
|
|
||||||
|
import '../pages/login/loginprefs.dart';
|
||||||
|
|
||||||
LoginPrefs loginPrefs = LoginPrefs();
|
LoginPrefs loginPrefs = LoginPrefs();
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ class BaseService {
|
|||||||
//创建client实例
|
//创建client实例
|
||||||
final _client = http.Client();
|
final _client = http.Client();
|
||||||
final String token =
|
final String token =
|
||||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1IiOjAsInJvbGVJZHMiOlsiODMiXSwidXNlcm5hbWUiOiJseWNzIiwidXNlcklkIjozNTYsIlBWIjoyLCJvcmciOiJhIiwiaWF0IjoxNzI1NTI2MDc0LCJleHAiOjE3MjY4MjIwNzR9.l47sd4L8OswBcHJxamGe9M5ttWqiukoJvE5QfwPARlw";
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1IiOjAsInJvbGVJZHMiOlsiODMiXSwidXNlcm5hbWUiOiJseWNzIiwidXNlcklkIjozNTYsIlBWIjoyLCJvcmciOiJhIiwiaWF0IjoxNzI1OTQ5NDUxLCJleHAiOjE3MjcyNDU0NTF9.o3cwloJcWAPclGXMzlmjIMM2x5GhBseToJe99vM4uVA";
|
||||||
|
|
||||||
// String baseUrl = "http://192.168.1.189:8001";//本地
|
// String baseUrl = "http://192.168.1.189:8001";//本地
|
||||||
String baseUrl = "http://1.82.251.83:8001"; //线上
|
String baseUrl = "http://1.82.251.83:8001"; //线上
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
import 'package:get_storage/get_storage.dart';
|
|
||||||
|
|
||||||
import 'package:cpnav/models/user.dart';
|
|
||||||
|
|
||||||
class LoginPrefs {
|
|
||||||
static const String expireStr = "expire"; //用户名
|
|
||||||
static const String tokenStr = "token"; //token
|
|
||||||
static const String phoneStr = "phone";
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
Future<String> init() async {
|
|
||||||
await GetStorage.init(); // 初始化 GetStorage
|
|
||||||
return 'ok';
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveExpire(int expire) {
|
|
||||||
box.write(expireStr, expire);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getExpire() {
|
|
||||||
return box.read(expireStr) ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveToken(String token) {
|
|
||||||
box.write(tokenStr, token);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getToken() {
|
|
||||||
return box.read(tokenStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeExpire() {
|
|
||||||
box.remove(expireStr);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeToken() {
|
|
||||||
box.remove(tokenStr);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void savePhone(String phone) {
|
|
||||||
box.write(phoneStr, phone);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPhone() {
|
|
||||||
return box.read(phoneStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearLogin() {
|
|
||||||
box.erase(); // 清除所有数据
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserController {
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
UserModel? getUser() {
|
|
||||||
final userMap = box.read('user');
|
|
||||||
if (userMap != null) {
|
|
||||||
return UserModel.fromJson(userMap);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUser(Map user) {
|
|
||||||
box.write('user', user);
|
|
||||||
// update();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:get_storage/get_storage.dart';
|
|
||||||
|
|
||||||
import 'package:cpnav/models/user.dart';
|
|
||||||
|
|
||||||
class LoginPrefs extends GetxController {
|
|
||||||
static const String expireStr = "expire"; //用户名
|
|
||||||
static const String tokenStr = "token"; //token
|
|
||||||
static const String phoneStr = "phone";
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
Future<String> init() async {
|
|
||||||
await GetStorage.init(); // 初始化 GetStorage
|
|
||||||
return 'ok';
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveExpire(int expire) {
|
|
||||||
box.write(expireStr, expire);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getExpire() {
|
|
||||||
return box.read(expireStr) ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveToken(String token) {
|
|
||||||
box.write(tokenStr, token);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getToken() {
|
|
||||||
return box.read(tokenStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeExpire() {
|
|
||||||
box.remove(expireStr);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeToken() {
|
|
||||||
box.remove(tokenStr);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void savePhone(String phone) {
|
|
||||||
box.write(phoneStr, phone);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPhone() {
|
|
||||||
return box.read(phoneStr) ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearLogin() {
|
|
||||||
box.erase(); // 清除所有数据
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserController extends GetxController {
|
|
||||||
final box = GetStorage(); // 实例化 GetStorage
|
|
||||||
|
|
||||||
UserModel? getUser() {
|
|
||||||
final userMap = box.read('user');
|
|
||||||
if (userMap != null) {
|
|
||||||
return UserModel.fromJson(userMap);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUser(Map user) {
|
|
||||||
box.write('user', user);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +1 @@
|
|||||||
Subproject commit 0b6aef315a6b7b05eec413cc6e9368611fad8e2b
|
Subproject commit ad96316e993e3bbb2ca2b5b360b2fb5b6a50f0d2
|
@ -1 +1 @@
|
|||||||
Subproject commit ac2179219ba52d0c91dfd51470fd1d7ebaae69be
|
Subproject commit aa1ed2754229ed2bc2aaccfaba074765a55adfd8
|
Loading…
Reference in New Issue
Block a user