Skip to content

Commit

Permalink
🔔 - Added no calendar access alert (#290)
Browse files Browse the repository at this point in the history
Co-authored-by: Guy Tepper <[email protected]>
  • Loading branch information
planecore and guytepper authored Jul 19, 2023
1 parent 9695d27 commit 9461e72
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
20 changes: 17 additions & 3 deletions app/components/route-details-header/route-details-header.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion app/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
"lastStop": "المحطة الأخيرة",
"routeWarning": "تحذير الطريق الطويل",
"routeWarningText": "هناك طرق قطار أقصر حول وقت المغادرة.",
"addToCalendar": "إضافة إلى التقويم"
"addToCalendar": "إضافة إلى التقويم",
"noCalendarAccessTitle": "تم تعطيل الوصول إلى التقويم",
"noCalendarAccessMessage": "للإضافة إلى تقويم المسار ، يرجى فتح إعدادات جهازك وتمكين الوصول إلى التقويم."
},
"settings": {
"title": "اعدادت",
Expand Down
4 changes: 3 additions & 1 deletion app/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion app/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"lastStop": "יעד סופי",
"routeWarning": "רכבת מאספת",
"routeWarningText": "קיימים מסלולי נסיעה קצרים יותר סביב שעת היציאה הנבחרת",
"addToCalendar": "הוספה ליומן"
"addToCalendar": "הוספה ליומן",
"noCalendarAccessTitle": "גישה ללוח שנה כבויה",
"noCalendarAccessMessage": "יש לאפשר גישה ללוח שנה בהגדרות המכשיר על מנת להוסיף נסיעה ליומן"
},
"settings": {
"title": "הגדרות",
Expand Down
4 changes: 3 additions & 1 deletion app/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
"lastStop": "Последняя остановка",
"routeWarning": "Предупреждение о длинном маршруте",
"routeWarningText": "Во время отправления есть более короткие маршруты поездов.",
"addToCalendar": "Добавить в календарь"
"addToCalendar": "Добавить в календарь",
"noCalendarAccessTitle": "Доступ к календарю отключен",
"noCalendarAccessMessage": "Чтобы добавить маршрут в календарь, откройте настройки устройства и включите доступ к календарю."
},
"settings": {
"title": "Настройки",
Expand Down
2 changes: 1 addition & 1 deletion app/screens/planner/planner-screen-header.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 9461e72

Please sign in to comment.