Skip to content

Commit

Permalink
Bugfixes introduced up to 0.2.2 (Part 2) (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Oct 13, 2023
1 parent 2b6c7df commit e4482b0
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 94 deletions.
1 change: 0 additions & 1 deletion lib/base/helpers/fullscreen_image_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:campus_flutter/navigaTumComponent/model/navigatum_roomfinder_map
import 'package:campus_flutter/theme.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class ImageFullScreenScaffold extends StatelessWidget {
factory ImageFullScreenScaffold.network(
Expand Down
50 changes: 29 additions & 21 deletions lib/base/helpers/hyperlink_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class HyperLinkText extends ConsumerStatefulWidget {
const HyperLinkText({super.key, this.link, this.uri, required this.label});
class HyperLinkListTile extends ConsumerStatefulWidget {
const HyperLinkListTile(
{super.key,
this.link,
this.uri,
required this.label,
this.dense = false});

final String? link;
final Uri? uri;
final String label;
final bool dense;

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

class _HyperlinkTextState extends ConsumerState<HyperLinkText> {
class _HyperlinkTextState extends ConsumerState<HyperLinkListTile> {
late TapGestureRecognizer tapGestureRecognizer;

@override
Expand All @@ -31,23 +37,25 @@ class _HyperlinkTextState extends ConsumerState<HyperLinkText> {

@override
Widget build(BuildContext context) {
return Row(
children: [
RichText(
text: TextSpan(
text: widget.label,
style: Theme.of(context).textTheme.bodyMedium,
recognizer: tapGestureRecognizer
..onTap = () {
if (widget.link != null) {
UrlLauncher.urlString(widget.link!, ref);
} else if (widget.uri != null) {
UrlLauncher.url(widget.uri!, ref);
}
})),
const Padding(padding: EdgeInsets.symmetric(horizontal: 2.0)),
const Icon(Icons.open_in_new, size: 15 /*, color: Colors.blue*/)
],
);
return ListTile(
dense: widget.dense,
title: Row(
children: [
RichText(
text: TextSpan(
text: widget.label,
style: Theme.of(context).textTheme.bodyMedium,
)),
const Padding(padding: EdgeInsets.symmetric(horizontal: 2.0)),
const Icon(Icons.open_in_new, size: 15 /*, color: Colors.blue*/)
],
),
onTap: () {
if (widget.link != null) {
UrlLauncher.urlString(widget.link!, ref);
} else if (widget.uri != null) {
UrlLauncher.url(widget.uri!, ref);
}
});
}
}
37 changes: 23 additions & 14 deletions lib/base/helpers/url_launcher.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
import 'dart:io';

import 'package:campus_flutter/providers_get_it.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

class UrlLauncher {
static urlString(String urlString, WidgetRef ref) async {
if (await canLaunchUrlString(urlString)) {
if (ref.read(useWebView) && Platform.isIOS) {
launchUrlString(urlString, mode: LaunchMode.inAppWebView).onError(
(error, stackTrace) => launchUrlString(urlString,
mode: LaunchMode.externalApplication));
} else {
launchUrlString(urlString, mode: LaunchMode.externalApplication);
if (kIsWeb) {
launchUrlString(urlString, mode: LaunchMode.platformDefault);
} else {
if (await canLaunchUrlString(urlString)) {
if (ref.read(useWebView) && Platform.isIOS) {
launchUrlString(urlString, mode: LaunchMode.inAppWebView).onError(
(error, stackTrace) => launchUrlString(urlString,
mode: LaunchMode.externalApplication));
} else {
launchUrlString(urlString, mode: LaunchMode.externalApplication);
}
}
}
}

static url(Uri url, WidgetRef ref) async {
if (await canLaunchUrl(url)) {
if (ref.read(useWebView) && Platform.isIOS) {
launchUrl(url, mode: LaunchMode.inAppWebView).onError(
(error, stackTrace) =>
launchUrl(url, mode: LaunchMode.externalApplication));
} else {
launchUrl(url, mode: LaunchMode.externalApplication);
if (kIsWeb) {
launchUrl(url, mode: LaunchMode.platformDefault);
} else {
if (await canLaunchUrl(url)) {
if (ref.read(useWebView) && Platform.isIOS) {
launchUrl(url, mode: LaunchMode.inAppWebView).onError(
(error, stackTrace) =>
launchUrl(url, mode: LaunchMode.externalApplication));
} else {
launchUrl(url, mode: LaunchMode.externalApplication);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/homeComponent/contactComponent/views/link_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:webview_flutter/webview_flutter.dart';
Expand Down Expand Up @@ -43,7 +44,7 @@ class LinkView extends ConsumerWidget {
}

void _launchUrl(String url, BuildContext context, WidgetRef ref) {
if (MediaQuery.orientationOf(context) == Orientation.portrait) {
if (MediaQuery.orientationOf(context) == Orientation.portrait || kIsWeb) {
UrlLauncher.urlString(url, ref);
} else {
final controller = WebViewController()
Expand Down
1 change: 0 additions & 1 deletion lib/lectureComponent/views/basic_lecture_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class BasicLectureInfoView extends ConsumerWidget {
BasicLectureInfoRowView(
information: lectureDetails.organisation,
iconData: Icons.import_contacts),
// TODO: person finder
if (lectureDetails.speaker != null)
BasicLectureInfoRowView(
information: lectureDetails.speaker!,
Expand Down
17 changes: 6 additions & 11 deletions lib/lectureComponent/views/detailed_lecture_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ class DetailedLectureInfoView extends StatelessWidget {
icon: Icons.info_outline_rounded,
title: context.localizations.detailedLectureInformation,
widgets: [
if (lectureDetails.courseContents != null) ...[
if (lectureDetails.courseContents != null)
DetailedLectureInfoRowView(
title: context.localizations.courseContents,
information: lectureDetails.courseContents!)
],
if (lectureDetails.courseObjective != null) ...[
const Divider(),
information: lectureDetails.courseContents!),
if (lectureDetails.courseObjective != null)
DetailedLectureInfoRowView(
title: context.localizations.courseObjective,
information: lectureDetails.courseObjective!)
],
if (lectureDetails.note != null) ...[
const Divider(),
information: lectureDetails.courseObjective!),
if (lectureDetails.note != null)
DetailedLectureInfoRowView(
title: context.localizations.note,
information: lectureDetails.note!)
],
information: lectureDetails.note!),
],
);
}
Expand Down
10 changes: 8 additions & 2 deletions lib/lectureComponent/views/lecture_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ class _LectureDetailsViewState extends ConsumerState<LectureDetailsView> {
if (ref.read(viewModel).event != null)
LectureMeetingInfoView(viewModel: viewModel),
BasicLectureInfoView(lectureDetails: lectureDetails),
DetailedLectureInfoView(lectureDetails: lectureDetails),
LectureLinksView(lectureDetails: lectureDetails)
if (lectureDetails.courseContents != null ||
lectureDetails.courseObjective != null ||
lectureDetails.note != null)
DetailedLectureInfoView(lectureDetails: lectureDetails),
if (lectureDetails.curriculumURL != null ||
lectureDetails.scheduledDatesURL != null ||
lectureDetails.examDateURL != null)
LectureLinksView(lectureDetails: lectureDetails)
];
}
}
25 changes: 12 additions & 13 deletions lib/lectureComponent/views/lecture_links_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ class LectureLinksView extends StatelessWidget {
title: context.localizations.lectureLinks,
widgets: [
if (lectureDetails.curriculumURL != null)
_entry(lectureDetails.curriculumURL,
context.localizations.lectureCurriculum),
HyperLinkListTile(
dense: true,
link: lectureDetails.curriculumURL,
label: context.localizations.lectureCurriculum),
if (lectureDetails.scheduledDatesURL != null)
_entry(lectureDetails.scheduledDatesURL,
context.localizations.scheduledLectureDates),
HyperLinkListTile(
dense: true,
link: lectureDetails.scheduledDatesURL,
label: context.localizations.scheduledLectureDates),
if (lectureDetails.examDateURL != null)
_entry(lectureDetails.examDateURL,
context.localizations.lectureExamDate),
HyperLinkListTile(
dense: true,
link: lectureDetails.examDateURL,
label: context.localizations.lectureExamDate),
],
);
}

Widget _entry(String? url, String label) {
return ListTile(
dense: true,
title: HyperLinkText(link: url ?? "", label: label),
);
}
}
1 change: 0 additions & 1 deletion lib/placesComponent/viewModels/study_rooms_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class StudyRoomsViewModel {
.map((e) => Marker(
markerId: MarkerId(const Uuid().v4()),
position: LatLng(e.coordinate!.latitude, e.coordinate!.longitude),
icon: BitmapDescriptor.defaultMarkerWithHue(208),
infoWindow: InfoWindow(
title: e.name ?? "Unknown",
onTap: () {
Expand Down
6 changes: 3 additions & 3 deletions lib/placesComponent/views/cafeterias/cafeterias_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _CafeteriasState extends ConsumerState<CafeteriasView> {
top: context.halfPadding,
bottom: context.padding),
markers:
ref.read(studyRoomsViewModel).mapMakers(context)),
ref.read(cafeteriasViewModel).mapMakers(context)),
),
Expanded(
child: SingleChildScrollView(
Expand All @@ -73,7 +73,7 @@ class _CafeteriasState extends ConsumerState<CafeteriasView> {
child: Column(
children: [
MapWidget.horizontalPadding(
markers: ref.read(studyRoomsViewModel).mapMakers(context),
markers: ref.read(cafeteriasViewModel).mapMakers(context),
),
const PaddedDivider(),
_cafeteriaList(cafeterias, true)
Expand All @@ -85,7 +85,7 @@ class _CafeteriasState extends ConsumerState<CafeteriasView> {
return ErrorHandlingView(
error: snapshot.error!,
errorHandlingViewType: ErrorHandlingViewType.fullScreen,
retry: ref.read(studyRoomsViewModel).fetch,
retry: ref.read(cafeteriasViewModel).fetch,
);
} else {
return DelayedLoadingIndicator(
Expand Down
41 changes: 15 additions & 26 deletions lib/settingsComponent/views/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:campus_flutter/base/enums/appearance.dart';
import 'package:campus_flutter/base/extensions/locale+fullname.dart';
import 'package:campus_flutter/base/helpers/hyperlink_text.dart';
import 'package:campus_flutter/base/helpers/icon_text.dart';
import 'package:campus_flutter/base/helpers/padded_divider.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/loginComponent/viewModels/login_viewmodel.dart';
Expand Down Expand Up @@ -166,33 +165,23 @@ class SettingsView extends ConsumerWidget {
return WidgetFrameView(
title: context.localizations.contactUs,
child: Card(
child: Column(
children: [
child: SeparatedList.widgets(
widgets: [
if (!kIsWeb)
ListTile(
HyperLinkListTile(
dense: true,
link: _betaTester(),
label: context.localizations.becomeABetaTester),
HyperLinkListTile(
dense: true,
title: HyperLinkText(
link: _betaTester(),
label: context.localizations.becomeABetaTester),
),
const PaddedDivider(height: 0),
ListTile(
dense: true,
title: HyperLinkText(
link: "https://github.com/TUM-Dev",
label: context.localizations.usOnGitHub),
),
const PaddedDivider(height: 0),
const ListTile(
dense: true,
title: HyperLinkText(
link: "https://app.tum.de", label: "TUM Dev Website"),
),
const PaddedDivider(height: 0),
ListTile(
dense: true,
title: HyperLinkText(uri: _feedbackEmail(), label: "Feedback"),
),
link: "https://github.com/TUM-Dev",
label: context.localizations.usOnGitHub),
const HyperLinkListTile(
dense: true,
link: "https://app.tum.de",
label: "TUM Dev Website"),
HyperLinkListTile(
dense: true, uri: _feedbackEmail(), label: "Feedback"),
],
)));
}
Expand Down

0 comments on commit e4482b0

Please sign in to comment.