Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Links in Lecture Details clickable #170

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/base/views/seperated_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,52 @@ class SeparatedList<T> extends StatelessWidget {
factory SeparatedList.list({
required List<T> data,
required Widget Function(T) tile,
CrossAxisAlignment? crossAxisAlignment,
bool padded = true,
}) {
return SeparatedList._(
data: data,
tile: tile,
crossAxisAlignment: crossAxisAlignment,
padded: padded,
);
}

factory SeparatedList.widgets({
required List<Widget> widgets,
CrossAxisAlignment? crossAxisAlignment,
bool padded = true,
}) {
return SeparatedList._(widgets: widgets, padded: padded, list: false);
return SeparatedList._(
widgets: widgets,
crossAxisAlignment: crossAxisAlignment,
padded: padded,
list: false,
);
}

const SeparatedList._({
super.key,
this.data,
this.widgets,
this.tile,
this.crossAxisAlignment,
this.padded = true,
this.list = true,
});

final List<T>? data;
final List<Widget>? widgets;
final Widget Function(T)? tile;
final CrossAxisAlignment? crossAxisAlignment;
final bool padded;
final bool list;

@override
Widget build(BuildContext context) {
if (list) {
return Column(
crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center,
children: [
for (var dataPoint in data!.indexed) ...[
tile!(dataPoint.$2),
Expand All @@ -56,6 +67,7 @@ class SeparatedList<T> extends StatelessWidget {
);
} else {
return Column(
crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center,
children: [
for (var dataPoint in widgets!.indexed) ...[
widgets![dataPoint.$1],
Expand Down
12 changes: 9 additions & 3 deletions lib/lectureComponent/views/detailed_lecture_info_row_view.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:campus_flutter/base/helpers/url_launcher.dart';
import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class DetailedLectureInfoRowView extends StatelessWidget {
class DetailedLectureInfoRowView extends ConsumerWidget {
const DetailedLectureInfoRowView({
super.key,
required this.title,
Expand All @@ -12,7 +15,7 @@ class DetailedLectureInfoRowView extends StatelessWidget {
final String information;

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
return Padding(
padding: EdgeInsets.all(context.padding),
child: Column(
Expand All @@ -25,7 +28,10 @@ class DetailedLectureInfoRowView extends StatelessWidget {
.titleSmall
?.copyWith(fontWeight: FontWeight.bold),
),
Text(information.replaceAll(r'\\n', "\n").replaceAll(r'\t', "\t")),
Linkify(
text: information.replaceAll(r'\\n', "\n").replaceAll(r'\t', "\t"),
onOpen: (link) => UrlLauncher.urlString(link.url, ref),
),
],
),
);
Expand Down
5 changes: 4 additions & 1 deletion lib/lectureComponent/views/lecture_info_card_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class LectureInfoCardView extends StatelessWidget {
style: Theme.of(context).textTheme.titleMedium,
),
child: Card(
child: SeparatedList.widgets(widgets: widgets),
child: SeparatedList.widgets(
widgets: widgets,
crossAxisAlignment: CrossAxisAlignment.start,
),
),
);
}
Expand Down
52 changes: 34 additions & 18 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ packages:
dependency: transitive
description:
name: barcode
sha256: "789f898eef0bd88312470bdb2cc996f895ad7dd5f89e9adde84b204546a90b45"
sha256: "2a8b2ee065f419c2aeda141436cc556d91ae772d220fd80679f4d431d6c2ab43"
url: "https://pub.dev"
source: hosted
version: "2.2.4"
version: "2.2.5"
barcode_widget:
dependency: "direct main"
description:
Expand Down Expand Up @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: build_resolvers
sha256: "64e12b0521812d1684b1917bc80945625391cb9bdd4312536b1d69dcb6133ed8"
sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
version: "2.4.2"
build_runner:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -141,10 +141,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "69acb7007eb2a31dc901512bfe0f7b767168be34cb734835d54c070bfa74c1b2"
sha256: c9aabae0718ec394e5bc3c7272e6bb0dc0b32201a08fe185ec1d8401d3e39309
url: "https://pub.dev"
source: hosted
version: "8.8.0"
version: "8.8.1"
cached_network_image:
dependency: "direct main"
description:
Expand Down Expand Up @@ -197,10 +197,10 @@ packages:
dependency: transitive
description:
name: code_builder
sha256: b2151ce26a06171005b379ecff6e08d34c470180ffe16b8e14b6d52be292b55f
sha256: feee43a5c05e7b3199bb375a86430b8ada1b04104f2923d0e03cc01ca87b6d84
url: "https://pub.dev"
source: hosted
version: "4.8.0"
version: "4.9.0"
collection:
dependency: "direct main"
description:
Expand All @@ -221,10 +221,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76"
url: "https://pub.dev"
source: hosted
version: "1.7.1"
version: "1.7.2"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -374,6 +374,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.3.1"
flutter_linkify:
dependency: "direct main"
description:
name: flutter_linkify
sha256: "74669e06a8f358fee4512b4320c0b80e51cffc496607931de68d28f099254073"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -735,6 +743,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.7.1"
linkify:
dependency: transitive
description:
name: linkify
sha256: "4139ea77f4651ab9c315b577da2dd108d9aa0bd84b5d03d33323f1970c645832"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -1112,10 +1128,10 @@ packages:
dependency: transitive
description:
name: source_gen
sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.5.0"
source_helper:
dependency: transitive
description:
Expand Down Expand Up @@ -1360,10 +1376,10 @@ packages:
dependency: transitive
description:
name: url_launcher_linux
sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd"
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
url: "https://pub.dev"
source: hosted
version: "3.1.0"
version: "3.1.1"
url_launcher_macos:
dependency: transitive
description:
Expand Down Expand Up @@ -1392,18 +1408,18 @@ packages:
dependency: transitive
description:
name: url_launcher_windows
sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc"
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
url: "https://pub.dev"
source: hosted
version: "3.1.0"
version: "3.1.1"
uuid:
dependency: "direct main"
description:
name: uuid
sha256: df5a4d8f22ee4ccd77f8839ac7cb274ebc11ef9adcce8b92be14b797fe889921
sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
url: "https://pub.dev"
source: hosted
version: "4.2.1"
version: "4.2.2"
vector_graphics:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies:
collection: ^1.18.0
firebase_crashlytics: ^3.4.6
firebase_core: ^2.24.0
flutter_linkify: ^6.0.0

dependency_overrides:
xml2json:
Expand Down