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

feat: add report button functionality - open email app #484

Merged
merged 11 commits into from
Dec 11, 2024
1 change: 1 addition & 0 deletions lib/config/ui_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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),
),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "[email protected]",
"report_change_subject" : "Sugestia zmiany - ToPWR",
"report_change_error_toast_message" : "Nie można otworzyć aplikacji mailowej",
"localization" : "Lokalizacja",
"amenities" : "Udogodnienia",
"surroundings": "Otoczenie",
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading