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

Fixing day title translation #968

Merged
merged 16 commits into from
Jan 5, 2024
Merged
14 changes: 0 additions & 14 deletions uni/lib/controller/local_storage/database/app_exams_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ import 'package:uni/model/entities/exam.dart';
class AppExamsDatabase extends AppDatabase {
AppExamsDatabase()
: super('exams.db', [_createScript], onUpgrade: migrate, version: 5);
Map<String, String> months = {
'Janeiro': '01',
'Fevereiro': '02',
'Março': '03',
'Abril': '04',
'Maio': '05',
'Junho': '06',
'Julho': '07',
'Agosto': '08',
'Setembro': '09',
'Outubro': '10',
'Novembro': '11',
'Dezembro': '12',
};

static const _createScript = '''
CREATE TABLE exams(id TEXT, subject TEXT, begin TEXT, end TEXT,
Expand Down
18 changes: 18 additions & 0 deletions uni/lib/controller/networking/url_launcher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/view/common_widgets/toast_message.dart';
import 'package:url_launcher/url_launcher.dart';

Future<void> launchUrlWithToast(BuildContext context, String url) async {
final validUrl = Uri.parse(url);
if (url != '' && canLaunchUrl(validUrl) as bool) {
await launchUrl(Uri.parse(url));
} else {
await ToastMessage.error(
context,
S.of(context).no_link,
);
}
}
3 changes: 3 additions & 0 deletions uni/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class MessageLookup extends MessageLookupByLibrary {
"edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"),
"empty_text":
MessageLookupByLibrary.simpleMessage("Please fill in this field"),
"exam_of": MessageLookupByLibrary.simpleMessage("of"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Exams Filter Settings"),
"exit_confirm":
Expand Down Expand Up @@ -184,6 +185,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("No favorite restaurants"),
"no_info": MessageLookupByLibrary.simpleMessage(
"There is no information to display"),
"no_link":
MessageLookupByLibrary.simpleMessage("We couldn\'t open the link"),
"no_library_info": MessageLookupByLibrary.simpleMessage(
"No library occupation information available"),
"no_menu_info": MessageLookupByLibrary.simpleMessage(
Expand Down
3 changes: 3 additions & 0 deletions uni/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class MessageLookup extends MessageLookupByLibrary {
"edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"),
"empty_text": MessageLookupByLibrary.simpleMessage(
"Por favor preenche este campo"),
"of_month": MessageLookupByLibrary.simpleMessage("de"),
"exams_filter":
MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"),
"exit_confirm": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -185,6 +186,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Sem restaurantes favoritos"),
"no_info": MessageLookupByLibrary.simpleMessage(
"Não existem informações para apresentar"),
"no_link": MessageLookupByLibrary.simpleMessage(
"Não conseguimos abrir o link"),
"no_library_info":
MessageLookupByLibrary.simpleMessage("Sem informação de ocupação"),
"no_menu_info": MessageLookupByLibrary.simpleMessage(
Expand Down
20 changes: 20 additions & 0 deletions uni/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions uni/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
"@no_library_info": {},
"occurrence_type": "Type of occurrence",
"@occurrence_type": {},
"of_month": "of",
"@of_month": {},
"no_link": "We couldn't open the link",
"@no_link": {},
"other_links": "Other links",
"@other_links": {},
"pass_change_request": "For security reasons, passwords must be changed periodically.",
Expand Down
4 changes: 4 additions & 0 deletions uni/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
"@no_library_info": {},
"occurrence_type": "Tipo de ocorrência",
"@occurrence_type": {},
"of_month": "de",
"@of_month": {},
"no_link": "Não conseguimos abrir o link",
"@no_link": {},
"other_links": "Outros links",
"@other_links": {},
"pass_change_request": "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.",
Expand Down
12 changes: 5 additions & 7 deletions uni/lib/view/about/widgets/terms_and_conditions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:uni/controller/fetchers/terms_and_conditions_fetcher.dart';
import 'package:uni/controller/networking/url_launcher.dart';
import 'package:uni/generated/l10n.dart';
import 'package:url_launcher/url_launcher.dart';

class TermsAndConditions extends StatelessWidget {
const TermsAndConditions({super.key});

@override
Widget build(BuildContext context) {
var termsAndConditionsSaved = S.of(context).loading_terms;
String? termsAndConditionsSaved = S.of(context).loading_terms;
final termsAndConditionsFuture = fetchTermsAndConditions();
return FutureBuilder(
future: termsAndConditionsFuture,
builder:
(BuildContext context, AsyncSnapshot<String> termsAndConditions) {
if (termsAndConditions.connectionState == ConnectionState.done &&
termsAndConditions.hasData) {
termsAndConditionsSaved = termsAndConditions.data!;
termsAndConditionsSaved = termsAndConditions.data;
}
return MarkdownBody(
styleSheet: MarkdownStyleSheet(),
shrinkWrap: false,
data: termsAndConditionsSaved,
data: termsAndConditionsSaved!,
onTapLink: (text, url, title) async {
if (await canLaunchUrl(Uri.parse(url!))) {
await launchUrl(Uri.parse(url));
}
await launchUrlWithToast(context, url!);
},
);
},
Expand Down
3 changes: 2 additions & 1 deletion uni/lib/view/exams/widgets/day_title.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:uni/generated/l10n.dart';

class DayTitle extends StatelessWidget {
const DayTitle({
Expand All @@ -17,7 +18,7 @@ class DayTitle extends StatelessWidget {
padding: const EdgeInsets.only(top: 15, bottom: 3),
alignment: Alignment.center,
child: Text(
'$weekDay, $day de $month',
'$weekDay, $day ${S.of(context).of_month} $month',
style: Theme.of(context).textTheme.titleLarge,
),
);
Expand Down
8 changes: 4 additions & 4 deletions uni/lib/view/schedule/widgets/schedule_slot.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/controller/networking/url_launcher.dart';
import 'package:uni/view/common_widgets/row_container.dart';
import 'package:url_launcher/url_launcher.dart';

class ScheduleSlot extends StatelessWidget {
const ScheduleSlot({
Expand Down Expand Up @@ -113,9 +113,9 @@ class SubjectButtonWidget extends StatelessWidget {
'UCURR_GERAL.FICHA_UC_VIEW?pv_ocorrencia_id=$occurrId';
}

Future<void> _launchURL() async {
Future<void> _launchURL(BuildContext context) async {
final url = toUcLink(occurrId);
await launchUrl(Uri.parse(url));
await launchUrlWithToast(context, url);
}

@override
Expand All @@ -133,7 +133,7 @@ class SubjectButtonWidget extends StatelessWidget {
color: Colors.grey,
alignment: Alignment.centerRight,
tooltip: 'Abrir página da UC no browser',
onPressed: _launchURL,
onPressed: () => _launchURL(context),
),
],
);
Expand Down
4 changes: 2 additions & 2 deletions uni/lib/view/useful_info/widgets/link_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:uni/controller/networking/url_launcher.dart';

class LinkButton extends StatelessWidget {
const LinkButton({
Expand Down Expand Up @@ -27,7 +27,7 @@ class LinkButton extends StatelessWidget {
.headlineSmall!
.copyWith(decoration: TextDecoration.underline),
),
onTap: () => launchUrl(Uri.parse(link)),
onTap: () => launchUrlWithToast(context, link),
),
),
],
Expand Down
4 changes: 2 additions & 2 deletions uni/lib/view/useful_info/widgets/text_components.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:uni/controller/networking/url_launcher.dart';

Container h1(String text, BuildContext context, {bool initial = false}) {
final marginTop = initial ? 15.0 : 30.0;
Expand Down Expand Up @@ -44,7 +44,7 @@ Container infoText(
.bodyLarge!
.apply(color: Theme.of(context).colorScheme.tertiary),
),
onTap: () => link != '' ? launchUrl(Uri.parse(link)) : null,
onTap: () => launchUrlWithToast(context, link),
),
),
);
Expand Down
Loading