feat: Add display name getter to DeviceInfo and update usage in HomeScreen; refactor contact type handling in MapMarkers

This commit is contained in:
Janez T
2025-10-14 11:18:59 +02:00
parent 373998bc7d
commit ccec842672
8 changed files with 1285 additions and 22 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,14 +2,13 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/connection_provider.dart';
import '../providers/app_provider.dart';
import '../models/device_info.dart' as models;
import '../services/tile_cache_service.dart';
import '../theme/app_theme.dart';
import 'messages_tab.dart';
import 'contacts_tab.dart';
import 'map_tab.dart';
import 'map_management_screen.dart';
import 'settings_screen.dart';
import 'device_config_screen.dart';
class HomeScreen extends StatefulWidget {
final Function(AppThemeMode) onThemeChanged;
@@ -352,7 +351,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
),
Text(
isConnected
? deviceInfo.deviceName ?? 'Connected'
? deviceInfo.displayName ?? 'Connected'
: 'Disconnected',
style: TextStyle(
fontSize: 14,
@@ -420,22 +419,42 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
),
),
const SizedBox(width: 12),
OutlinedButton(
// Settings button
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DeviceConfigScreen(),
),
);
},
icon: const Icon(Icons.settings),
iconSize: 20,
tooltip: 'Device Settings',
constraints: const BoxConstraints(
minWidth: 36,
minHeight: 36,
),
padding: EdgeInsets.zero,
),
const SizedBox(width: 8),
// Disconnect button (prominent, icon only)
FilledButton(
onPressed: () async {
await provider.disconnect();
if (context.mounted) {
context.read<AppProvider>().clearAllData();
}
},
style: OutlinedButton.styleFrom(
style: FilledButton.styleFrom(
backgroundColor: Colors.red.shade700,
foregroundColor: Colors.white,
side: const BorderSide(color: Colors.white),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
padding: const EdgeInsets.all(10),
minimumSize: const Size(40, 40),
shape: const CircleBorder(),
),
child: const Text('Disconnect', style: TextStyle(fontSize: 13)),
child: const Icon(Icons.power_settings_new, size: 20),
),
],
),
@@ -467,7 +486,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
Expanded(
child: Text(
isConnected
? deviceInfo.deviceName ?? 'Connected'
? deviceInfo.displayName ?? 'Connected'
: 'Not Connected',
style: Theme.of(context).textTheme.bodyMedium,
),

View File

@@ -687,7 +687,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
super.build(context); // Required for AutomaticKeepAliveClientMixin
return Consumer2<ContactsProvider, MessagesProvider>(
builder: (context, contactsProvider, messagesProvider, child) {
final contactsWithLocation = contactsProvider.chatContactsWithLocation;
final contactsWithLocation = contactsProvider.contactsWithLocation;
final sarMarkers = messagesProvider.sarMarkers;
final center = _calculateCenter(contactsWithLocation, sarMarkers);
@@ -729,7 +729,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
onContactTap: (contact) {
_showDetailedCompassWithContact(
context,
contactsProvider.chatContactsWithLocation,
contactsProvider.contactsWithLocation,
messagesProvider.sarMarkers,
contact,
);
@@ -742,7 +742,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
onSarMarkerTap: (marker) {
_showDetailedCompassWithSarMarker(
context,
contactsProvider.chatContactsWithLocation,
contactsProvider.contactsWithLocation,
messagesProvider.sarMarkers,
marker,
);
@@ -807,7 +807,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
child: GestureDetector(
onTap: () => _showDetailedCompass(
context,
contactsProvider.chatContactsWithLocation,
contactsProvider.contactsWithLocation,
messagesProvider.sarMarkers,
),
child: _CompassWidget(