Skip to content

Commit

Permalink
Fix User Interface Errors (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Mar 31, 2024
1 parent 53ff568 commit ff56645
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 98 deletions.
11 changes: 10 additions & 1 deletion lib/base/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"contactMore":"Kontakt & Mehr",
"tokenPermissions":"Berechtigungen für Token",
"permissionChangePossibleInTUMonline":"Du kannst deine Berechtigungen in TUMOnline ändern",
"logout":"Abmelden",
"login":"Anmelden",
"notLoggedIn":"Nicht angemeldet",
"welcomeToTheApp":"Willkommen in der\n TUM Campus App",
Expand Down Expand Up @@ -252,6 +251,16 @@
}
},
"closed":"Geschlossen",
"closedOn":"{day} geschlossen",
"@closedOn":{
"description":"Day",
"placeholders":{
"day":{
"type":"String",
"example":"Montag"
}
}
},
"closedToday":"Heute geschlossen",
"submitFeedback":"Feedback einreichen",
"yourEmailAddress":"Deine E-Mail-Adresse",
Expand Down
11 changes: 10 additions & 1 deletion lib/base/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"contactMore":"Contact & More",
"tokenPermissions":"Token Permissions",
"permissionChangePossibleInTUMonline":"You can change your permissions on TUMOnline",
"logout":"Logout",
"login":"Login",
"notLoggedIn":"Not Logged In",
"welcomeToTheApp":"Welcome to the TUM Campus App",
Expand Down Expand Up @@ -252,6 +251,16 @@
}
},
"closed":"Closed",
"closedOn":"Closed on {day}",
"@closedOn":{
"description":"Day",
"placeholders":{
"day":{
"type":"String",
"example":"Monday"
}
}
},
"closedToday":"Closed Today",
"submitFeedback":"Submit Feedback",
"yourEmailAddress":"Your Email Address",
Expand Down
18 changes: 16 additions & 2 deletions lib/base/util/places_util.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:campus_flutter/base/extensions/date_time.dart';
import 'package:campus_flutter/base/util/string_parser.dart';
import 'package:campus_flutter/placesComponent/model/cafeterias/opening_hours.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class PlacesUtil {
static Widget? openingHours(
(bool, OpeningHour?)? openingHours,
DateTime? dateTime,
BuildContext context,
) {
if (openingHours != null && dateTime != null) {
if (openingHours != null && !openingHours.$1 && dateTime != null) {
return Padding(
padding: EdgeInsets.only(left: context.padding),
child: Text(
dateTime.isAtSameDay(DateTime.now())
? context.localizations.closedToday
: context.localizations.closedOn(
DateFormat.EEEE(context.localizations.localeName)
.format(dateTime),
),
),
);
} else if (openingHours?.$2 != null && dateTime != null) {
final dayString = StringParser.getDayString(dateTime, context);
return Padding(
padding: EdgeInsets.only(left: context.padding),
child: Text(
context.localizations.open(
dayString,
openingHours.$2!.start,
openingHours!.$2!.start,
openingHours.$2!.end,
),
),
Expand Down
12 changes: 9 additions & 3 deletions lib/onboardingComponent/views/confirm_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,27 @@ class _ConfirmViewState extends ConsumerState<ConfirmView> {
value.compareTo(const Duration(seconds: 9, milliseconds: 2)) ==
-1) {
setState(() {
currentText = 1;
if (mounted) {
currentText = 1;
}
});
} else if (value
.compareTo(const Duration(seconds: 9, milliseconds: 3)) ==
1 &&
value.compareTo(const Duration(seconds: 16, milliseconds: 24)) ==
-1) {
setState(() {
currentText = 2;
if (mounted) {
currentText = 2;
}
});
} else if (value.compareTo(Duration.zero) == 1 &&
value.compareTo(const Duration(seconds: 5, milliseconds: 16)) ==
-1) {
setState(() {
currentText = 0;
if (mounted) {
currentText = 0;
}
});
}
}
Expand Down
22 changes: 0 additions & 22 deletions lib/placesComponent/model/cafeterias/dish_label.dart

This file was deleted.

19 changes: 0 additions & 19 deletions lib/placesComponent/model/cafeterias/dish_label.g.dart

This file was deleted.

5 changes: 1 addition & 4 deletions lib/placesComponent/viewModels/cafeterias_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:campus_flutter/base/enums/campus.dart';
import 'package:campus_flutter/base/enums/user_preference.dart';
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:campus_flutter/base/extensions/campus_exception.dart';
import 'package:campus_flutter/base/routing/routes.dart';
import 'package:campus_flutter/base/services/location_service.dart';
import 'package:campus_flutter/main.dart';
Expand Down Expand Up @@ -217,9 +216,7 @@ class CafeteriasViewModel {
) {
return MealPlanService.getCafeteriaMenu(forcedRefresh, cafeteria).then(
(response) => response.$2,
onError: (error) => Future<List<CafeteriaMenu>>.error(
CampusException("Unable to fetch meal plan"),
),
onError: (error) => error,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _CafeteriaWidgetViewState extends ConsumerState<CafeteriaWidgetView> {
),
subtitle: PlacesUtil.openingHours(
snapshot.data?.$1.openingHoursForDate(snapshot.data?.$2?.date),
snapshot.data?.$2!.date,
snapshot.data?.$2?.date,
context,
),
child: _dynamicContent(snapshot),
Expand Down
44 changes: 7 additions & 37 deletions lib/placesComponent/views/map_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,47 +96,12 @@ class MapWidget extends ConsumerStatefulWidget {
ConsumerState<ConsumerStatefulWidget> createState() => _MapWidgetState();
}

class _MapWidgetState extends ConsumerState<MapWidget>
with WidgetsBindingObserver {
class _MapWidgetState extends ConsumerState<MapWidget> {
final Completer<GoogleMapController> _controller =
Completer<GoogleMapController>();

bool isMapVisible = false;

@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_setMapStyle();
}

Future _setMapStyle({bool platformChanged = false}) async {
final controller = await _controller.future;
setBrightness(controller, platformChanged);
}

void setBrightness(GoogleMapController controller, bool platformChanged) {
final brightness = Theme.of(context).brightness;
if (brightness == (platformChanged ? Brightness.light : Brightness.dark)) {
controller.setMapStyle(getIt.get<MapThemeService>().darkTheme);
} else {
controller.setMapStyle(getIt.get<MapThemeService>().lightTheme);
}
}

@override
void didChangePlatformBrightness() {
setState(() {
_setMapStyle(platformChanged: true);
});
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
Widget build(BuildContext context) {
return Padding(
Expand Down Expand Up @@ -167,6 +132,9 @@ class _MapWidgetState extends ConsumerState<MapWidget>
opacity: isMapVisible ? 1.0 : 0.01,
duration: const Duration(milliseconds: 200),
child: GoogleMap(
style: Theme.of(context).brightness == Brightness.light
? getIt.get<MapThemeService>().lightTheme
: getIt.get<MapThemeService>().darkTheme,
mapType: MapType.normal,
padding: widget.controlPadding ?? EdgeInsets.zero,
initialCameraPosition: CameraPosition(
Expand All @@ -192,7 +160,9 @@ class _MapWidgetState extends ConsumerState<MapWidget>
Future.delayed(
const Duration(milliseconds: 250),
() => setState(() {
isMapVisible = true;
if (mounted) {
isMapVisible = true;
}
}),
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/settingsComponent/views/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SettingsView extends ConsumerWidget {
textAlign: TextAlign.center,
)
: Text(
context.localizations.logout,
context.localizations.reset,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.red,
fontWeight: FontWeight.w500,
Expand Down
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
url: "https://pub.dev"
source: hosted
version: "2.4.8"
version: "2.4.9"
build_runner_core:
dependency: transitive
description:
Expand Down Expand Up @@ -569,10 +569,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "7ecb2f391edbca5473db591b48555a8912dde60edd0fb3013bd6743033b2d3f8"
sha256: "5ed2687bc961f33a752017ccaa7edead3e5601b28b6376a5901bf24728556b85"
url: "https://pub.dev"
source: hosted
version: "13.2.1"
version: "13.2.2"
google_identity_services_web:
dependency: transitive
description:
Expand Down Expand Up @@ -610,7 +610,7 @@ packages:
description:
path: "packages/google_maps_flutter/google_maps_flutter_ios"
ref: main
resolved-ref: c13a2045826d0465e4014949c11582460072fc87
resolved-ref: "76ec0f6a67acefeff16dba1dcbd3ec7323ec7883"
url: "https://github.com/jakobkoerber/packages.git"
source: git
version: "2.5.2"
Expand Down Expand Up @@ -1672,10 +1672,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
sha256: "0a989dc7ca2bb51eac91e8fd00851297cfffd641aa7538b165c62637ca0eaa4a"
url: "https://pub.dev"
source: hosted
version: "5.3.0"
version: "5.4.0"
win32_registry:
dependency: transitive
description:
Expand Down

0 comments on commit ff56645

Please sign in to comment.