Skip to content

Commit

Permalink
UI improvements (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Oct 11, 2023
1 parent c306ac6 commit ade4b99
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 263 deletions.
2 changes: 1 addition & 1 deletion lib/base/localization/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"comingSoon":"demnächst verfügbar",
"appearance":"Darstellung",
"language":"Sprache",
"brightness":"Helligkeit",
"theme":"Theme",
"useWebView":"Web-Ansicht verwenden",
"hideFailedGrades":"Durchgefallene Noten ausblenden",
"defaultMapsApplication":"Standard-Kartenanwendung",
Expand Down
2 changes: 1 addition & 1 deletion lib/base/localization/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"comingSoon":"Coming Soon",
"language":"Language",
"appearance":"Appearance",
"brightness":"Brightness",
"theme":"Theme",
"useWebView":"Use Web View",
"hideFailedGrades":"Hide Failed Grades",
"defaultMapsApplication":"Default Maps Application",
Expand Down
103 changes: 42 additions & 61 deletions lib/homeComponent/contactComponent/views/link_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:campus_flutter/base/helpers/icon_text.dart';
import 'package:campus_flutter/providers_get_it.dart';
import 'package:campus_flutter/base/helpers/url_launcher.dart';
import 'package:campus_flutter/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:webview_flutter/webview_flutter.dart';
Expand All @@ -13,68 +13,49 @@ class LinkView extends ConsumerWidget {
return Row(
children: [
Expanded(
child: SizedBox(
height: MediaQuery.sizeOf(context).height * 0.08,
child: GestureDetector(
onTap: () async {
if (MediaQuery.orientationOf(context) ==
Orientation.portrait) {
UrlLauncher.urlString("https://moodle.tum.de", ref);
} else {
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (request) =>
NavigationDecision.navigate))
..loadRequest(Uri.parse("https://moodle.tum.de"));
ref
.read(homeSplitViewModel)
.selectedWidget
.add(WebViewWidget(controller: controller));
}
},
child: const Card(
margin: EdgeInsets.only(
right: 5.0, top: 5.0, bottom: 5.0, left: 15.0),
child: Center(
child: IconText(
iconData: Icons.school_outlined,
label: "Moodle",
iconSize: 24,
)))))),
child: Card(
margin: EdgeInsets.only(
right: context.halfPadding,
top: context.halfPadding,
bottom: context.halfPadding,
left: context.padding),
child: ListTile(
leading: const Icon(Icons.school),
title: const Center(child: Text("Moodle")),
onTap: () => _launchUrl("https://moodle.tum.de", context, ref),
),
)),
Expanded(
child: SizedBox(
height: MediaQuery.sizeOf(context).height * 0.08,
child: GestureDetector(
onTap: () async {
if (MediaQuery.orientationOf(context) ==
Orientation.portrait) {
UrlLauncher.urlString("https://campus.tum.de", ref);
} else {
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (request) =>
NavigationDecision.navigate))
..loadRequest(Uri.parse("https://campus.tum.de"));
ref
.read(homeSplitViewModel)
.selectedWidget
.add(WebViewWidget(controller: controller));
}
},
child: const Card(
margin: EdgeInsets.only(
right: 15.0, top: 5.0, bottom: 5.0, left: 5.0),
child: Center(
child: IconText(
iconData: Icons.language_outlined,
label: "TUMOnline",
iconSize: 24,
))))))
child: Card(
margin: EdgeInsets.only(
right: context.padding,
top: context.halfPadding,
bottom: context.halfPadding,
left: context.halfPadding),
child: ListTile(
leading: const Icon(Icons.person),
title: const Center(child: Text("TUMonline")),
onTap: () => _launchUrl("https://campus.tum.de", context, ref),
),
)),
],
);
}

void _launchUrl(String url, BuildContext context, WidgetRef ref) {
if (MediaQuery.orientationOf(context) == Orientation.portrait) {
UrlLauncher.urlString(url, ref);
} else {
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(const Color(0x00000000))
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (request) => NavigationDecision.navigate))
..loadRequest(Uri.parse(url));
ref
.read(homeSplitViewModel)
.selectedWidget
.add(WebViewWidget(controller: controller));
}
}
}
42 changes: 19 additions & 23 deletions lib/homeComponent/contactComponent/views/tuition_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:campus_flutter/base/helpers/card_with_padding.dart';
import 'package:campus_flutter/base/helpers/delayed_loading_indicator.dart';
import 'package:campus_flutter/base/helpers/icon_text.dart';
import 'package:campus_flutter/profileComponent/model/tuition.dart';
Expand All @@ -16,25 +15,13 @@ class TuitionView extends ConsumerWidget {
return StreamBuilder(
stream: ref.watch(profileViewModel).tuition,
builder: (context, snapshot) {
return SizedBox(
height: MediaQuery.sizeOf(context).height * 0.08,
child: GestureDetector(
onTap: () {
(snapshot.hasData && snapshot.data != null)
? _alertDialog(context, snapshot)
: {};
},
child: CardWithPadding(
child: Row(mainAxisSize: MainAxisSize.min, children: [
const Padding(
padding: EdgeInsets.only(right: 10.0),
child: Icon(Icons.euro),
),
Text(context.localizations.tuitionFees),
const Spacer(),
_tuitionStatus(context, snapshot)
])),
));
return Card(
child: ListTile(
leading: const Icon(Icons.euro),
title: Text(context.localizations.tuitionFees),
trailing: _tuitionStatus(context, snapshot),
onTap: () => _alertDialog(context, snapshot),
));
});
}

