2024-08-26 18:58:33 +08:00
|
|
|
import 'package:cpnav/controllers/gnss_Controller.dart';
|
2024-08-18 22:42:37 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:get/get.dart';
|
2024-08-26 18:58:33 +08:00
|
|
|
import 'package:scence_map/controllers/controller.dart';
|
2024-08-26 18:25:21 +08:00
|
|
|
import 'package:scence_map/controllers/plumController.dart';
|
2024-08-23 17:54:57 +08:00
|
|
|
import 'appbar.dart';
|
2024-08-28 17:56:53 +08:00
|
|
|
import 'pages/aim_point/aimPointer.dart';
|
2024-08-29 17:45:39 +08:00
|
|
|
import 'pages/history/history_record.dart';
|
2024-08-18 22:42:37 +08:00
|
|
|
import 'pages/pass_track/view.dart';
|
2024-08-26 18:25:21 +08:00
|
|
|
import 'pages/pile/pileNav/view.dart';
|
2024-08-23 17:54:57 +08:00
|
|
|
import 'pages/pile/rightDra/pileGenerate.dart';
|
2024-08-29 17:45:39 +08:00
|
|
|
import 'pages/real/index.dart';
|
|
|
|
import 'pages/setting/setting_page.dart';
|
2024-08-18 22:42:37 +08:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
2024-08-26 18:58:33 +08:00
|
|
|
Get.put(ScenceMapController());
|
2024-08-23 17:54:57 +08:00
|
|
|
Get.put(PlumDataController());
|
2024-08-28 17:56:53 +08:00
|
|
|
Get.put(SightController());
|
2024-08-26 18:58:33 +08:00
|
|
|
Get.put(GnssController());
|
2024-08-18 22:42:37 +08:00
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-08-29 17:45:39 +08:00
|
|
|
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'),
|
|
|
|
);
|
|
|
|
},
|
2024-08-18 22:42:37 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
final String title;
|
2024-08-29 17:45:39 +08:00
|
|
|
static ValueNotifier<bool> isDarkMode = ValueNotifier<bool>(false);
|
2024-08-18 22:42:37 +08:00
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
late bool isPortrait;
|
|
|
|
late double appBarHeight = 34.0;
|
|
|
|
|
|
|
|
final _currentIndex = 0.obs;
|
|
|
|
final List<Widget> _pages = [
|
2024-08-29 17:45:39 +08:00
|
|
|
Real(),
|
2024-08-26 18:25:21 +08:00
|
|
|
RealView(),
|
2024-08-18 22:42:37 +08:00
|
|
|
Container(
|
|
|
|
color: Colors.blue,
|
|
|
|
),
|
2024-08-29 17:45:39 +08:00
|
|
|
HistoryRecord(),
|
|
|
|
SettingPortrait()
|
2024-08-18 22:42:37 +08:00
|
|
|
];
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-08-23 17:54:57 +08:00
|
|
|
final size = MediaQuery.of(context).size;
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-08-18 22:42:37 +08:00
|
|
|
return Scaffold(
|
2024-08-26 18:25:21 +08:00
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
drawerEdgeDragWidth: 0.0, // 禁止通过滑动打开drawer
|
2024-08-23 17:54:57 +08:00
|
|
|
endDrawer: _currentIndex.value == 1
|
|
|
|
? Drawer(
|
|
|
|
width: size.width * .8,
|
|
|
|
child: const PileGenerate(),
|
|
|
|
)
|
|
|
|
: null,
|
2024-08-18 22:42:37 +08:00
|
|
|
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],
|
|
|
|
),
|
|
|
|
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],
|
|
|
|
),
|
|
|
|
// 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: "设置"),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|