From 9461e72f00c920fed8a4fe3dfef2fc84f012660b Mon Sep 17 00:00:00 2001 From: Matan Mashraki <12946462+planecore@users.noreply.github.com> Date: Wed, 19 Jul 2023 12:28:59 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=94=20-=20Added=20no=20calendar=20acce?= =?UTF-8?q?ss=20alert=20(#290)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Guy Tepper --- .../route-details-header.tsx | 20 ++++++++++++++++--- app/i18n/ar.json | 4 +++- app/i18n/en.json | 4 +++- app/i18n/he.json | 4 +++- app/i18n/ru.json | 4 +++- app/screens/planner/planner-screen-header.tsx | 2 +- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/components/route-details-header/route-details-header.tsx b/app/components/route-details-header/route-details-header.tsx index 9e0dcd78..4594394e 100644 --- a/app/components/route-details-header/route-details-header.tsx +++ b/app/components/route-details-header/route-details-header.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/display-name */ import React, { useMemo, useLayoutEffect } from "react" -import { Image, ImageBackground, View, ViewStyle, TextStyle, ImageStyle } from "react-native" +import { Image, ImageBackground, View, ViewStyle, TextStyle, ImageStyle, Alert, Linking } from "react-native" import analytics from "@react-native-firebase/analytics" import { useNavigation } from "@react-navigation/native" import { observer } from "mobx-react-lite" @@ -97,13 +97,27 @@ export interface RouteDetailsHeaderProps { } export const RouteDetailsHeader = observer(function RouteDetailsHeader(props: RouteDetailsHeaderProps) { - const { routeItem, originId, destinationId, screenName, style, eventConfig } = props + const { routeItem, originId, destinationId, screenName, style } = props const { favoriteRoutes } = useStores() const navigation = useNavigation() const addToCalendar = () => { + analytics().logEvent("add_route_to_calendar") const eventConfig = createEventConfig(routeItem) - AddCalendarEvent.presentEventCreatingDialog(eventConfig) + AddCalendarEvent.presentEventCreatingDialog(eventConfig).catch((error) => { + if (error === "permissionNotGranted") { + Alert.alert(translate("routeDetails.noCalendarAccessTitle"), translate("routeDetails.noCalendarAccessMessage"), [ + { + style: "cancel", + text: translate("common.cancel"), + }, + { + text: translate("settings.title"), + onPress: () => Linking.openSettings(), + }, + ]) + } + }) } const originName = stationsObject[originId][stationLocale] diff --git a/app/i18n/ar.json b/app/i18n/ar.json index d640636c..a4b5acd8 100644 --- a/app/i18n/ar.json +++ b/app/i18n/ar.json @@ -51,7 +51,9 @@ "lastStop": "المحطة الأخيرة", "routeWarning": "تحذير الطريق الطويل", "routeWarningText": "هناك طرق قطار أقصر حول وقت المغادرة.", - "addToCalendar": "إضافة إلى التقويم" + "addToCalendar": "إضافة إلى التقويم", + "noCalendarAccessTitle": "تم تعطيل الوصول إلى التقويم", + "noCalendarAccessMessage": "للإضافة إلى تقويم المسار ، يرجى فتح إعدادات جهازك وتمكين الوصول إلى التقويم." }, "settings": { "title": "اعدادت", diff --git a/app/i18n/en.json b/app/i18n/en.json index 898479af..bcacd482 100644 --- a/app/i18n/en.json +++ b/app/i18n/en.json @@ -59,7 +59,9 @@ "lastStop": "Last Stop", "routeWarning": "Long Route Warning", "routeWarningText": "There are shorter train routes around the departure time.", - "addToCalendar": "Add to Calendar" + "addToCalendar": "Add to Calendar", + "noCalendarAccessTitle": "Calendar access disabled", + "noCalendarAccessMessage": "To add the ride to your calendar, open your device settings and grant access to your calendar." }, "settings": { "title": "Settings", diff --git a/app/i18n/he.json b/app/i18n/he.json index b6473e44..28745e21 100644 --- a/app/i18n/he.json +++ b/app/i18n/he.json @@ -59,7 +59,9 @@ "lastStop": "יעד סופי", "routeWarning": "רכבת מאספת", "routeWarningText": "קיימים מסלולי נסיעה קצרים יותר סביב שעת היציאה הנבחרת", - "addToCalendar": "הוספה ליומן" + "addToCalendar": "הוספה ליומן", + "noCalendarAccessTitle": "גישה ללוח שנה כבויה", + "noCalendarAccessMessage": "יש לאפשר גישה ללוח שנה בהגדרות המכשיר על מנת להוסיף נסיעה ליומן" }, "settings": { "title": "הגדרות", diff --git a/app/i18n/ru.json b/app/i18n/ru.json index 13bb3a29..6618ec85 100644 --- a/app/i18n/ru.json +++ b/app/i18n/ru.json @@ -58,7 +58,9 @@ "lastStop": "Последняя остановка", "routeWarning": "Предупреждение о длинном маршруте", "routeWarningText": "Во время отправления есть более короткие маршруты поездов.", - "addToCalendar": "Добавить в календарь" + "addToCalendar": "Добавить в календарь", + "noCalendarAccessTitle": "Доступ к календарю отключен", + "noCalendarAccessMessage": "Чтобы добавить маршрут в календарь, откройте настройки устройства и включите доступ к календарю." }, "settings": { "title": "Настройки", diff --git a/app/screens/planner/planner-screen-header.tsx b/app/screens/planner/planner-screen-header.tsx index 0fd1d2b0..9ac14aeb 100644 --- a/app/screens/planner/planner-screen-header.tsx +++ b/app/screens/planner/planner-screen-header.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react" -import { Image, ImageStyle, Platform, TouchableOpacity, View, ViewStyle } from "react-native" +import { Image, ImageStyle, TouchableOpacity, View, ViewStyle } from "react-native" import { useNavigation } from "@react-navigation/core" import { observer } from "mobx-react-lite" import * as storage from "../../utils/storage"