Skip to content

Commit

Permalink
User Interface Enhancements (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Mar 18, 2024
1 parent 8ea0d32 commit ae0b818
Show file tree
Hide file tree
Showing 29 changed files with 379 additions and 447 deletions.
17 changes: 14 additions & 3 deletions ios/CalendarWidget/CalendarWidgetContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ struct CalendarWidgetContent: View {
var updatedAt: Date

init(entry: CalendarWidgetEntry) {
self.availableItems = entry.size == .systemLarge ? 5 : 2
self.widgetFamily = entry.size
self.updatedAt = entry.date
self.events = groupEntriesByDate(entries: Array(entry.entries.prefix(availableItems)))
self.availableItems = CalendarWidgetContent.getAvailableItems(widgetFamily: entry.size)
self.events = CalendarWidgetContent.groupEntriesByDate(entries: Array(entry.entries.prefix(availableItems)))
}

private var dateFormatter: DateFormatter {
Expand Down Expand Up @@ -68,7 +68,7 @@ struct CalendarWidgetContent: View {
}
}

func groupEntriesByDate(entries: [CalendarEntry]) -> [Date: [CalendarEntry]] {
static func groupEntriesByDate(entries: [CalendarEntry]) -> [Date: [CalendarEntry]] {
var groupedEntries: [Date: [CalendarEntry]] = [:]

for entry in entries {
Expand All @@ -85,4 +85,15 @@ struct CalendarWidgetContent: View {
}
return groupedEntries
}

static func getAvailableItems(widgetFamily: WidgetFamily) -> Int {
switch widgetFamily {
case .systemSmall, .systemMedium:
return 2
case .systemLarge, .systemExtraLarge:
return 5
default:
return 2
}
}
}
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ SPEC CHECKSUMS:
FirebaseInstallations: 763814908793c0da14c18b3dcffdec71e29ed55e
FirebaseSessions: cd97fb07674f3906619c871eefbd260a1546c9d3
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
geolocator_apple: 9157311f654584b9bb72686c55fc02a97b73f461
geolocator_apple: 6cbaf322953988e009e5ecb481f07efece75c450
google_maps_flutter_ios: d9b9a308a1f14275c2967aefa639018a02bd44e8
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleMaps: 8939898920281c649150e0af74aa291c60f2e77d
Expand All @@ -210,7 +210,7 @@ SPEC CHECKSUMS:
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 036b856153a2b1f61f21030ff725f3e6fece2b78
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
quick_actions_ios: d24571db7345d2e48d094db8d077a015a568002d
Expand Down
8 changes: 4 additions & 4 deletions lib/base/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"settings":"Einstellungen",
"settingsAndFeedback":"Einstellungen & Feedback",
"generalSettings":"Allgemeine Einstellungen",
"comingSoon":"demnächst verfügbar",
"comingSoon":"Demnächst verfügbar",
"appearance":"Darstellung",
"language":"Sprache",
"theme":"Theme",
Expand All @@ -23,7 +23,7 @@
"logout":"Abmelden",
"login":"Anmelden",
"notLoggedIn":"Nicht angemeldet",
"welcomeToTheApp":"Willkommen in der\n TUM-Campus-App",
"welcomeToTheApp":"Willkommen in der\n TUM Campus App",
"enterYourIDToStart":"Gib deine TUM ID ein, um zu starten",
"continueWithoutID":"Ohne TUM ID fortfahren",
"unknown":"Unbekannt",
Expand Down Expand Up @@ -60,7 +60,7 @@
}
}
},
"checkToken":"Token überprüfen",
"checkToken":"Token prüfen",
"tryAgain":"Erneut versuchen",
"contactSupport":"Support kontaktieren",
"cafeteria":"Mensa",
Expand All @@ -83,7 +83,7 @@
"lectureLinks":"Veranstaltungslinks",
"thisMeeting":"Dieser Termin",
"lectureDetails":"Vorlesungsdetails",
"noLecturesSelected":"keine vorlesungen ausgewählt",
"noLecturesSelected":"Keine Vorlesungen ausgewählt",
"showDirections":"Wegbeschreibung anzeigen",
"notAvailableAbbrev":"n. v.",
"becomeABetaTester":"Werde Beta-Tester",
Expand Down
2 changes: 1 addition & 1 deletion lib/base/util/string_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class StringParser {
static String dateFormatter(DateTime dateTime, BuildContext context) {
return DateFormat(
DateFormat.YEAR_MONTH_DAY,
"de",
context.localizations.localeName,
).format(dateTime);
}

Expand Down
9 changes: 6 additions & 3 deletions lib/calendarComponent/model/calendar_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ class CalendarEvent extends Searchable {
}

String get timePeriod {
return "${DateFormat.Hm("de").format(startDate)} - ${DateFormat.Hm("de").format(endDate)}";
return "${DateFormat.Hm().format(startDate)} - ${DateFormat.Hm().format(endDate)}";
}

String _dateTimePeriod(BuildContext context) {
final start = DateFormat("EE, dd.MM.yyyy, HH:mm", "de").format(startDate);
final end = DateFormat("HH:mm", "de").format(endDate);
final start = DateFormat(
"EE, dd.MM.yyyy, HH:mm",
context.localizations.localeName,
).format(startDate);
final end = DateFormat("HH:mm").format(endDate);
return "$start - $end";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:campus_flutter/calendarComponent/model/calendar_event.dart';
import 'package:campus_flutter/calendarComponent/services/calendar_view_service.dart';
import 'package:campus_flutter/homeComponent/split_view_viewmodel.dart';
import 'package:campus_flutter/lectureComponent/views/lecture_details_view.dart';
import 'package:campus_flutter/main.dart';
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:flutter/material.dart';
Expand All @@ -15,10 +13,10 @@ class CalendarHomeWidgetEventView extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final String startTime = DateFormat(DateFormat.HOUR24_MINUTE, "de")
.format(calendarEvent.startDate);
final String endTime = DateFormat(DateFormat.HOUR24_MINUTE, "de")
.format(calendarEvent.endDate);
final String startTime =
DateFormat(DateFormat.HOUR24_MINUTE).format(calendarEvent.startDate);
final String endTime =
DateFormat(DateFormat.HOUR24_MINUTE).format(calendarEvent.endDate);
final DateTime today = DateTime.now();
final DateTime todayDate = DateTime(today.year, today.month, today.day);
final DateTime tomorrowDate = DateTime(today.year, today.month, today.day)
Expand All @@ -29,32 +27,23 @@ class CalendarHomeWidgetEventView extends ConsumerWidget {
calendarEvent.startDate.day,
);

return GestureDetector(
return InkWell(
onTap: () {
if (MediaQuery.orientationOf(context) == Orientation.portrait) {
getIt<CalendarViewService>()
.showDetails(null, calendarEvent, context, ref);
} else {
ref.read(homeSplitViewModel).selectedWidget.add(
LectureDetailsView(
event: calendarEvent,
),
);
}
getIt<CalendarViewService>()
.showDetails(null, calendarEvent, context, ref);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
//const Spacer(),
Text(
startDate.isAtSameMomentAs(todayDate)
? context.localizations.today
: startDate.isAtSameMomentAs(tomorrowDate)
? context.localizations.tomorrow
: DateFormat(
"EEEE, d. MMM",
"de",
context.localizations.localeName,
).format(calendarEvent.startDate),
style: TextStyle(color: Theme.of(context).colorScheme.secondary),
),
Expand Down Expand Up @@ -97,7 +86,6 @@ class CalendarHomeWidgetEventView extends ConsumerWidget {
),
),
),
//const Spacer()
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class _CalendarHomeWidgetView extends ConsumerState<CalendarHomeWidgetView> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
DateFormat.EEEE("de").format(today),
DateFormat.EEEE(context.localizations.localeName).format(today),
style: TextStyle(color: Theme.of(context).primaryColor),
),
Text(
DateFormat.MMMd("de").format(today),
DateFormat.MMMd(context.localizations.localeName).format(today),
style: Theme.of(context).textTheme.headlineSmall,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'package:campus_flutter/departuresComponent/model/departure.dart';
import 'package:campus_flutter/departuresComponent/model/station.dart';
import 'package:campus_flutter/departuresComponent/viewModel/departures_viewmodel.dart';
import 'package:campus_flutter/departuresComponent/views/departures_details_row_view.dart';
import 'package:campus_flutter/departuresComponent/views/departures_details_view.dart';
import 'package:campus_flutter/homeComponent/split_view_viewmodel.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/preference_selection_view.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart';
import 'package:campus_flutter/base/extensions/context.dart';
Expand Down Expand Up @@ -69,7 +67,7 @@ class _DeparturesHomeWidgetState extends ConsumerState<DeparturesHomeWidget> {
],
),
child: GestureDetector(
onTap: () => _onWidgetPressed(context),
onTap: () => context.push(departures),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height * 0.225,
Expand Down Expand Up @@ -153,16 +151,4 @@ class _DeparturesHomeWidgetState extends ConsumerState<DeparturesHomeWidget> {
],
);
}

_onWidgetPressed(BuildContext context) {
if (MediaQuery.orientationOf(context) == Orientation.portrait) {
context.push(departures);
} else {
ref.read(homeSplitViewModel).selectedWidget.add(
const DeparturesDetailsScaffold(
isSplitView: true,
),
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import 'package:campus_flutter/navigation_service.dart';
import 'package:campus_flutter/personDetailedComponent/model/person_details.dart';
import 'package:campus_flutter/personDetailedComponent/viewModel/person_details_viewmodel.dart';
import 'package:campus_flutter/profileComponent/model/profile.dart';
import 'package:campus_flutter/profileComponent/viewModel/profile_viewmodel.dart';
import 'package:campus_flutter/studentCardComponent/viewModel/student_card_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:campus_flutter/base/extensions/context.dart';

class ContactCardView extends ConsumerStatefulWidget {
const ContactCardView({super.key});
const ContactCardView({super.key, required this.profile});

final Profile profile;

@override
ConsumerState<ConsumerStatefulWidget> createState() =>
Expand All @@ -38,7 +39,7 @@ class _ContactCardViewState extends ConsumerState<ContactCardView> {
onTap: () => NavigationService.openStudentCardSheet(context),
child: contactInfo(
snapshot.data,
ref.read(profileViewModel).profile.value!,
widget.profile,
),
);
} else {
Expand Down
4 changes: 3 additions & 1 deletion lib/homeComponent/contactComponent/views/contact_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class _ContactScreenState extends ConsumerState<ContactScreen> {
child: CardWithPadding(
child: Center(
child: snapshot.hasData
? const ContactCardView()
? ContactCardView(
profile: snapshot.data!,
)
: snapshot.hasError
? const UnauthorizedView()
: Container(),
Expand Down
87 changes: 7 additions & 80 deletions lib/homeComponent/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:campus_flutter/base/util/padded_divider.dart';
import 'package:campus_flutter/homeComponent/contactComponent/views/contact_view.dart';
import 'package:campus_flutter/homeComponent/split_view_viewmodel.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand All @@ -24,7 +23,13 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
if (orientation == Orientation.portrait) {
return _widgetScrollView();
} else {
return const AnimatedSplitView();
return Row(
children: [
const Spacer(),
Expanded(flex: 2, child: _widgetScrollView()),
const Spacer(),
],
);
}
},
);
Expand All @@ -42,81 +47,3 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
@override
bool get wantKeepAlive => true;
}

class AnimatedSplitView extends ConsumerStatefulWidget {
const AnimatedSplitView({super.key});

@override
ConsumerState<ConsumerStatefulWidget> createState() =>
_AnimatedSplitViewState();
}

class _AnimatedSplitViewState extends ConsumerState<AnimatedSplitView>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
late Animation _animation;
final ScrollController scrollController = ScrollController();

@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 200),
vsync: this,
);
_animation = IntTween(begin: 0, end: 600).animate(_animationController);
_animation.addListener(() => setState(() {}));
}

@override
Widget build(BuildContext context) {
final double value = _animation.value / 2;
return StreamBuilder(
stream: ref.read(homeSplitViewModel).selectedWidget,
builder: (context, snapshot) {
if (snapshot.hasData) {
_animationController.forward();
} else if (!snapshot.hasData && _animationController.value != 0.0) {
_animationController.reverse();
}
return Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(flex: 250 - value.toInt(), child: Container()),
Expanded(flex: 500, child: _widgetScrollView()),
Expanded(flex: 250 - value.toInt(), child: Container()),
Expanded(
flex: _animation.value,
child: (snapshot.hasData && _animation.value == 600)
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconButton(
onPressed: () => ref
.read(homeSplitViewModel)
.selectedWidget
.add(null),
icon: const Icon(Icons.close),
),
Expanded(child: snapshot.data!),
],
)
: Container(),
),
],
),
);
},
);
}

Widget _widgetScrollView() {
return SingleChildScrollView(
controller: scrollController,
child: const Column(
children: [ContactScreen(), PaddedDivider(), WidgetScreen()],
),
);
}
}
10 changes: 0 additions & 10 deletions lib/homeComponent/split_view_viewmodel.dart

This file was deleted.

Loading

0 comments on commit ae0b818

Please sign in to comment.