放大镜

This commit is contained in:
tanlinxing 2024-08-30 17:57:33 +08:00
parent a139836df5
commit b53abd5705
13 changed files with 863 additions and 335 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,25 +1,26 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import 'main.dart';
import 'pages/aim_point/aimPointer.dart';
// import '../login_in/connect/bluetooth_page.dart';
// import '../login_in/connect/connect_type.dart';
// import '../login_in/getx/real_data.dart';
// import 'main.dart';
import 'pages/real/realController.dart';
final SightController sightcontroller = Get.find();
final RealController realcontroller = Get.find();
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
final double appBarHeight;
final RxInt _currentIndex;
final isDarkMode = false.obs;
final isCardVisible = false.obs;
final isDataVisible = false.obs;
CustomAppBar({required this.appBarHeight, required RxInt currentIndex})
: _currentIndex = currentIndex;
CustomAppBar({
required this.appBarHeight,
required RxInt currentIndex,
}) : _currentIndex = currentIndex;
@override
Widget build(BuildContext context) {
@ -55,30 +56,34 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
// }),
actions: [
InkWell(
onTap: () {
MyHomePage.isDarkMode.value = !MyHomePage.isDarkMode.value;
},
child: Icon(
MyHomePage.isDarkMode.value ? Icons.dark_mode : Icons.sunny,
size: 35,
Obx(
() => InkWell(
onTap: () {
appcontroller.isDarkMode.value = !appcontroller.isDarkMode.value;
},
child: Icon(
appcontroller.isDarkMode.value ? Icons.dark_mode : Icons.sunny,
size: 35,
),
),
),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => const ScenceMap())),
},
child: Image(
image: const AssetImage('images/satellite.png'),
// width: 40,
color: MyHomePage.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
height: 40,
Obx(
() => InkWell(
onTap: () {
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => const ScenceMap())),
},
child: Image(
image: const AssetImage('images/satellite.png'),
// width: 40,
color: appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
height: 40,
),
),
),
const SizedBox(
@ -93,6 +98,10 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
//
sightcontroller.isCardVisible.value =
!sightcontroller.isCardVisible.value; //
sightcontroller.lastManualTapTime =
DateTime.now().millisecondsSinceEpoch;
},
child: Icon(
Icons.my_location_sharp,
@ -100,7 +109,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
color: sightcontroller.isCardVisible.value
? Colors.blue
// : const Color.fromARGB(200, 29, 28, 28),
: (MyHomePage.isDarkMode.value
: (appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28)),
), //
@ -112,16 +121,15 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
Obx(
() => InkWell(
onTap: () {
// final RealController controller1 = Get.find(); //
// controller1.isDataVisible.value =
// !controller1.isDataVisible.value; //
realcontroller.isDataVisible.value =
!realcontroller.isDataVisible.value; //
},
child: Icon(
Icons.date_range_rounded,
size: 35,
color: isDataVisible.value
? Colors.blue
: (MyHomePage.isDarkMode.value
: (appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28)),
), //
@ -138,7 +146,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
child: Icon(
Icons.settings_outlined,
size: 35,
color: MyHomePage.isDarkMode.value
color: appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
),

View File

@ -0,0 +1,5 @@
import 'package:get/get.dart';
class AppController extends GetxController {
final RxBool isDarkMode = false.obs;
}

View File

@ -5,6 +5,7 @@ import 'package:cpnav/pages/pass_track/controller.dart';
import 'package:get/get.dart';
import 'package:gnss/gnss.dart';
import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/record_entity.dart';
import '../models/pilePoint/coord_trans.dart';
import '../pages/aim_point/aimPointer.dart';
@ -24,8 +25,18 @@ class GnssController extends GetxController {
var auxdrilldistance = 2.0.obs; //线
var offsetangle = 0.0.obs; //线
late final CoordTrans coordTrans;
RecordEntity? lastPilePoint;
var _dx = 0.0;
var _dy = 0.0;
Timer? timer;
checkDistance() {
if (DateTime.now().millisecondsSinceEpoch - sight.lastManualTapTime <
10000 ||
DateTime.now().millisecondsSinceEpoch - sight.lastCloseTapTime <
10000) {
return;
}
Offset pilerCenterPoint = Offset(device.x, device.y);
if (sight.selectedPilePoint == null) {
return;
@ -75,6 +86,24 @@ class GnssController extends GetxController {
//
timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
// if (lastPilePoint != sight.selectedPilePoint) {
// lastPilePoint = sight.selectedPilePoint;
// if (sight.selectedPilePoint != null) {
// var dx = device.x - sight.selectedPilePoint!.x;
// var dy = device.y - sight.selectedPilePoint!.y;
// var distance = sqrt(dx * dx + dy * dy);
// if (distance > 20) {
// dx = (sight.selectedPilePoint!.x - device.x) / (distance / 20);
// dy = (sight.selectedPilePoint!.y - device.y) / (distance / 20);
// device.x = sight.selectedPilePoint!.x + dx;
// device.y = sight.selectedPilePoint!.y + dy;
// }
// _dx = -dx / 50;
// _dy = -dy / 50;
// }
// }
// device.x += _dx;
// device.y += _dy;
device.x += 0.2;
device.y += 0.2;
device.rotation = device.rotation + pi / 180; // 0-360

View File

@ -1,4 +1,6 @@
import 'package:cpnav/controllers/appcontroller.dart';
import 'package:cpnav/controllers/gnss_Controller.dart';
import 'package:cpnav/pages/setting/child_pages/antenna/antenna_setting.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
@ -11,39 +13,48 @@ import 'pages/pass_track/view.dart';
import 'pages/pile/pileNav/view.dart';
import 'pages/pile/rightDra/pileGenerate.dart';
import 'pages/real/index.dart';
import 'pages/setting/child_pages/XyChange/connect.dart';
import 'pages/setting/setting_page.dart';
import 'service/user/loginprefs.dart';
void main() {
final AppController appcontroller = Get.put(AppController());
Connect connect = Connect();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //
Get.put(ScenceMapController());
Get.put(PlumDataController());
Get.put(SightController());
Get.put(GnssController());
runApp(const MyApp());
Get.put(AntennaController());
LoginPrefs loginPrefs = LoginPrefs();
String value =
await loginPrefs.init(); // await await等待异步方法执行完毕
if ('ok' == value) {
connect.init();
runApp(const MyApp());
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ValueListenableBuilder<bool>(
valueListenable: MyHomePage.isDarkMode,
builder: (context, isDarkMode, child) {
return MaterialApp(
title: 'Flutter Demo',
theme: isDarkMode ? ThemeData.dark() : ThemeData.light(),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
},
);
return Obx(() {
return MaterialApp(
title: 'Flutter Demo',
theme: appcontroller.isDarkMode.value
? ThemeData.dark()
: ThemeData.light(),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
});
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
static ValueNotifier<bool> isDarkMode = ValueNotifier<bool>(false);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
@ -51,7 +62,6 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
late bool isPortrait;
late double appBarHeight = 34.0;
final _currentIndex = 0.obs;
final List<Widget> _pages = [
Real(),
@ -67,250 +77,248 @@ class _MyHomePageState extends State<MyHomePage> {
final size = MediaQuery.of(context).size;
return Scaffold(
resizeToAvoidBottomInset: false,
drawerEdgeDragWidth: 0.0, // drawer
endDrawer: _currentIndex.value == 1
? Drawer(
width: size.width * .8,
child: const PileGenerate(),
)
: null,
appBar: PreferredSize(
preferredSize: Size.fromHeight(appBarHeight),
child: CustomAppBar(appBarHeight: 56, currentIndex: _currentIndex),
resizeToAvoidBottomInset: false,
drawerEdgeDragWidth: 0.0, // drawer
endDrawer: _currentIndex.value == 1
? Drawer(
width: size.width * .8,
child: const PileGenerate(),
)
: null,
appBar: PreferredSize(
preferredSize: Size.fromHeight(appBarHeight),
child: CustomAppBar(
appBarHeight: 56,
currentIndex: _currentIndex,
),
body: OrientationBuilder(
builder: (context, orientation) {
// final size = MediaQuery.of(context).size;
appBarHeight = Orientation.portrait == orientation ? 56.0 : 34.0;
isPortrait = Orientation.portrait == orientation ? true : false;
appBarHeight = Orientation.portrait == orientation ? 56.0 : 34.0;
if (!isPortrait) {
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: _pages[_currentIndex.value],
),
body: OrientationBuilder(
builder: (context, orientation) {
// final size = MediaQuery.of(context).size;
appBarHeight = Orientation.portrait == orientation ? 56.0 : 34.0;
isPortrait = Orientation.portrait == orientation ? true : false;
appBarHeight = Orientation.portrait == orientation ? 56.0 : 34.0;
if (!isPortrait) {
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: _pages[_currentIndex.value],
),
const VerticalDivider(
width: 1, // 1
thickness: 1,
),
SizedBox(
width: 48,
child: SafeArea(
child: LayoutBuilder(builder: (context, constraints) {
//
// if (!isPortrait) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 0;
});
},
icon: const Icon(Icons.date_range_rounded),
color: _currentIndex.value == 0
? const Color.fromARGB(255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'实时',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 0
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(
height: 1, // 1
thickness: 1,
),
//
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 1;
});
},
icon: const Icon(Icons.map_outlined),
color: _currentIndex.value == 1
? const Color.fromARGB(255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'桩点',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 1
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 2;
});
},
icon: const Icon(Icons.my_location_sharp),
color: _currentIndex.value == 2
? const Color.fromARGB(255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'任务',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 2
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 3;
});
},
icon:
const Icon(Icons.table_chart_outlined),
color: _currentIndex.value == 3
? const Color.fromARGB(255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'历史',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 3
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 4;
});
},
icon: const Icon(Icons.settings),
color: _currentIndex.value == 4
? const Color.fromARGB(255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'设置',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 4
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
)
]);
//
}),
),
const VerticalDivider(
width: 1, // 1
thickness: 1,
),
SizedBox(
width: 48,
child: SafeArea(
child: LayoutBuilder(builder: (context, constraints) {
//
// if (!isPortrait) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 0;
});
},
icon:
const Icon(Icons.date_range_rounded),
color: _currentIndex.value == 0
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'实时',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 0
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(
height: 1, // 1
thickness: 1,
),
//
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 1;
});
},
icon: const Icon(Icons.map_outlined),
color: _currentIndex.value == 1
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'桩点',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 1
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 2;
});
},
icon: const Icon(Icons.my_location_sharp),
color: _currentIndex.value == 2
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'任务',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 2
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 3;
});
},
icon: const Icon(
Icons.table_chart_outlined),
color: _currentIndex.value == 3
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'历史',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 3
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
),
const Divider(),
Column(
children: [
IconButton(
onPressed: () {
setState(() {
_currentIndex.value = 4;
});
},
icon: const Icon(Icons.settings),
color: _currentIndex.value == 4
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
Align(
alignment: Alignment.center,
child: Text(
'设置',
style: TextStyle(
fontSize: 12,
color: _currentIndex.value == 4
? const Color.fromARGB(
255, 60, 95, 123)
: Colors.grey,
),
),
),
],
)
]);
//
}),
),
)
]);
} //
)
]);
} //
else {
//
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
flex: 12,
child: _pages[_currentIndex.value],
else {
//
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
flex: 12,
child: _pages[_currentIndex.value],
),
// VerticalDivider(),
Expanded(
flex: 1,
child: SizedBox(
height: 48,
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex.value,
onTap: (index) {
setState(() {
_currentIndex.value = index;
});
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.date_range_rounded),
label: "实时"),
BottomNavigationBarItem(
icon: Icon(Icons.map_outlined), label: "计划"),
BottomNavigationBarItem(
icon: Icon(Icons.my_location_sharp),
label: "对点"),
BottomNavigationBarItem(
icon: Icon(Icons.table_chart_outlined),
label: "历史"),
BottomNavigationBarItem(
icon: Icon(Icons.settings), label: "设置"),
]),
),
// VerticalDivider(),
Expanded(
flex: 1,
child: SizedBox(
height: 48,
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex.value,
onTap: (index) {
setState(() {
_currentIndex.value = index;
});
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.date_range_rounded),
label: "实时"),
BottomNavigationBarItem(
icon: Icon(Icons.map_outlined), label: "计划"),
BottomNavigationBarItem(
icon: Icon(Icons.my_location_sharp),
label: "对点"),
BottomNavigationBarItem(
icon: Icon(Icons.table_chart_outlined),
label: "历史"),
BottomNavigationBarItem(
icon: Icon(Icons.settings), label: "设置"),
]),
),
)
]);
}
},
));
)
]);
}
},
),
);
}
}

