Új appbar, NtripSettingsSheet
This commit is contained in:
@@ -18,23 +18,21 @@ import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:terepi_seged/controls/geoid_grid.dart';
|
||||
import 'package:terepi_seged/enums/map_survey_mode.dart';
|
||||
import 'package:terepi_seged/eov/convert_coordinate.dart';
|
||||
import 'package:terepi_seged/eov/eov.dart';
|
||||
import 'package:terepi_seged/models/point_to_measure.dart';
|
||||
import 'package:terepi_seged/models/point_with_description_model.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/views/measured_points_table_dialog.dart';
|
||||
import 'package:terepi_seged/pages/ntrip_settings/presentation/controllers/ntrip_settings_controller.dart';
|
||||
import 'package:terepi_seged/pages/ntrip_settings/presentation/views/ntrip_settings_sheet.dart';
|
||||
import 'package:terepi_seged/services/coord_converter_service.dart';
|
||||
import 'package:terepi_seged/services/gnss/gnss_connection.dart';
|
||||
import 'package:terepi_seged/services/gnss/gnss_device_service.dart';
|
||||
import 'package:terepi_seged/services/gnss/gnss_service.dart';
|
||||
import 'package:terepi_seged/services/ntrip_service.dart';
|
||||
|
||||
enum MapSurveyMode {
|
||||
measure, // Bemérés — ahol vagyok, azt rögzítem
|
||||
stakeout, // Kitűzés — adott ponthoz navigálok, majd rögzítem
|
||||
}
|
||||
|
||||
class MapSurveyController extends GetxController {
|
||||
static MapSurveyController get to => Get.find();
|
||||
|
||||
@@ -258,6 +256,77 @@ class MapSurveyController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
String _formatMeter(double? value, [int decimalSpace = 3]) {
|
||||
if (value == null || value.isNaN || value.isInfinite) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return '${value.toStringAsFixed(decimalSpace)} m';
|
||||
}
|
||||
|
||||
String get verticalAccuracyText {
|
||||
return _formatMeter(gpsAltitudeError.value);
|
||||
}
|
||||
|
||||
String get horizontalAccuracyText {
|
||||
return _formatMeter(max(gpsLatitudeError.value, gpsLongitudeError.value));
|
||||
}
|
||||
|
||||
void setMode(MapSurveyMode newMode) {
|
||||
mode.value = newMode;
|
||||
|
||||
// Itt lehet módhoz kötött állapotokat állítani:
|
||||
// - alsó panel tartalma
|
||||
// - térképi tap viselkedés
|
||||
// - aktív kártyák
|
||||
// - track indítás/leállítás figyelmeztetés stb.
|
||||
}
|
||||
|
||||
String get currentModeLabel {
|
||||
switch (mode.value) {
|
||||
case MapSurveyMode.browse:
|
||||
return 'Térkép';
|
||||
case MapSurveyMode.measure:
|
||||
return 'Bemérés';
|
||||
case MapSurveyMode.stakeout:
|
||||
return 'Kitűzés';
|
||||
case MapSurveyMode.fieldWalk:
|
||||
return 'Bejárás';
|
||||
}
|
||||
}
|
||||
|
||||
IconData get currentModeIcon {
|
||||
switch (mode.value) {
|
||||
case MapSurveyMode.browse:
|
||||
return Icons.map;
|
||||
case MapSurveyMode.measure:
|
||||
return Icons.add_location_alt;
|
||||
case MapSurveyMode.stakeout:
|
||||
return Icons.gps_fixed;
|
||||
case MapSurveyMode.fieldWalk:
|
||||
return Icons.hiking;
|
||||
}
|
||||
}
|
||||
|
||||
void openNtripsettings() {
|
||||
if (!Get.isRegistered<NtripSettingsController>()) {
|
||||
Get.put(NtripSettingsController());
|
||||
}
|
||||
|
||||
Get.bottomSheet(const NtripSettingsSheet(),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
ignoreSafeArea: false);
|
||||
}
|
||||
|
||||
void showNtripStatus() {
|
||||
// Get.bottomSheet(
|
||||
// const NtripStatusSheet(),
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// );
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────
|
||||
// Térkép vezérlők
|
||||
// ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_map_polywidget/flutter_map_polywidget.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:terepi_seged/enums/map_survey_mode.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/views/settings_dialog.dart';
|
||||
import 'package:terepi_seged/utils/rive_utils.dart';
|
||||
@@ -59,11 +60,11 @@ class MapSurveyView extends GetView<MapSurveyController> {
|
||||
// right: 16,
|
||||
// child: SavePointFab(controller: controller),
|
||||
// ),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: MapBottomPanel(controller: controller))
|
||||
// Positioned(
|
||||
// bottom: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// child: MapBottomPanel(controller: controller))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:terepi_seged/services/ntrip_service.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class NtripSettingsController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
final hostController = TextEditingController();
|
||||
final portController = TextEditingController();
|
||||
final mountPointController = TextEditingController();
|
||||
final usernameController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
|
||||
final isPasswordVisible = false.obs;
|
||||
final autoConnect = false.obs;
|
||||
final isBusy = false.obs;
|
||||
|
||||
final _secureStorage = const FlutterSecureStorage();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
hostController.text = prefs.getString('ntrip_host') ?? '';
|
||||
portController.text = prefs.getInt('ntrip_port')?.toString() ?? '2101';
|
||||
mountPointController.text = prefs.getString('ntrip_mountpoint') ?? '';
|
||||
usernameController.text = prefs.getString('ntrip_username') ?? '';
|
||||
autoConnect.value = prefs.getBool('ntrip_auto_connect') ?? false;
|
||||
|
||||
passwordController.text =
|
||||
await _secureStorage.read(key: 'ntrip_password') ?? '';
|
||||
}
|
||||
|
||||
Future<void> saveSettings() async {
|
||||
if (!(formKey.currentState?.validate() ?? false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString('ntrip_host', hostController.text.trim());
|
||||
await prefs.setInt(
|
||||
'ntrip_port',
|
||||
int.parse(portController.text.trim()),
|
||||
);
|
||||
await prefs.setString(
|
||||
'ntrip_mountpoint',
|
||||
mountPointController.text.trim(),
|
||||
);
|
||||
await prefs.setString(
|
||||
'ntrip_username',
|
||||
usernameController.text.trim(),
|
||||
);
|
||||
await prefs.setBool(
|
||||
'ntrip_auto_connect',
|
||||
autoConnect.value,
|
||||
);
|
||||
|
||||
await _secureStorage.write(
|
||||
key: 'ntrip_password',
|
||||
value: passwordController.text,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> saveAndConnect() async {
|
||||
if (!(formKey.currentState?.validate() ?? false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isBusy.value = true;
|
||||
|
||||
await saveSettings();
|
||||
|
||||
// await NtripService.to.connect(
|
||||
// host: hostController.text.trim(),
|
||||
// port: int.parse(portController.text.trim()),
|
||||
// mountPoint: mountPointController.text.trim(),
|
||||
// username: usernameController.text.trim(),
|
||||
// password: passwordController.text,
|
||||
// );
|
||||
|
||||
Get.back();
|
||||
|
||||
Get.snackbar(
|
||||
'NTRIP',
|
||||
'Kapcsolódás elindítva.',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'NTRIP hiba',
|
||||
e.toString(),
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} finally {
|
||||
isBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> disconnect() async {
|
||||
try {
|
||||
isBusy.value = true;
|
||||
await NtripService.to.disconnect();
|
||||
} finally {
|
||||
isBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
hostController.dispose();
|
||||
portController.dispose();
|
||||
mountPointController.dispose();
|
||||
usernameController.dispose();
|
||||
passwordController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:terepi_seged/services/ntrip_service.dart';
|
||||
|
||||
import '../controllers/ntrip_settings_controller.dart';
|
||||
|
||||
class NtripSettingsSheet extends GetView<NtripSettingsController> {
|
||||
const NtripSettingsSheet({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final bottomInset = MediaQuery.viewInsetsOf(context).bottom;
|
||||
final screenHeight = MediaQuery.sizeOf(context).height;
|
||||
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: screenHeight * 0.86,
|
||||
),
|
||||
child: Material(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: SingleChildScrollView(
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
reverse: true,
|
||||
padding: EdgeInsets.fromLTRB(16, 12, 16, 20 + bottomInset),
|
||||
child: Form(
|
||||
key: controller.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 42,
|
||||
height: 4,
|
||||
margin: const EdgeInsets.only(bottom: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.outlineVariant,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.settings_input_antenna),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'NTRIP beállítások',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: controller.hostController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Caster / host',
|
||||
hintText: 'pl. caster.example.com',
|
||||
prefixIcon: Icon(Icons.dns),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return 'A host megadása kötelező.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: controller.portController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Port',
|
||||
hintText: '2101',
|
||||
prefixIcon: Icon(Icons.tag),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
final port = int.tryParse(value?.trim() ?? '');
|
||||
if (port == null || port <= 0 || port > 65535) {
|
||||
return 'Érvényes portszámot adj meg.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: controller.mountPointController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mountpoint',
|
||||
hintText: 'pl. BUDAPEST_RTCM32',
|
||||
prefixIcon: Icon(Icons.place),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return 'A mountpoint megadása kötelező.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: controller.usernameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Felhasználónév',
|
||||
prefixIcon: Icon(Icons.person),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Obx(() {
|
||||
return TextFormField(
|
||||
controller: controller.passwordController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Jelszó',
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
controller.isPasswordVisible.value
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
onPressed: () {
|
||||
controller.isPasswordVisible.value =
|
||||
!controller.isPasswordVisible.value;
|
||||
},
|
||||
),
|
||||
),
|
||||
obscureText: !controller.isPasswordVisible.value,
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 8),
|
||||
Obx(() {
|
||||
return SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('Automatikus kapcsolódás'),
|
||||
subtitle: const Text(
|
||||
'Az app indításakor próbáljon NTRIP-re kapcsolódni.',
|
||||
),
|
||||
value: controller.autoConnect.value,
|
||||
onChanged: (value) {
|
||||
controller.autoConnect.value = value;
|
||||
},
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() {
|
||||
final isBusy = controller.isBusy.value;
|
||||
final isConnected = NtripService.to.isConnected.value;
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
if (isConnected)
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed:
|
||||
isBusy ? null : controller.disconnect,
|
||||
icon: const Icon(Icons.link_off),
|
||||
label: const Text('Bontás'),
|
||||
),
|
||||
),
|
||||
if (isConnected) const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: FilledButton.icon(
|
||||
onPressed:
|
||||
isBusy ? null : controller.saveAndConnect,
|
||||
icon: isBusy
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.play_arrow),
|
||||
label: Text(
|
||||
isBusy
|
||||
? 'Kapcsolódás...'
|
||||
: 'Mentés és kapcsolódás',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
await controller.saveSettings();
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('Csak mentés'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
class ShellController extends GetxController {
|
||||
static ShellController get to => Get.find();
|
||||
|
||||
final currentIndex = 0.obs;
|
||||
final currentIndex = 1.obs;
|
||||
final isNavBarVisible = true.obs;
|
||||
|
||||
static const titles = [
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:terepi_seged/pages/home/presentation/views/home_view.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
||||
import 'package:terepi_seged/services/ntrip_service.dart';
|
||||
import 'package:terepi_seged/widgets/gnss_status_chip.dart';
|
||||
import 'package:terepi_seged/widgets/shell_adaptive_appbar.dart';
|
||||
import 'package:terepi_seged/widgets/shell_map_appbar.dart';
|
||||
|
||||
import '../../../../widgets/app_drawer.dart';
|
||||
import '../../../map_survey/presentations/views/map_survey_view.dart';
|
||||
@@ -22,63 +24,36 @@ class ShellView extends GetView<ShellController> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mapController = Get.find<MapSurveyController>();
|
||||
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: false,
|
||||
appBar: AppBar(
|
||||
// Cím reaktívan frissül tab váltáskor
|
||||
title: Obx(() => Text(controller.currentTitle)),
|
||||
actions: [
|
||||
const GnssStatusChip(),
|
||||
const SizedBox(width: 6),
|
||||
Obx(() => controller.currentIndex.value == 1
|
||||
? NtripStatusChip(
|
||||
isConnected: NtripService.to.isConnected,
|
||||
onToggle: () {
|
||||
NtripService.to.isConnected.value
|
||||
? NtripService.to.disconnect()
|
||||
: NtripService.to.connect();
|
||||
},
|
||||
)
|
||||
: const SizedBox.shrink())
|
||||
],
|
||||
),
|
||||
// extendBody: true,
|
||||
// extendBodyBehindAppBar: false,
|
||||
resizeToAvoidBottomInset: true,
|
||||
appBar: ShellMapAppBar(controller: mapController),
|
||||
// appBar: AppBar(
|
||||
// // Cím reaktívan frissül tab váltáskor
|
||||
// title: Obx(() => Text(controller.currentTitle)),
|
||||
// actions: [
|
||||
// const GnssStatusChip(),
|
||||
// const SizedBox(width: 6),
|
||||
// Obx(() => controller.currentIndex.value == 1
|
||||
// ? NtripStatusChip(
|
||||
// isConnected: NtripService.to.isConnected,
|
||||
// onToggle: () {
|
||||
// NtripService.to.isConnected.value
|
||||
// ? NtripService.to.disconnect()
|
||||
// : NtripService.to.connect();
|
||||
// },
|
||||
// )
|
||||
// : const SizedBox.shrink())
|
||||
// ],
|
||||
// ),
|
||||
drawer: const AppDrawer(),
|
||||
body: Obx(() => IndexedStack(
|
||||
index: controller.currentIndex.value,
|
||||
children: _pages,
|
||||
)),
|
||||
bottomNavigationBar: Obx(
|
||||
() => AnimatedSize(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeInOut,
|
||||
child: controller.isNavBarVisible.value
|
||||
? NavigationBar(
|
||||
selectedIndex: controller.currentIndex.value,
|
||||
onDestinationSelected: controller.goToTab,
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.map_outlined),
|
||||
selectedIcon: Icon(Icons.map),
|
||||
label: 'Térkép',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.gps_fixed),
|
||||
label: 'Mérés',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.route),
|
||||
label: 'Track',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.table_chart_outlined),
|
||||
selectedIcon: Icon(Icons.table_chart),
|
||||
label: 'Adatok',
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user