added expansion panel

This commit is contained in:
Nico
2025-05-27 22:21:17 +02:00
parent 5733d4da75
commit 817b087ce3
4 changed files with 116 additions and 114 deletions

View File

@@ -62,8 +62,7 @@ import 'app_localizations_en.dart';
/// be consistent with the languages listed in the AppLocalizations.supportedLocales /// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property. /// property.
abstract class AppLocalizations { abstract class AppLocalizations {
AppLocalizations(String locale) AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName; final String localeName;
@@ -71,8 +70,7 @@ abstract class AppLocalizations {
return Localizations.of<AppLocalizations>(context, AppLocalizations); return Localizations.of<AppLocalizations>(context, AppLocalizations);
} }
static const LocalizationsDelegate<AppLocalizations> delegate = static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations /// A list of this localizations delegate along with the default localizations
/// delegates. /// delegates.
@@ -84,8 +82,7 @@ abstract class AppLocalizations {
/// Additional delegates can be added by appending to this list in /// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list /// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required. /// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
<LocalizationsDelegate<dynamic>>[
delegate, delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
@@ -98,12 +95,6 @@ abstract class AppLocalizations {
Locale('en') Locale('en')
]; ];
/// The title of the homepage
///
/// In en, this message translates to:
/// **'wildlife monitoring'**
String get homePageTitle;
/// Button to add a place /// Button to add a place
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@@ -1083,8 +1074,7 @@ abstract class AppLocalizations {
String get deleteWholeRouteBody; String get deleteWholeRouteBody;
} }
class _AppLocalizationsDelegate class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate(); const _AppLocalizationsDelegate();
@override @override
@@ -1093,25 +1083,25 @@ class _AppLocalizationsDelegate
} }
@override @override
bool isSupported(Locale locale) => bool isSupported(Locale locale) => <String>['de', 'en'].contains(locale.languageCode);
<String>['de', 'en'].contains(locale.languageCode);
@override @override
bool shouldReload(_AppLocalizationsDelegate old) => false; bool shouldReload(_AppLocalizationsDelegate old) => false;
} }
AppLocalizations lookupAppLocalizations(Locale locale) { AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified. // Lookup logic when only language code is specified.
switch (locale.languageCode) { switch (locale.languageCode) {
case 'de': case 'de': return AppLocalizationsDe();
return AppLocalizationsDe(); case 'en': return AppLocalizationsEn();
case 'en':
return AppLocalizationsEn();
} }
throw FlutterError( throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue ' 'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration ' 'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.'); 'that was used.'
);
} }

View File