Expand Down Expand Up @@ -81,21 +68,30 @@ class TuitionView extends ConsumerWidget {
return IconText(
iconData: Icons.check,
label: context.localizations.tuitionPaid,
style: const TextStyle(color: Colors.green),
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: Colors.green),
leadingIcon: false,
);
} else {
final numberFormat =
NumberFormat.currency(locale: "de_DE", symbol: "€");
return Text(numberFormat.format(snapshot.data?.amount),
style: const TextStyle(color: Colors.red));
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: Colors.red));
}
} else {
return DelayedLoadingIndicator(
name: context.localizations.tuition,
alternativeLoadingIndicator: Text(
context.localizations.notAvailableAbbrev,
style: const TextStyle(color: Colors.red)));
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: Colors.red)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:campus_flutter/base/helpers/delayed_loading_indicator.dart';
import 'package:campus_flutter/base/helpers/icon_text.dart';
import 'package:campus_flutter/base/helpers/padded_divider.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart';
import 'package:campus_flutter/providers_get_it.dart';
Expand Down Expand Up @@ -31,14 +30,7 @@ class CampusMostSearchedView extends ConsumerWidget {
children: [
for (var entity in snapshot.data!.indexed) ...[
ListTile(
title: IconText(
iconData: Icons.school,
label: entity.$2.getFormattedName(),
style: Theme.of(context).textTheme.bodyMedium,
multipleLines: true,
iconSize: 15,
iconColor: Theme.of(context).primaryColor,
),
title: Text(entity.$2.getFormattedName()),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 15,
Expand Down
4 changes: 1 addition & 3 deletions lib/placesComponent/views/campuses/campus_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:campus_flutter/base/enums/campus.dart';
import 'package:campus_flutter/base/helpers/card_with_padding.dart';
import 'package:campus_flutter/base/views/seperated_list.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart';
import 'package:campus_flutter/placesComponent/model/cafeterias/cafeteria.dart';
Expand Down Expand Up @@ -122,8 +121,7 @@ class _CampusViewState extends ConsumerState<CampusView> {
if (cafeterias.isNotEmpty)
WidgetFrameView(
title: context.localizations.cafeterias,
child: CardWithPadding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Card(
child: SeparatedList.list(
data: cafeterias,
tile: (cafeteria) =>
Expand Down
42 changes: 21 additions & 21 deletions lib/placesComponent/views/homeWidget/study_room_widget_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:campus_flutter/base/helpers/card_with_padding.dart';
import 'package:campus_flutter/base/helpers/delayed_loading_indicator.dart';
import 'package:campus_flutter/base/views/error_handling_view.dart';
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart';
Expand Down Expand Up @@ -71,10 +70,9 @@ class _StudyRoomWidgetViewState extends ConsumerState<StudyRoomWidgetView> {
context);
}
},
child: CardWithPadding.constrained(
boxConstraints: BoxConstraints(
minHeight: MediaQuery.sizeOf(context).height * 0.08),
child: _widgetLabel(snapshot, context)));
child: widget.closestStudyRoom
? Card(child: _widgetLabel(snapshot, context))
: _widgetLabel(snapshot, context));
});
}

Expand All @@ -92,16 +90,20 @@ class _StudyRoomWidgetViewState extends ConsumerState<StudyRoomWidgetView> {
(element) => element.id == widget.studyRoomGroup!.id),
context);
} else {
return Center(
child: Text(context.localizations.noNearFreeStudyRoomsFound));
return ListTile(
title: Center(
child: Text(context.localizations.noNearFreeStudyRoomsFound)),
);
}
} else if (snapshot.hasError) {
return ErrorHandlingView(
error: snapshot.error!,
errorHandlingViewType: ErrorHandlingViewType.descriptionOnly);
return ListTile(
title: ErrorHandlingView(
error: snapshot.error!,
errorHandlingViewType: ErrorHandlingViewType.descriptionOnly));
} else {
return DelayedLoadingIndicator(
name: context.localizations.nearestStudyRooms);
return ListTile(
title: DelayedLoadingIndicator(
name: context.localizations.nearestStudyRooms));
}
}

Expand All @@ -119,15 +121,13 @@ class _StudyRoomWidgetViewState extends ConsumerState<StudyRoomWidgetView> {
}

Widget _buttonLabel(StudyRoomGroup studyRoomGroup, BuildContext context) {
return Row(
children: [
Expanded(
child: Text(studyRoomGroup.name ?? context.localizations.unknown)),
const Padding(padding: EdgeInsets.symmetric(horizontal: 5.0)),
_freeRooms(studyRoomGroup),
const Padding(padding: EdgeInsets.symmetric(horizontal: 5.0)),
const Icon(Icons.arrow_forward_ios, size: 15)
],
return ListTile(
title: Text(studyRoomGroup.name ?? context.localizations.unknown),
subtitle: _freeRooms(studyRoomGroup),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 15,
),
);
}

Expand Down
Loading

0 comments on commit ade4b99

Please sign in to comment.