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

View File

@@ -8,9 +8,6 @@ import 'app_localizations.dart';
class AppLocalizationsDe extends AppLocalizations {
AppLocalizationsDe([String locale = 'de']) : super(locale);
@override
String get homePageTitle => 'Wildtiermonitoring';
@override
String get addplace => 'Standort hinzufügen';
@@ -213,8 +210,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get locationDisabled => 'Standort ausgeschaltet. Bitte einschalten';
@override
String get locationForbidden =>
'Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben';
String get locationForbidden => 'Zugriff auf Standort verweigert. Es ist empfohlen dies zu erlauben';
@override
String get map => 'Karte';
@@ -250,7 +246,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get viewplaces => 'Standorte anzeigen';
@override
String get viewExcursionen => 'Excursionen anzeigen';
String get viewExcursionen => 'Exkursionen anzeigen';
@override
String get showloginscreen => 'Login-Bildschirm Anzeigen';
@@ -283,7 +279,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get placedata => 'Standortdaten';
@override
String get excursionData => 'Exursions daten';
String get excursionData => 'Exkursions daten';
@override
String get sent => 'Gesendet';
@@ -397,7 +393,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get vor46Tagen => 'vor 4/6 Tagen';
@override
String get vor1Woche => '=> 1 week';
String get vor1Woche => '=> 1 Woche';
@override
String get letzterNiederschlag => 'Letzter Niederschlag';
@@ -439,8 +435,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get gesLaengeAllerDokSpuren => 'Gesamte Länge aller dok. Spuren';
@override
String get maxAnzahlZusGefaehrdeterTiere =>
'Max. Anzahl zus. gefährdeter Tiere';
String get maxAnzahlZusGefaehrdeterTiere => 'Max. Anzahl zus. gefährdeter Tiere';
@override
String get sicher => 'Sicher';
@@ -491,18 +486,14 @@ class AppLocalizationsDe extends AppLocalizations {
String get tracking => 'Tracking';
@override
String get couldntDeterminePosition =>
'Position konnte nicht ermittelt werden';
String get couldntDeterminePosition => 'Position konnte nicht ermittelt werden';
@override
String get trackingRunningInBackground =>
'Die Tracking funktion läuft im Hintergrund';
String get trackingRunningInBackground => 'Die Tracking funktion läuft im Hintergrund';
@override
String get needsAlwaysLocation =>
'Diese app braucht die Standort berechtigung auf immer gesetzt';
String get needsAlwaysLocation => 'Diese app braucht die Standort berechtigung auf immer gesetzt';
@override
String get deleteWholeRouteBody =>
'Sind Sie sicher, dass die gesamte bisher gegangene Route gelöscht werden soll?';
String get deleteWholeRouteBody => '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 {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get homePageTitle => 'wildlife monitoring';
@override
String get addplace => 'add Place';
@@ -213,8 +210,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get locationDisabled => 'Location Disabled. Please enable it';
@override
String get locationForbidden =>
'Location forbidden. It is recommended to allow it';
String get locationForbidden => 'Location forbidden. It is recommended to allow it';
@override
String get map => 'Map';
@@ -439,8 +435,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get gesLaengeAllerDokSpuren => 'Total length of documentad tracks';
@override
String get maxAnzahlZusGefaehrdeterTiere =>
'Max count of additonal dangered animals';
String get maxAnzahlZusGefaehrdeterTiere => 'Max count of additonal dangered animals';
@override
String get sicher => 'Certain';
@@ -494,14 +489,11 @@ class AppLocalizationsEn extends AppLocalizations {
String get couldntDeterminePosition => 'couldn\'t determine position';
@override
String get trackingRunningInBackground =>
'The tracking service is running in the background';
String get trackingRunningInBackground => 'The tracking service is running in the background';
@override
String get needsAlwaysLocation =>
'This app needs the location permission set to always';
String get needsAlwaysLocation => 'This app needs the location permission set to always';
@override
String get deleteWholeRouteBody =>
'Do you really want to delete the existing route?';
String get deleteWholeRouteBody => 'Do you really want to delete the existing route?';
}

View File

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