feat: Enhance SAR message handling with color indexing and localization

- Added `sarColorIndex` to `Message` and `SarMarker` models to support color indexing for SAR markers.
- Introduced a standard color palette in `SarTemplate` and methods to retrieve colors based on index.
- Updated `SarTemplate` to include localization for template names.
- Modified `SarUpdateSheet` and message sending logic to include color index in SAR messages.
- Enhanced `SarMessageParser` to support both old and new message formats with color index.
- Updated UI components to reflect changes in SAR marker color handling based on the new color index.
- Improved sample data generation to utilize localized strings for better testing and demonstration.
This commit is contained in:
Janez T
2025-10-23 19:17:13 +02:00
parent b70eed1bf2
commit 98cda8c976
28 changed files with 2734 additions and 270 deletions

View File

@@ -878,8 +878,8 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
builder: (context) => SarUpdateSheet(
prePopulatedPosition: position,
allowLocationUpdate: false, // Don't allow changing to current location
onSend: (emoji, name, position, roomPublicKey, sendToChannel) async {
await _sendSarMessage(emoji, name, position, roomPublicKey, sendToChannel);
onSend: (emoji, name, position, roomPublicKey, sendToChannel, colorIndex) async {
await _sendSarMessage(emoji, name, position, roomPublicKey, sendToChannel, colorIndex);
},
),
);
@@ -891,6 +891,7 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
Position position,
Uint8List? roomPublicKey,
bool sendToChannel,
int colorIndex,
) async {
final connectionProvider = context.read<ConnectionProvider>();
final messagesProvider = context.read<MessagesProvider>();
@@ -918,9 +919,9 @@ class _MapTabState extends State<MapTab> with AutomaticKeepAliveClientMixin {
}
try {
// Format: S:<emoji>:<latitude>,<longitude>:<name>
// New format: S:<emoji>:<colorIndex>:<latitude>,<longitude>:<name>
// Round coordinates to 5 decimal places (~1m accuracy) since most GPS is only that accurate
final sarMessage = 'S:$emoji:${position.latitude.toStringAsFixed(5)},${position.longitude.toStringAsFixed(5)}:$name';
final sarMessage = 'S:$emoji:$colorIndex:${position.latitude.toStringAsFixed(5)},${position.longitude.toStringAsFixed(5)}:$name';
if (sendToChannel) {
// Create message ID