pile_nav_new/lib/appbar.dart

170 lines
6.0 KiB
Dart
Raw Normal View History

2024-08-18 22:42:37 +08:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
2024-08-27 18:08:05 +08:00
import 'package:scence_map/controllers/controller.dart';
2024-08-18 22:42:37 +08:00
2024-08-29 17:45:39 +08:00
import 'main.dart';
2024-08-28 17:56:53 +08:00
import 'pages/aim_point/aimPointer.dart';
2024-08-18 22:42:37 +08:00
// import '../login_in/connect/bluetooth_page.dart';
// import '../login_in/connect/connect_type.dart';
// import '../login_in/getx/real_data.dart';
// import 'main.dart';
2024-08-28 17:56:53 +08:00
final SightController sightcontroller = Get.find();
2024-08-18 22:42:37 +08:00
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;
@override
Widget build(BuildContext context) {
const textStyle = TextStyle(fontSize: 16);
return AppBar(
toolbarHeight: 40,
centerTitle: true, // 标题居中
title: Obx(() {
if (_currentIndex.value == 0) {
return const Text("桩点:", style: textStyle);
} else if (_currentIndex.value == 1) {
return const Text("设备:", style: textStyle);
} else {
return const Text("系统:", style: textStyle);
}
}),
// title: _currentIndex.value == 0
// ? Obx(() => Text("桩点:${realController.pileId.value}",
// style: textStyle))
// : const Text("设备:", style: textStyle),
// // const Center(
// // child: Obx(() => Text("设备:", style: textStyle)),
// // ),
// title: Obx(() {
// if (_currentIndex.value == 1) {
// return const Text("设备:", style: textStyle);
// } else if (_currentIndex.value == 0) {
// return Text("桩点:${realController.pileId.value}",
// style: textStyle);
// } else {
// return const Text("系统:", style: textStyle);
// }
// }),
actions: [
InkWell(
onTap: () {
2024-08-29 17:45:39 +08:00
MyHomePage.isDarkMode.value = !MyHomePage.isDarkMode.value;
2024-08-18 22:42:37 +08:00
},
child: Icon(
2024-08-29 17:45:39 +08:00
MyHomePage.isDarkMode.value ? Icons.dark_mode : Icons.sunny,
2024-08-18 22:42:37 +08:00
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,
2024-08-29 17:45:39 +08:00
color: MyHomePage.isDarkMode.value
2024-08-18 22:42:37 +08:00
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
height: 40,
),
),
const SizedBox(
width: 10,
),
_currentIndex.value == 1
? Row(
children: [
Obx(
() => InkWell(
onTap: () {
// 点击图标时显示对点卡片
2024-08-28 17:56:53 +08:00
sightcontroller.isCardVisible.value =
!sightcontroller.isCardVisible.value; // 确保控制器已定义
2024-08-18 22:42:37 +08:00
},
child: Icon(
Icons.my_location_sharp,
size: 35,
2024-08-28 17:56:53 +08:00
color: sightcontroller.isCardVisible.value
2024-08-18 22:42:37 +08:00
? Colors.blue
// : const Color.fromARGB(200, 29, 28, 28),
2024-08-29 17:45:39 +08:00
: (MyHomePage.isDarkMode.value
2024-08-18 22:42:37 +08:00
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28)),
), // 新增图标
),
),
const SizedBox(
width: 10,
),
Obx(
() => InkWell(
onTap: () {
// final RealController controller1 = Get.find(); // 获取控制器
// controller1.isDataVisible.value =
// !controller1.isDataVisible.value; // 更新控制器中的值
},
child: Icon(
Icons.date_range_rounded,
size: 35,
color: isDataVisible.value
? Colors.blue
2024-08-29 17:45:39 +08:00
: (MyHomePage.isDarkMode.value
2024-08-18 22:42:37 +08:00
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28)),
), // 新增图标
),
),
const SizedBox(
width: 10,
),
UnconstrainedBox(
child: SizedBox(
height: 30,
child: Builder(
builder: (context) => InkWell(
child: Icon(
Icons.settings_outlined,
size: 35,
2024-08-29 17:45:39 +08:00
color: MyHomePage.isDarkMode.value
2024-08-18 22:42:37 +08:00
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
),
onTap: () => Scaffold.of(context).openEndDrawer(),
),
),
),
)
],
)
: const Text(""),
// Obx(() => Icon(
// blueToothController.connectedType.value == ConnectType.wifi
// ? Icons.wifi
// : (blueToothController.connectedType.value ==
// ConnectType.bluetooth
// ? Icons.bluetooth
// : Icons.close),
// color: Colors.green,
// size: 30,
// ))
],
);
}
@override
Size get preferredSize => Size.fromHeight(appBarHeight);
}