feat: MeshCore SAR - Flutter BLE mesh radio companion app

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janez T
2026-02-28 10:11:33 +01:00
commit baf49d27d8
313 changed files with 101770 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// Service for managing locale preferences
class LocalePreferences {
static const String _localeKey = 'app_locale';
/// Supported locales
static const List<Locale> supportedLocales = [
Locale('en'), // English
Locale('sl'), // Slovenian
Locale('hr'), // Croatian
Locale('de'), // German
Locale('es'), // Spanish
Locale('fr'), // French
Locale('it'), // Italian
];
/// Get the saved locale or return null to use system locale
static Future<Locale?> getLocale() async {
final prefs = await SharedPreferences.getInstance();
final localeCode = prefs.getString(_localeKey);
if (localeCode == null) {
return null; // Use system locale
}
return Locale(localeCode);
}
/// Save the selected locale
static Future<void> setLocale(Locale? locale) async {
final prefs = await SharedPreferences.getInstance();
if (locale == null) {
// Remove preference to use system locale
await prefs.remove(_localeKey);
} else {
await prefs.setString(_localeKey, locale.languageCode);
}
}
/// Get display name for a locale
static String getDisplayName(Locale? locale) {
if (locale == null) {
return 'System Default';
}
switch (locale.languageCode) {
case 'en':
return 'English';
case 'sl':
return 'Slovenščina';
case 'hr':
return 'Hrvatski';
case 'de':
return 'Deutsch';
case 'es':
return 'Español';
case 'fr':
return 'Français';
case 'it':
return 'Italiano';
default:
return locale.languageCode;
}
}
/// Get native display name for a locale (shown in selection dialog)
static String getNativeDisplayName(Locale locale) {
switch (locale.languageCode) {
case 'en':
return 'English';
case 'sl':
return 'Slovenščina';
case 'hr':
return 'Hrvatski';
case 'de':
return 'Deutsch';
case 'es':
return 'Español';
case 'fr':
return 'Français';
case 'it':
return 'Italiano';
default:
return locale.languageCode;
}
}
}