diff --git a/lib/config/ui_config.dart b/lib/config/ui_config.dart index 91891a1b..434d1c1c 100644 --- a/lib/config/ui_config.dart +++ b/lib/config/ui_config.dart @@ -215,6 +215,7 @@ abstract class DigitalGuideConfig { static const heightSmall = 8.0; static const heightBig = 24.0; static const heightHuge = 48.0; + static const paddingMedium = 16.0; } abstract class AlertDialogConfig { diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart b/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart index f3a19e5e..e91e8da9 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart +++ b/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart @@ -1,32 +1,46 @@ +import "package:flutter/gestures.dart"; import "package:flutter/widgets.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; +import "../../../../../config/ui_config.dart"; import "../../../../../theme/app_theme.dart"; import "../../../../../utils/context_extensions.dart"; +import "../../../../../utils/launch_url_util.dart"; class DigitalGuideDataSourceLink extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - return Text.rich( - TextSpan( - text: "${context.localize.data_come_from_website}: ", - style: const TextStyle( - fontWeight: FontWeight.bold, - ), - children: [ - TextSpan( - text: context.localize.digital_guide_website, - style: context.textTheme.bodyOrange.copyWith( - decoration: TextDecoration.underline, - decorationColor: context.colorTheme.orangePomegranade, - fontWeight: FontWeight.bold, - ), - // TODO(Bartosh): on tap url handling -> webbrowser launch + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: DigitalGuideConfig.paddingMedium, + ), + child: Text.rich( + TextSpan( + text: "${context.localize.data_come_from_website}: ", + style: const TextStyle( + fontWeight: FontWeight.bold, ), - ], + children: [ + TextSpan( + text: context.localize.digital_guide_website, + style: context.textTheme.bodyOrange.copyWith( + decoration: TextDecoration.underline, + decorationColor: context.colorTheme.orangePomegranade, + fontWeight: FontWeight.bold, + ), + recognizer: TapGestureRecognizer() + ..onTap = () async { + await ref.launch( + context.localize.digital_guide_website + .replaceAll("www.", "https://"), + ); + }, + ), + ], + ), + textAlign: TextAlign.center, + style: context.textTheme.body, ), - textAlign: TextAlign.center, - style: context.textTheme.body, ); } } diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart b/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart index 623d5518..06deadf5 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart +++ b/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart @@ -1,21 +1,47 @@ +import "dart:async"; + import "package:flutter/material.dart"; +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:fluttertoast/fluttertoast.dart"; import "../../../../../config/ui_config.dart"; import "../../../../../theme/app_theme.dart"; import "../../../../../utils/context_extensions.dart"; +import "../../../../../utils/launch_url_util.dart"; -class ReportChangeButton extends StatelessWidget { +class ReportChangeButton extends ConsumerWidget { @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { return Padding( padding: AppWidgetsConfig.paddingMedium, child: Column( children: [ - Text(context.localize.change_report_title), + Text(context.localize.report_change_title), const SizedBox(height: 8), ElevatedButton( - // TODO(Bartosh): handle action - onPressed: () {}, + onPressed: () async { + final errorMessageToast = + context.localize.report_change_error_toast_message; + final backgroundColorToast = context.colorTheme.greyLight; + final textColorToast = context.colorTheme.blackMirage; + + final emailUrl = + "mailto:${context.localize.report_change_email}?subject=${Uri.encodeComponent(context.localize.report_change_subject)}"; + + if (!await ref.launch( + emailUrl, + )) { + unawaited( + Fluttertoast.showToast( + msg: errorMessageToast, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + backgroundColor: backgroundColorToast, + textColor: textColorToast, + ), + ); + } + }, style: ElevatedButton.styleFrom( backgroundColor: context.colorTheme.blueAzure, padding: AppWidgetsConfig.paddingMedium, @@ -26,7 +52,7 @@ class ReportChangeButton extends StatelessWidget { ), ), child: Text( - context.localize.change_report_button, + context.localize.report_change_button, style: TextStyle(color: context.colorTheme.whiteSoap), ), ), diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index d167e43c..d82c95c1 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -151,8 +151,11 @@ "about_the_app": "O aplikacji", "other_view" : "Inne", "map" : "Mapa", - "change_report_title" : "Coś się zmieniło?", - "change_report_button" : "Zgłoś zmianę", + "report_change_title" : "Coś się zmieniło?", + "report_change_button" : "Zgłoś zmianę", + "report_change_email" : "kn.solvro@pwr.edu.pl", + "report_change_subject" : "Sugestia zmiany - ToPWR", + "report_change_error_toast_message" : "Nie można otworzyć aplikacji mailowej", "localization" : "Lokalizacja", "amenities" : "Udogodnienia", "surroundings": "Otoczenie", diff --git a/pubspec.yaml b/pubspec.yaml index b2dea573..19ddbfea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -89,6 +89,7 @@ dependencies: upgrader: ^11.3.0 in_app_review: ^2.0.9 flutter_map_animations: ^0.7.1 + fluttertoast: ^8.2.8 dev_dependencies: flutter_test: