261 lines
8.9 KiB
Dart
261 lines
8.9 KiB
Dart
//字体
|
||
import 'package:bottom_picker/resources/arrays.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/rendering.dart';
|
||
import 'package:flutter/scheduler.dart';
|
||
import 'package:flutter/widgets.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:scence_map/controller.dart';
|
||
import 'package:scence_map/scence_map.dart';
|
||
import 'package:bottom_picker/bottom_picker.dart';
|
||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||
import 'bottomMenu.dart';
|
||
import "controller.dart";
|
||
// import '../login_in/connect/bluetooth_page.dart';
|
||
// import '../login_in/connect/config.dart';
|
||
// import '../login_in/connect/connect_type.dart';
|
||
// import '../login_in/getx/blue_tooth.dart';
|
||
// import '../setting/antenna_setting.dart';
|
||
// import '../setting/person_details.dart';
|
||
// import '../setting/wifi_page.dart';
|
||
// import '../setting/xy_change.dart';
|
||
|
||
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||
|
||
class PassTrack extends StatefulWidget {
|
||
final String date;
|
||
final controller;
|
||
|
||
const PassTrack({super.key, required this.date, this.controller});
|
||
|
||
@override
|
||
State<PassTrack> createState() => _PasstrackState();
|
||
}
|
||
|
||
// FileHandle fileHandle = FileHandle();
|
||
|
||
class _PasstrackState extends State<PassTrack> {
|
||
final controller = Get.put(PassTrackController("WXLMB", "cp_orad"));
|
||
String str = "播放";
|
||
int sWidth = 0;
|
||
int bits = -1;
|
||
int speed = 50;
|
||
List<int> speedList = [1, 2, 10, 20, 50, 100, 200, 500];
|
||
int maxLength = 200;
|
||
// int _value = 0;
|
||
SfRangeValues _rangevalues = const SfRangeValues(0.0, 200.0);
|
||
// late final ScenceMapScaleMoveCallback? onUpdate;
|
||
@override
|
||
initState() {
|
||
super.initState();
|
||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
|
||
// .ceil();
|
||
|
||
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
|
||
// fileHandle.date = widget.date;
|
||
// await fileHandle.init();
|
||
// //在帧绘制完成后执行数据渲染
|
||
// // await initPlatformState();
|
||
// if (fileHandle.pointData.isNotEmpty) {
|
||
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
|
||
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
|
||
// }
|
||
|
||
// for (var item in fileHandle.deviceList) {
|
||
// if (item["point"] != null) {
|
||
// bits = item["bits"];
|
||
// break;
|
||
// }
|
||
// }
|
||
// // passTrackPlugin.map_setCenterDevice(bits);
|
||
// setState(() {
|
||
// if (fileHandle.pointData.isNotEmpty) {
|
||
// maxLength = fileHandle.pointData.length;
|
||
// // _value = maxLength;
|
||
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
|
||
// }
|
||
// });
|
||
});
|
||
}
|
||
|
||
Future<void> initPlatformState() async {
|
||
// String platformVersion;
|
||
// try {
|
||
// platformVersion = await passTrackPlugin.getPlatformVersion() ??
|
||
// 'Unknown platform version';
|
||
// } on PlatformException {
|
||
// platformVersion = 'Failed to get platform version.';
|
||
// }
|
||
// await passTrackPlugin.create(sWidth, sWidth);
|
||
// fileHandle.textureId = await passTrackPlugin.getTextureId() ?? -1;
|
||
// print("textureId: ${fileHandle.textureId}");
|
||
|
||
// if (!mounted) return;
|
||
|
||
// setState(() {
|
||
// platformVersion = platformVersion;
|
||
// });
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final size = MediaQuery.of(context).size;
|
||
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
||
return Stack(
|
||
children: [
|
||
ScenceMapView(
|
||
children: [],
|
||
onUpdate: (Offset center, double scale, double rotation) {
|
||
print("center:$center scale:$scale rotation:$rotation");
|
||
},
|
||
),
|
||
Positioned(
|
||
width: isPortrait ? size.width * .63 : size.width * .42,
|
||
left: isPortrait ? 190 : 200,
|
||
bottom: 30,
|
||
child: Container(
|
||
padding: EdgeInsets.only(bottom: 5),
|
||
child: SfRangeSlider(
|
||
// 双向
|
||
min: 0.0,
|
||
max: maxLength,
|
||
values: _rangevalues,
|
||
// interval: 5,
|
||
showTicks: false,
|
||
showLabels: false,
|
||
enableTooltip: true,
|
||
minorTicksPerInterval: 1,
|
||
stepSize: 1,
|
||
onChanged: (SfRangeValues values) {
|
||
setState(() {
|
||
_rangevalues = SfRangeValues(
|
||
values.start.roundToDouble(), values.end.roundToDouble());
|
||
});
|
||
},
|
||
),
|
||
),
|
||
),
|
||
Positioned(
|
||
left: isPortrait ? 190 : 200,
|
||
bottom: 0,
|
||
child: Row(
|
||
children: [
|
||
const SizedBox(
|
||
width: 18,
|
||
),
|
||
SizedBox(
|
||
width: 74, // 设置按钮的宽度
|
||
child: ElevatedButton(
|
||
style: ButtonStyle(
|
||
backgroundColor: MaterialStateProperty.all<Color?>(
|
||
str == "播放" ? Colors.blue : Colors.red,
|
||
),
|
||
),
|
||
onPressed: () {
|
||
setState(() {
|
||
if (str == "播放") {
|
||
str = "暂停";
|
||
} else {
|
||
str = "播放";
|
||
}
|
||
});
|
||
},
|
||
child: Text(
|
||
str,
|
||
style: TextStyle(fontSize: 12, color: Colors.black),
|
||
)),
|
||
),
|
||
const SizedBox(
|
||
width: 5,
|
||
),
|
||
ElevatedButton(
|
||
style: ButtonStyle(
|
||
backgroundColor: MaterialStateProperty.all<Color?>(
|
||
Colors.transparent,
|
||
),
|
||
),
|
||
onPressed: () {
|
||
_openSpeedPicker(context, speedList);
|
||
},
|
||
child: Text(speed.toString()),
|
||
),
|
||
const SizedBox(
|
||
width: 15,
|
||
),
|
||
Column(children: [
|
||
Text("此处遍数:0"),
|
||
StreamBuilder<DateTime>(
|
||
stream: Stream.periodic(
|
||
Duration(seconds: 1), (_) => DateTime.now()),
|
||
builder: (context, snapshot) {
|
||
if (snapshot.hasData) {
|
||
final dateTime = snapshot.data!.toLocal();
|
||
final formattedDate =
|
||
"${dateTime.year % 100}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.day.toString().padLeft(2, '0')}";
|
||
final formattedTime =
|
||
"${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}:${dateTime.second.toString().padLeft(2, '0')}";
|
||
return Text(
|
||
"$formattedDate $formattedTime",
|
||
style: const TextStyle(
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.bold,
|
||
),
|
||
);
|
||
} else {
|
||
return const Text(
|
||
"加载中...",
|
||
style: TextStyle(
|
||
fontSize: 16, fontWeight: FontWeight.bold),
|
||
);
|
||
}
|
||
},
|
||
),
|
||
])
|
||
],
|
||
),
|
||
),
|
||
BottomMenu(),
|
||
],
|
||
);
|
||
}
|
||
|
||
void _openSpeedPicker(BuildContext context, List<int> items) {
|
||
List<Text> list = items.map((speed) => Text("$speed 速度")).toList();
|
||
showModalBottomSheet(
|
||
context: context,
|
||
builder: (BuildContext context) {
|
||
return Container(
|
||
width: MediaQuery.of(context).size.width * 0.5, // 设置宽度为屏幕宽度的 80%
|
||
child: BottomPicker(
|
||
items: list,
|
||
pickerTitle: Text('选择播放速度'),
|
||
titleAlignment: Alignment.center,
|
||
titlePadding: const EdgeInsets.all(8.0),
|
||
dismissable: true,
|
||
onSubmit: (index) {
|
||
setState(() {
|
||
speed = items[index];
|
||
});
|
||
},
|
||
bottomPickerTheme: BottomPickerTheme.morningSalad,
|
||
backgroundColor: Colors.white,
|
||
pickerTextStyle: const TextStyle(
|
||
fontSize: 14,
|
||
color: Colors.black,
|
||
),
|
||
itemExtent: 35.0,
|
||
displayCloseIcon: true,
|
||
closeIconColor: Colors.black,
|
||
closeIconSize: 20,
|
||
layoutOrientation: TextDirection.ltr,
|
||
buttonAlignment: MainAxisAlignment.end,
|
||
displaySubmitButton: true,
|
||
buttonContent: Text("确认"),
|
||
),
|
||
);
|
||
},
|
||
);
|
||
}
|
||
}
|