132 lines
5.0 KiB
Dart
132 lines
5.0 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get_state_manager/get_state_manager.dart';
|
|
import 'package:get/state_manager.dart';
|
|
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
|
import 'package:terepi_seged/pages/shell/presentations/controllers/shell_controller.dart';
|
|
import 'package:terepi_seged/services/gnss/gnss_service.dart';
|
|
import 'package:terepi_seged/services/ntrip_service.dart';
|
|
import 'package:terepi_seged/widgets/gnss_status_chip.dart';
|
|
import 'package:terepi_seged/widgets/map_mode_menu_anchor.dart';
|
|
|
|
class ShellMapAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final MapSurveyController controller;
|
|
|
|
const ShellMapAppBar({
|
|
super.key,
|
|
required this.controller,
|
|
});
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(52);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
toolbarHeight: 60,
|
|
leadingWidth: 44,
|
|
titleSpacing: 0,
|
|
leading: Builder(builder: (context) {
|
|
return IconButton(
|
|
padding: EdgeInsets.zero,
|
|
constraints: const BoxConstraints(minWidth: 40, minHeight: 40),
|
|
icon: const Icon(Icons.menu),
|
|
onPressed: () {
|
|
Scaffold.of(context).openDrawer();
|
|
},
|
|
);
|
|
}),
|
|
title: Obx(() {
|
|
return Row(children: [
|
|
MapModeMenuAnchor(controller: controller),
|
|
const SizedBox(width: 2),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Row(children: [
|
|
const Text('H:', style: TextStyle(fontSize: 12)),
|
|
SizedBox(width: 2),
|
|
Text(controller.horizontalAccuracyText,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: _errorColor(max(
|
|
controller.gpsLatitudeError.value,
|
|
controller.gpsLongitudeError.value)),
|
|
fontWeight: FontWeight.w600,
|
|
fontFeatures: const [FontFeature.tabularFigures()]))
|
|
]),
|
|
Row(children: [
|
|
const Text('V:', style: TextStyle(fontSize: 12)),
|
|
SizedBox(width: 2),
|
|
Text(controller.verticalAccuracyText,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color:
|
|
_errorColor(controller.gpsAltitudeError.value),
|
|
fontWeight: FontWeight.w600,
|
|
fontFeatures: const [FontFeature.tabularFigures()]))
|
|
])
|
|
]),
|
|
SizedBox(width: 8),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
GnssTextStatusChip(),
|
|
Row(children: [
|
|
const Icon(Icons.satellite_alt, size: 12),
|
|
SizedBox(width: 2),
|
|
Text(
|
|
'${GnssService.to.totalVisibleSatellites}/${GnssService.to.totalUsedSatellites}',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w600,
|
|
fontFeatures: const [FontFeature.tabularFigures()]))
|
|
])
|
|
]),
|
|
const GnssIconStatusChip(),
|
|
const SizedBox(width: 2),
|
|
NtripIconStatusChip(
|
|
isConnected: NtripService.to.isConnected,
|
|
onToggle: () {
|
|
NtripService.to.isConnected.value
|
|
? NtripService.to.disconnect()
|
|
: NtripService.to.connect();
|
|
},
|
|
onSettings: () {
|
|
HapticFeedback.mediumImpact();
|
|
controller.openNtripsettings();
|
|
}),
|
|
]);
|
|
}),
|
|
actions: [
|
|
PopupMenuButton(
|
|
tooltip: 'További funkciók',
|
|
icon: const Icon(Icons.more_vert),
|
|
onSelected: null,
|
|
itemBuilder: (context) => const [
|
|
PopupMenuItem(
|
|
value: 1,
|
|
child: Text('Koordináták'),
|
|
),
|
|
PopupMenuItem(
|
|
value: 1,
|
|
child: Text('Rétegek'),
|
|
),
|
|
])
|
|
]);
|
|
}
|
|
|
|
Color _errorColor(double e) {
|
|
if (e < 0.05) return Colors.greenAccent;
|
|
if (e < 0.2) return Colors.green;
|
|
if (e < 1.0) return Colors.orange;
|
|
return Colors.red;
|
|
}
|
|
}
|