@@ -8,9 +8,6 @@ import 'app_localizations.dart';
class AppLocalizationsDe extends AppLocalizations { class AppLocalizationsDe extends AppLocalizations {
AppLocalizationsDe([String locale = 'de']) : super(locale); AppLocalizationsDe([String locale = 'de']) : super(locale);
@override
String get homePageTitle => 'Wildtiermonitoring';
@override @override
String get addplace => 'Standort hinzufügen'; String get addplace => 'Standort hinzufügen';
@@ -213,8 +210,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get locationDisabled => 'Standort ausgeschaltet. Bitte einschalten'; String get locationDisabled => 'Standort ausgeschaltet. Bitte einschalten';
@override @override
String get locationForbidden => String get locationForbidden => 'Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben';
'Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben';
@override @override
String get map => 'Karte'; String get map => 'Karte';
@@ -250,7 +246,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get viewplaces => 'Standorte anzeigen'; String get viewplaces => 'Standorte anzeigen';
@override @override
String get viewExcursionen => 'Excursionen anzeigen'; String get viewExcursionen => 'Exkursionen anzeigen';
@override @override
String get showloginscreen => 'Login-Bildschirm Anzeigen'; String get showloginscreen => 'Login-Bildschirm Anzeigen';
@@ -283,7 +279,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get placedata => 'Standortdaten'; String get placedata => 'Standortdaten';
@override @override
String get excursionData => 'Exursions daten'; String get excursionData => 'Exkursions daten';
@override @override
String get sent => 'Gesendet'; String get sent => 'Gesendet';
@@ -397,7 +393,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get vor46Tagen => 'vor 4/6 Tagen'; String get vor46Tagen => 'vor 4/6 Tagen';
@override @override
String get vor1Woche => '=> 1 week'; String get vor1Woche => '=> 1 Woche';
@override @override
String get letzterNiederschlag => 'Letzter Niederschlag'; String get letzterNiederschlag => 'Letzter Niederschlag';
@@ -439,8 +435,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get gesLaengeAllerDokSpuren => 'Gesamte Länge aller dok. Spuren'; String get gesLaengeAllerDokSpuren => 'Gesamte Länge aller dok. Spuren';
@override @override
String get maxAnzahlZusGefaehrdeterTiere => String get maxAnzahlZusGefaehrdeterTiere => 'Max. Anzahl zus. gefährdeter Tiere';
'Max. Anzahl zus. gefährdeter Tiere';
@override @override
String get sicher => 'Sicher'; String get sicher => 'Sicher';
@@ -491,18 +486,14 @@ class AppLocalizationsDe extends AppLocalizations {
String get tracking => 'Tracking'; String get tracking => 'Tracking';
@override @override
String get couldntDeterminePosition => String get couldntDeterminePosition => 'Position konnte nicht ermittelt werden';
'Position konnte nicht ermittelt werden';
@override @override
String get trackingRunningInBackground => String get trackingRunningInBackground => 'Die Tracking funktion läuft im Hintergrund';
'Die Tracking funktion läuft im Hintergrund';
@override @override
String get needsAlwaysLocation => String get needsAlwaysLocation => 'Diese app braucht die Standort berechtigung auf immer gesetzt';
'Diese app braucht die Standort berechtigung auf immer gesetzt';
@override @override
String get deleteWholeRouteBody => String get deleteWholeRouteBody => 'Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?';
'Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?';
} }

View File

@@ -8,9 +8,6 @@ import 'app_localizations.dart';
class AppLocalizationsEn extends AppLocalizations { class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale); AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get homePageTitle => 'wildlife monitoring';
@override @override
String get addplace => 'add Place'; String get addplace => 'add Place';
@@ -213,8 +210,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get locationDisabled => 'Location Disabled. Please enable it'; String get locationDisabled => 'Location Disabled. Please enable it';
@override @override
String get locationForbidden => String get locationForbidden => 'Location forbidden. It is recommended to allow it';
'Location forbidden. It is recommended to allow it';
@override @override
String get map => 'Map'; String get map => 'Map';
@@ -439,8 +435,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get gesLaengeAllerDokSpuren => 'Total length of documentad tracks'; String get gesLaengeAllerDokSpuren => 'Total length of documentad tracks';
@override @override
String get maxAnzahlZusGefaehrdeterTiere => String get maxAnzahlZusGefaehrdeterTiere => 'Max count of additonal dangered animals';
'Max count of additonal dangered animals';
@override @override
String get sicher => 'Certain'; String get sicher => 'Certain';
@@ -494,14 +489,11 @@ class AppLocalizationsEn extends AppLocalizations {
String get couldntDeterminePosition => 'couldn\'t determine position'; String get couldntDeterminePosition => 'couldn\'t determine position';
@override @override
String get trackingRunningInBackground => String get trackingRunningInBackground => 'The tracking service is running in the background';
'The tracking service is running in the background';
@override @override
String get needsAlwaysLocation => String get needsAlwaysLocation => 'This app needs the location permission set to always';
'This app needs the location permission set to always';
@override @override
String get deleteWholeRouteBody => String get deleteWholeRouteBody => 'Do you really want to delete the existing route?';
'Do you really want to delete the existing route?';
} }

View File