View File

@ -1,9 +1,7 @@
import 'package:cpnav/pages/real/realController.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/record_entity.dart';
import 'package:scence_map/scence_map.dart';
import '../../service/pile/device_type.dart';
@ -25,6 +23,8 @@ class SightController extends GetxController {
var visualList = [].obs;
var plot = 2.0.obs;
var scale = 0.75.obs;
int lastManualTapTime = 0;
int lastCloseTapTime = 0;
reset() {
sightOffset.value = const Offset(3, 3);
sightOffsetInit.value = const Offset(0, 0);
@ -144,9 +144,9 @@ class DrawCicle extends CustomPainter {
canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
canvas.translate(rectWidth + 5, rectWidth + 5);
// if (sight.selectedRecord.value != Offset(2, 2)) {
// drawPoint(canvas);
// }
if (sight.selectedPilePoint != null) {
drawPoint(canvas);
}
// //
// double x = real.tiltX.value; //
@ -175,7 +175,8 @@ class DrawCicle extends CustomPainter {
}
drawPoint(Canvas canvas) {
canvas.drawCircle(Offset.zero, 20, Paint()..color = Colors.grey);
canvas.drawCircle(Offset.zero, 20,
Paint()..color = const Color.fromARGB(255, 139, 33, 33));
// drawText(canvas, pos - const Offset(20, 10), i, false);
}

View File

@ -1,16 +1,16 @@
import 'dart:async';
import 'dart:math';
import 'dart:ui' as ui;
import 'package:cpnav/appbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scence_map/scence_map.dart';
import 'package:scence_map/controllers/controller.dart';
import '../../controllers/gnss_Controller.dart';
import '../../service/pile/device_type.dart';
import 'aimPointer.dart';
final SightController sight = Get.put(SightController());
final ScenceMapController mapcontroller = Get.put(ScenceMapController());
final GnssController gnsscontroller = Get.put(GnssController());
class AimPointer extends StatefulWidget {
const AimPointer({super.key});
@ -46,11 +46,16 @@ class _AimPointerState extends State<AimPointer> {
bool isPortrait = Orientation.portrait == orientation ? true : false;
double rectWidth = size.width;
final deviceType = getDeviceType(context);
// var dx = item.x - targetPoint.dx;
// var dy = item.y - targetPoint.dy;
// var left = dx * cos(maprotation) + dy * sin(maprotation);
// var top = -dx * sin(maprotation) + dy * cos(maprotation);
double left = 0.0;
double top = 0.0;
if (sight.selectedPilePoint != null) {
var dx = gnsscontroller.device.x - sight.selectedPilePoint!.x;
var dy = gnsscontroller.device.y - sight.selectedPilePoint!.y;
left = dx * cos(mapcontroller.rotation.value) +
dy * sin(mapcontroller.rotation.value);
top = -dx * sin(mapcontroller.rotation.value) +
dy * cos(mapcontroller.rotation.value);
}
if (orientation == Orientation.landscape) {
rectWidth = size.width / 2 - 60;
if (deviceType == DeviceType.mobile) {
@ -75,17 +80,23 @@ class _AimPointerState extends State<AimPointer> {
child: Stack(
children: [
Container(
width: rectWidth,
height: rectWidth,
clipBehavior: Clip.hardEdge, //
decoration: BoxDecoration(
border: Border.all(
color: isDarkMode ? Colors.white : Colors.black),
borderRadius:
BorderRadius.all(Radius.circular(rectWidth / 2)),
),
child: const SightView(),
),
width: rectWidth,
height: rectWidth,
clipBehavior: Clip.hardEdge, //
decoration: BoxDecoration(
border: Border.all(
color: isDarkMode ? Colors.white : Colors.black),
borderRadius:
BorderRadius.all(Radius.circular(rectWidth / 2)),
),
child: Obx(() {
return Transform(
transform: Matrix4.identity()
..rotateZ(mapcontroller.rotation.value),
alignment: FractionalOffset.center,
child: const SightView(),
);
})),
Positioned(
top: 0,
left: 10,
@ -123,25 +134,26 @@ class _AimPointerState extends State<AimPointer> {
onPressed: () {
//
sight.isCardVisible.value = false;
sight.lastCloseTapTime =
DateTime.now().millisecondsSinceEpoch;
},
),
),
Positioned(
// left: rectWidth / 2 + left / mapcontroller.pixel2MeterRatio,
// top: rectWidth / 2 - top / mapcontroller.pixel2MeterRatio,
left: 70,
top: 70,
// child: Obx(() {
// return Transform(
// // transform: Matrix4.identity()..rotateZ(item.rotation.value),
// transform: Matrix4.identity()..rotateZ(0),
// alignment: FractionalOffset.center,
// child: DevicePointer(item),
// );
// }),
if (sight.selectedPilePoint != null)
Positioned(
left: rectWidth / 2 + left / mapcontroller.pixel2MeterRatio,
top: rectWidth / 2 - top / mapcontroller.pixel2MeterRatio,
// left: 70,
// top: 70,
child: Transform(
transform: Matrix4.identity()
..rotateZ(gnsscontroller.device.rotation + pi / 2),
alignment: FractionalOffset.center,
child: DevicePointer(),
)
child: DevicePointer(),
)
// child: DevicePointer(),
)
],
),
),

View File

@ -13,6 +13,7 @@ import 'package:scence_map/record_entity.dart';
import 'package:scence_map/scence_map.dart';
import 'package:syncfusion_flutter_sliders/sliders.dart';
import '../real/realDataCard.dart';
import 'iconContainer.dart';
import "controller.dart";
@ -265,6 +266,7 @@ class _PasstrackState extends State<PassTrack> {
),
IconContainer(),
SightGview(),
RealDataShow(),
// CustomPaint(
// painter: BorderPainter(controller),
// ),

View File

@ -0,0 +1,173 @@
//
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'realController.dart';
class RealDataShow extends StatelessWidget {
const RealDataShow({super.key});
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
final Orientation orientation =
MediaQuery.of(context).orientation; //
// var isDataVisible = true.obs;
final RealController controller1 = Get.find();
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
double width;
double height;
//
if (orientation == Orientation.portrait) {
width = size.width / 5 * 2.4; //
height = size.height / 5 * 2; //
} else {
width = size.width / 3.7; //
height = size.height / 1.5; //
}
return Obx(() => Positioned(
left: controller1.sightOffset1.value.dx,
top: controller1.sightOffset1.value.dy,
width: width,
height: height,
child: GestureDetector(
onPanStart: (details) {
//
controller1.sightInit1.value =
details.localPosition - controller1.sightOffset1.value;
},
onPanUpdate: (details) {
//
controller1.sightOffset1.value =
details.localPosition - controller1.sightInit1.value;
},
child: Visibility(
visible: controller1.isDataVisible.value,
child: Container(
decoration: const BoxDecoration(
color: Color.fromARGB(0, 214, 133, 133)),
child: Card(
elevation: 5.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"实时数据",
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.bold,
color: isDarkMode
? Colors.white
: Colors.black),
),
IconButton(
icon: const Icon(Icons.close),
onPressed: () {
controller1.isDataVisible.value = false;
},
),
],
),
..._buildRealTimeDataList(context),
],
),
),
),
)))));
}
Widget _buildCard(BuildContext context, double width, double height) {
final RealController controller1 = Get.find();
return Container(
decoration: const BoxDecoration(color: Color.fromARGB(0, 214, 133, 133)),
child: Card(
elevation: 5.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("实时数据"),
IconButton(
icon: const Icon(Icons.close),
onPressed: () {
controller1.isDataVisible.value = false;
},
),
],
),
..._buildRealTimeDataList(context),
],
),
),
),
);
}
List<Widget> _buildRealTimeDataList(BuildContext context) {
//
final RealController realController = Get.find();
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
// final orientation = MediaQuery.of(context).orientation;
// bool isPortrait = Orientation.portrait == orientation ? true : false;
//
List<DataItem> dataItems = [
DataItem(
"速度(m/min)",
() => realController.speed.abs() >= 100
? realController.speed.toStringAsFixed(1)
: realController.speed.toStringAsFixed(2)),
DataItem("时间(min:s)", () => realController.time.value),
DataItem("深度(m)", () => realController.depth.toStringAsFixed(2)),
DataItem("1#瞬时流量(L/min)",
() => realController.subtotalFlow1.toStringAsFixed(2)),
DataItem("2#瞬时流量(L/min)",
() => realController.subtotalFlow2.toStringAsFixed(2)),
DataItem(
"1#累计流量(L)", () => realController.totalFlow1.toStringAsFixed(2)),
DataItem(
"2#累计流量(L)", () => realController.totalFlow2.toStringAsFixed(2)),
];
//
return dataItems.map((item) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(item.title,
style: TextStyle(
fontSize: 13,
color: isDarkMode ? Colors.white : Colors.black,
)),
Obx(() => Text(item.value(),
style: TextStyle(
fontSize: 18,
color: isDarkMode ? Colors.white : Colors.black,
))),
],
),
);
}).toList();
}
}
class DataItem {
final String title;
final String Function() value;
DataItem(this.title, this.value);
}

