From de783fa0831db1009a8c064e119142a980a51df6 Mon Sep 17 00:00:00 2001 From: tanlinxing Date: Mon, 19 Aug 2024 18:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E9=83=A8=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flutter-plugins | 10 +- .flutter-plugins-dependencies | 2 +- .vscode/launch.json | 45 +++ lib/main.dart | 6 +- lib/pages/pass_track/bottomMenu.dart | 437 +++++++++++++++++++++++++++ lib/pages/pass_track/view.dart | 244 ++++++++++++++- pubspec.lock | 56 +++- pubspec.yaml | 2 + 8 files changed, 776 insertions(+), 26 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 lib/pages/pass_track/bottomMenu.dart diff --git a/.flutter-plugins b/.flutter-plugins index 5950249..1c6e910 100644 --- a/.flutter-plugins +++ b/.flutter-plugins @@ -1,6 +1,6 @@ # This is a generated file; do not edit or check into version control. -path_provider=C:\\Users\\Holy\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.4\\ -path_provider_android=C:\\Users\\Holy\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.10\\ -path_provider_foundation=C:\\Users\\Holy\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_foundation-2.4.0\\ -path_provider_linux=C:\\Users\\Holy\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_linux-2.2.1\\ -path_provider_windows=C:\\Users\\Holy\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_windows-2.3.0\\ +path_provider=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.4\\ +path_provider_android=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.10\\ +path_provider_foundation=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_foundation-2.4.0\\ +path_provider_linux=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_linux-2.2.1\\ +path_provider_windows=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_windows-2.3.0\\ diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 56aa6d6..e518847 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Holy\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\Holy\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Holy\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Holy\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Holy\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-18 22:26:36.756652","version":"3.22.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-19 18:27:32.051943","version":"3.24.0","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..929b29b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // 使用 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": "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" + } + ] +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 9733d20..f708704 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,11 +2,13 @@ import 'package:cpnav/appbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; +import 'package:scence_map/controller.dart'; import 'pages/pass_track/view.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏 + runApp(const MyApp()); } @@ -66,7 +68,9 @@ class _MyHomePageState extends State { final _currentIndex = 0.obs; final List _pages = [ - PassTrack(), + PassTrack( + date: '', + ), Container( color: Colors.green, ), diff --git a/lib/pages/pass_track/bottomMenu.dart b/lib/pages/pass_track/bottomMenu.dart new file mode 100644 index 0000000..c2ab619 --- /dev/null +++ b/lib/pages/pass_track/bottomMenu.dart @@ -0,0 +1,437 @@ +import 'package:cpnav/pages/pass_track/view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class BottomMenu extends StatefulWidget { + @override + _BottomMenuState createState() => _BottomMenuState(); +} + +class _BottomMenuState extends State { + int _selectedIndex = -1; + void _temporarilySelectContainer(int index) { + setState(() { + _selectedIndex = index; + }); + Future.delayed(Duration(milliseconds: 200), () { + setState(() { + _selectedIndex = -1; + }); + }); + } + + @override + Widget build(BuildContext context) { + var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; + return isPortrait + ? Positioned( + right: 10, + bottom: 130, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 36, + decoration: BoxDecoration( + color: Colors.transparent, // 设置背景为透明 + border: Border.all( + color: Color.fromARGB(255, 54, 52, 52), + width: 1.0, // 设置边框宽度 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: Column(children: [ + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.article, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.speed, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.thermostat, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + width: 2.0, // 设置边框宽度 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.zoom_in, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + width: 2.0, // 设置边框宽度 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.zoom_out, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.refresh, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.place, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + ]), + ), + ], + )) + : Positioned( + right: 10, + bottom: 15, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + height: 36, + decoration: BoxDecoration( + color: Colors.transparent, // 设置背景为透明 + border: Border.all( + color: Color.fromARGB(255, 54, 52, 52), + width: 1.0, // 设置边框宽度 + ), + borderRadius: BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: Center( + // 使用 Center 小部件将子容器居中 + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.article, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.speed, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.thermostat, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + width: 2.0, // 设置边框宽度 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.zoom_in, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + width: 2.0, // 设置边框宽度 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.zoom_out, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.refresh, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.green, // 设置背景颜色为绿色 + border: Border.all( + color: Colors.white, // 设置边框颜色为白色 + ), + borderRadius: + BorderRadius.circular(5.0), // 可选:设置圆角边框 + ), + child: InkWell( + child: const Icon( + Icons.place, + color: Colors.white, + ), + onTap: () { + mapcontroller.scale = 1.0; + mapcontroller.rotation.value = 0.0; + mapcontroller.updateCount.value++; + // onUpdate?.call( + // mapcontroller.centerXY, 1.0, 0.0); + // sight.reset(); + }, + ), + ), + ], + ), + ), + ), + ], + )); + } +} diff --git a/lib/pages/pass_track/view.dart b/lib/pages/pass_track/view.dart index b76c775..ecc7527 100644 --- a/lib/pages/pass_track/view.dart +++ b/lib/pages/pass_track/view.dart @@ -1,8 +1,15 @@ //字体 +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'; @@ -13,17 +20,240 @@ import "controller.dart"; // import '../setting/wifi_page.dart'; // import '../setting/xy_change.dart'; -class PassTrack extends StatelessWidget { - final controller = Get.put(PassTrackController("WXLMB", "cp_orad")); +ScenceMapController mapcontroller = Get.put(ScenceMapController()); - PassTrack(); +class PassTrack extends StatefulWidget { + final String date; + final controller; + + const PassTrack({super.key, required this.date, this.controller}); + + @override + State createState() => _PasstrackState(); +} + +// FileHandle fileHandle = FileHandle(); + +class _PasstrackState extends State { + final controller = Get.put(PassTrackController("WXLMB", "cp_orad")); + String str = "播放"; + int sWidth = 0; + int bits = -1; + int speed = 50; + List 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 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) { - return ScenceMapView( - children: [], - onUpdate: (Offset center, double scale, double rotation) { - print("center:$center scale:$scale rotation:$rotation"); + 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( + 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( + Colors.transparent, + ), + ), + onPressed: () { + _openSpeedPicker(context, speedList); + }, + child: Text(speed.toString()), + ), + const SizedBox( + width: 15, + ), + Column(children: [ + Text("此处遍数:0"), + StreamBuilder( + 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 items) { + List 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("确认"), + ), + ); }, ); } diff --git a/pubspec.lock b/pubspec.lock index 0d057ca..a56f94c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -25,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + bottom_picker: + dependency: "direct main" + description: + name: bottom_picker + sha256: "7c690407c6c489bc7c556858c3f1b804aac73c3a128559f328cc829ba12983ad" + url: "https://pub.dev" + source: hosted + version: "2.8.0" characters: dependency: transitive description: @@ -147,22 +155,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" leak_tracker: dependency: transitive description: name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.4" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -191,18 +207,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.15.0" path: dependency: transitive description: @@ -335,6 +351,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + syncfusion_flutter_core: + dependency: transitive + description: + name: syncfusion_flutter_core + sha256: "24d7f43ff33bd6248c95d8b3312f6b9fe89637727ca778d60490b81ebd5bd8e7" + url: "https://pub.dev" + source: hosted + version: "26.2.9" + syncfusion_flutter_sliders: + dependency: "direct main" + description: + name: syncfusion_flutter_sliders + sha256: "3adae52373f7dfbf829bbd0b1afe8e37b7e63d13e612a68e7f2474ff8bc5cb99" + url: "https://pub.dev" + source: hosted + version: "26.2.9" term_glyph: dependency: transitive description: @@ -347,10 +379,10 @@ packages: dependency: transitive description: name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.7.2" typed_data: dependency: transitive description: @@ -395,10 +427,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc url: "https://pub.dev" source: hosted - version: "14.2.1" + version: "14.2.4" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index aef09f2..a3614d8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,6 +41,8 @@ dependencies: http: ^1.2.2 flutter_svg: ^2.0.10+1 google_fonts: ^6.2.1 + syncfusion_flutter_sliders: ^26.2.9 + bottom_picker: ^2.8.0 dev_dependencies: flutter_test: