Skip to content

Commit

Permalink
Changing uc link to open in app page
Browse files Browse the repository at this point in the history
  • Loading branch information
adriannalmeida committed Nov 17, 2023
1 parent 018b108 commit 352c552
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions uni/lib/view/schedule/widgets/schedule_slot.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/providers/startup/profile_provider.dart';
import 'package:uni/view/common_widgets/row_container.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:uni/view/course_unit_info/course_unit_info.dart';

class ScheduleSlot extends StatelessWidget {
const ScheduleSlot({
Expand All @@ -16,6 +18,7 @@ class ScheduleSlot extends StatelessWidget {
this.classNumber,
super.key,
});

final String subject;
final String rooms;
final DateTime begin;
Expand Down Expand Up @@ -105,6 +108,7 @@ class ScheduleSlot extends StatelessWidget {

class SubjectButtonWidget extends StatelessWidget {
const SubjectButtonWidget({required this.occurrId, super.key});

final int occurrId;

String toUcLink(int occurrId) {
Expand All @@ -113,9 +117,19 @@ class SubjectButtonWidget extends StatelessWidget {
'UCURR_GERAL.FICHA_UC_VIEW?pv_ocorrencia_id=$occurrId';
}

Future<void> _launchURL() async {
final url = toUcLink(occurrId);
await launchUrl(Uri.parse(url));
void _launchURL(BuildContext context) {
final courseUnits = Provider.of<ProfileProvider>(context, listen: false)
.profile
.courseUnits;
final correspondingCourseUnit = courseUnits
.where((courseUnit) => courseUnit.occurrId == occurrId)
.first;
Navigator.push(
context,
MaterialPageRoute<CourseUnitDetailPageView>(
builder: (context) => CourseUnitDetailPageView(correspondingCourseUnit),
),
);
}

@override
Expand All @@ -132,8 +146,8 @@ class SubjectButtonWidget extends StatelessWidget {
iconSize: 18,
color: Colors.grey,
alignment: Alignment.centerRight,
tooltip: 'Abrir página da UC no browser',
onPressed: _launchURL,
tooltip: 'olaAbrir página da UC no browser',
onPressed: () => _launchURL(context),
),
],
);
Expand All @@ -146,6 +160,7 @@ class ScheduleTeacherClassInfoWidget extends StatelessWidget {
this.classNumber,
super.key,
});

final String? classNumber;
final String teacher;

Expand All @@ -161,6 +176,7 @@ class ScheduleTeacherClassInfoWidget extends StatelessWidget {

class ScheduleTimeWidget extends StatelessWidget {
const ScheduleTimeWidget({required this.begin, required this.end, super.key});

final String begin;
final String end;

Expand All @@ -182,6 +198,7 @@ class ScheduleTimeTextField extends StatelessWidget {
required this.context,
super.key,
});

final String time;
final BuildContext context;

Expand All @@ -202,6 +219,7 @@ class TextFieldWidget extends StatelessWidget {
required this.alignment,
super.key,
});

final String text;
final TextStyle? style;
final TextAlign alignment;
Expand Down

0 comments on commit 352c552

Please sign in to comment.