@@ -55,6 +55,8 @@ class _ExcursionMainState extends State<ExcursionMain> {
headingAccuracy: 0.0, headingAccuracy: 0.0,
); );
bool bimaExtended = false;
// all TextEditingController because its easier // all TextEditingController because its easier
Map<String, Map<String, dynamic>> rmap = { Map<String, Map<String, dynamic>> rmap = {
"ID": {"controller": TextEditingController(), "required": false}, "ID": {"controller": TextEditingController(), "required": false},
@@ -120,30 +122,30 @@ class _ExcursionMainState extends State<ExcursionMain> {
@override @override
void initState() { void initState() {
GeolocatorService.deteterminePosition(alwaysOnNeeded: true) GeolocatorService.deteterminePosition(
.then((result) => currentPosition = result) alwaysOnNeeded: true,
.catchError((error) { ).then((result) => currentPosition = result).catchError((error) {
if (error is LocationDisabledException) { if (error is LocationDisabledException) {
if (mounted) { if (mounted) {
SnackBarHelper.showSnackBarMessage( SnackBarHelper.showSnackBarMessage(
context, context,
AppLocalizations.of(context)!.locationDisabled, AppLocalizations.of(context)!.locationDisabled,
); );
} }
} else if (error is LocationForbiddenException) { } else if (error is LocationForbiddenException) {
if (mounted) { if (mounted) {
SnackBarHelper.showSnackBarMessage( SnackBarHelper.showSnackBarMessage(
context, context,
AppLocalizations.of(context)!.locationForbidden, AppLocalizations.of(context)!.locationForbidden,
); );
} }
} else if (error is NeedAlwaysLocation) { } else if (error is NeedAlwaysLocation) {
if (mounted) { if (mounted) {
AddEntriesDialogHelper.locationSettingsDialog(context); AddEntriesDialogHelper.locationSettingsDialog(context);
} }
} }
return currentPosition; return currentPosition;
}); });
if (widget.existingData?.isNotEmpty ?? false) { if (widget.existingData?.isNotEmpty ?? false) {
for (var key in widget.existingData!.keys) { for (var key in widget.existingData!.keys) {
@@ -260,41 +262,68 @@ class _ExcursionMainState extends State<ExcursionMain> {
const SizedBox(height: 10), const SizedBox(height: 10),
// ---------- Bima number // ---------- Bima number
const Divider(), const Divider(),
// TODO implement expensionpanel
const SizedBox(height: 10), const SizedBox(height: 10),
VarTextField(
textController: rmap["BimaNr"]!["controller"]!, ClipRRect(
localization: AppLocalizations.of(context)!.bimaNr, borderRadius: BorderRadius.all(Radius.circular(10)),
dbName: "BimaNr", child: ExpansionPanelList(
required: false, expansionCallback:
dbDesignation: DatabasesEnum.excursion, ((int index, bool isExpanded) =>
), setState(() => bimaExtended = isExpanded)),
const SizedBox(height: 10), expandedHeaderPadding: EdgeInsets.all(0),
// ---------- Bima name children: [
VarTextField( ExpansionPanel(
textController: rmap["BimaName"]!["controller"]!, isExpanded: bimaExtended,
localization: AppLocalizations.of(context)!.bimaName, canTapOnHeader: true,
dbName: "BimaName", headerBuilder: (context, bool isOpen) => Padding(
required: false, padding: const EdgeInsets.only(left: 15),
dbDesignation: DatabasesEnum.excursion, child: Align(alignment: Alignment.centerLeft, child: Text("BImA", style: Theme.of(context).textTheme.bodyLarge,),),
), ),
const SizedBox(height: 10), body: Padding(
// ---------- Bima user padding: const EdgeInsets.all(15),
BimaNutzer( child: Column(
onBimaNutzerChanged: (value) { children: [
setState(() { const SizedBox(height: 10),
rmap["BimaNutzer"]!["controller"]!.text = value; VarTextField(
}); textController: rmap["BimaNr"]!["controller"]!,
}, localization: AppLocalizations.of(context)!.bimaNr,
), dbName: "BimaNr",
const SizedBox(height: 10), required: false,
// ---------- Bima AGV dbDesignation: DatabasesEnum.excursion,
VarTextField( ),
textController: rmap["BimaAGV"]!["controller"]!, const SizedBox(height: 10),
localization: AppLocalizations.of(context)!.bimaAGV, // ---------- Bima name
dbName: "BimaAGV", VarTextField(
required: false, textController: rmap["BimaName"]!["controller"]!,
dbDesignation: DatabasesEnum.excursion, localization: AppLocalizations.of(context)!.bimaName,
dbName: "BimaName",
required: false,
dbDesignation: DatabasesEnum.excursion,
),
const SizedBox(height: 10),
// ---------- Bima user
BimaNutzer(
onBimaNutzerChanged: (value) {
setState(() {
rmap["BimaNutzer"]!["controller"]!.text = value;
});
},
),
const SizedBox(height: 10),
// ---------- Bima AGV
VarTextField(
textController: rmap["BimaAGV"]!["controller"]!,
localization: AppLocalizations.of(context)!.bimaAGV,
dbName: "BimaAGV",
required: false,
dbDesignation: DatabasesEnum.excursion,
),
],
),
),
),
],
),
), ),
], ],
), ),
@@ -475,7 +504,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
AddEntriesDialogHelper.showTemplateDialog( AddEntriesDialogHelper.showTemplateDialog(
context, context,
getFieldsText(), getFieldsText(),
DatabasesEnum.excursion DatabasesEnum.excursion,
); );
return; return;
} else if (!empty) { } else if (!empty) {