View File

@ -0,0 +1,290 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../XyChange/connect.dart';
import '../connect/config/blueParams.dart';
import '../connect/controllers/blueToothController.dart';
final BlueToothController blueToothController = Get.put(BlueToothController());
BlueSetting blueSetting = BlueSetting();
class AntennaSetting extends GetView<AntennaController> {
const AntennaSetting({super.key});
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final isPortrait =
MediaQuery.of(context).orientation == Orientation.portrait;
// brightness信息
Brightness currentBrightness = Theme.of(context).brightness;
bool isDarkMode = currentBrightness == Brightness.dark;
Widget simpleDevice = Card(
clipBehavior: Clip.hardEdge,
child: CustomPaint(
size: isPortrait
? Size(size.width, size.height / 2)
: Size(size.width / 2, size.height - 80),
painter: SimpleDevice(controller, isDarkMode),
),
);
List<Widget> inputList = [
// const Text("中心点位置(m):"),
// Row(
// children: [
// Expanded(
// child: TextFormField(
// enabled: false, // false以禁止输入
// initialValue:
// controller.centerPoint.value.dx.toStringAsFixed(3),
// keyboardType: TextInputType.number,
// decoration: const InputDecoration(prefixText: 'x:'),
// validator: (value) {
// if (value == null || value.isEmpty) {
// return '请输入';
// }
// return null;
// },
// onChanged: (String value) {
// if (value != "") {
// double point = double.parse(value);
// if (point != 0) {
// controller.centerPoint.value =
// Offset(point, controller.centerPoint.value.dy);
// }
// }
// }),
// ),
// const SizedBox(
// width: 5,
// ),
// Expanded(
// child: TextFormField(
// enabled: false, // false以禁止输入
// initialValue:
// controller.centerPoint.value.dy.toStringAsFixed(3),
// keyboardType: TextInputType.number,
// decoration: const InputDecoration(prefixText: 'y:'),
// validator: (value) {
// if (value == null || value.isEmpty) {
// return '请输入';
// }
// return null;
// },
// onChanged: (String value) {
// if (value != "") {
// double point = double.parse(value);
// if (point != 0) {
// controller.centerPoint.value =
// Offset(controller.centerPoint.value.dx, point);
// }
// }
// }),
// )
// ],
// ),
const Text("左侧位置(m):"),
Row(
children: [
Expanded(
child: TextFormField(
initialValue: controller.leftPoint.value.dx.toStringAsFixed(3),
keyboardType: TextInputType.number,
decoration: const InputDecoration(prefixText: 'x:'),
validator: (value) {
if (value == null || value.isEmpty) {
return '请输入值';
}
return null;
},
onChanged: (String value) {
if (value != "") {
double point = double.parse(value);
if (point != 0) {
controller.leftPoint.value =
Offset(point, controller.leftPoint.value.dy);
}
}
}),
),
const SizedBox(
width: 5,
),
Expanded(
child: TextFormField(
initialValue: controller.leftPoint.value.dy.toStringAsFixed(3),
keyboardType: TextInputType.number,
decoration: const InputDecoration(prefixText: 'y:'),
validator: (value) {
if (value == null || value.isEmpty) {
return '请输入值';
}
return null;
},
onChanged: (String value) {
if (value != "") {
double point = double.parse(value);
if (point != 0) {
controller.leftPoint.value =
Offset(controller.leftPoint.value.dx, point);
}
}
}),
),
],
),
const Text("右侧位置(m):"),
Row(
children: [
Expanded(
child: TextFormField(
initialValue: controller.rightPoint.value.dx.toStringAsFixed(3),
keyboardType: TextInputType.number,
decoration: const InputDecoration(prefixText: 'x:'),
validator: (value) {
if (value == null || value.isEmpty) {
return '请输入值';
}
return null;
},
onChanged: (String value) {
if (value != "") {
double point = double.parse(value);
if (point != 0) {
controller.rightPoint.value =
Offset(point, controller.rightPoint.value.dy);
}
}
}),
),
const SizedBox(
width: 5,
),
Expanded(
child: TextFormField(
initialValue: controller.rightPoint.value.dy.toStringAsFixed(3),
keyboardType: TextInputType.number,
decoration: const InputDecoration(prefixText: 'y:'),
validator: (value) {
if (value == null || value.isEmpty) {
return '请输入值';
}
return null;
},
onChanged: (String value) {
if (value != "") {
double point = double.parse(value);
if (point != 0) {
controller.rightPoint.value =
Offset(controller.rightPoint.value.dx, point);
}
}
}),
)
],
),
];
Widget button = TextButton(
onPressed: () {
Offset center = controller.leftPoint.value;
Offset right =
controller.rightPoint.value - controller.leftPoint.value;
Connect().writeAntenna(
Offset(-center.dx, center.dy),
Offset(right.dx, -right.dy),
blueToothController.connectedDeviceID.value);
},
child: const Text("位置更新"));
return Scaffold(
appBar: AppBar(
title: const Text('天线位置设置'),
toolbarHeight: 40,
),
body: SingleChildScrollView(
child: isPortrait
? Column(
children: [
simpleDevice,
Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [...inputList, button],
),
)
],
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
simpleDevice,
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [...inputList, button],
),
))
],
),
),
);
}
}
//
class SimpleDevice extends CustomPainter {
final AntennaController controller;
final bool isDarkMode;
SimpleDevice(this.controller, this.isDarkMode) : super();
@override
void paint(Canvas canvas, Size size) {
final Paint paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 2.0;
paint.color = isDarkMode ? Colors.white : Colors.black;
final Path path = Path();
double w = size.width;
if (size.width > size.height) {
w = size.height;
}
double unit = w * .1;
double width = w * .2;
double height = w * .8;
double left = (size.width - width) / 2;
double top = (size.height - height) / 2;
canvas.translate(left, top);
canvas.drawRect(Rect.fromLTWH(0, 0, width, height), paint);
Offset center = Offset(controller.centerPoint.value.dx * unit,
controller.centerPoint.value.dy * unit);
double radius = 10;
canvas.drawCircle(center, radius, paint);
canvas.translate(center.dx, center.dy);
Offset leftPoint = Offset(controller.leftPoint.value.dx * unit,
controller.leftPoint.value.dy * unit);
Offset rightPoint = Offset(controller.rightPoint.value.dx * unit,
controller.rightPoint.value.dy * unit);
canvas.drawLine(const Offset(10, 0), rightPoint, paint);
canvas.drawLine(const Offset(-10, 0), leftPoint, paint);
canvas.drawCircle(rightPoint, 10, paint);
canvas.drawCircle(leftPoint, 10, paint);
canvas.translate(-center.dx, -center.dy);
canvas.drawPath(path, paint);
canvas.translate(-left, -top);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
class AntennaController extends GetxController {
var leftPoint = const Offset(-1, 3).obs;
var rightPoint = const Offset(1, 3).obs;
var centerPoint = const Offset(1.0, 0.5).obs;
}

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
import 'child_pages/XyChange/xy_change.dart';
import 'child_pages/antenna/antenna_setting.dart';
import 'child_pages/connect/bluetooth_page.dart';
import 'child_pages/persondetail/person_details.dart';
import 'child_pages/connect/wifi_page.dart';
@ -13,7 +13,6 @@ import 'child_pages/connect/config/app_config.dart';
import 'child_pages/connect/config/connect_type.dart';
import 'child_pages/connect/controllers/blueToothController.dart';
//
TextStyle textStyle = const TextStyle(fontSize: 15);
@ -108,8 +107,8 @@ class _SettingPortraitState extends State<SettingPortrait> {
MaterialPageRoute(builder: (context) => const PersonDetails()));
}),
ListItem('天线位置设置', Icons.settings_input_antenna, () {
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => const AntennaSetting()));
Navigator.push(context,
MaterialPageRoute(builder: (context) => const AntennaSetting()));
}),
];
SchedulerBinding.instance.addPostFrameCallback((_) async {});

View File

@ -363,7 +363,7 @@ packages:
source: hosted
version: "1.0.1"
path_provider:
dependency: transitive
dependency: "direct main"
description:
name: path_provider
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378

View File

@ -58,6 +58,7 @@ dependencies:
open_settings: ^2.0.2
wifi_scan: ^0.4.1+1
wifi_iot: ^0.3.19+1
path_provider: ^2.1.4
dev_dependencies: