Skip to content

Commit 7c61a55

Browse files
authored
Merge pull request #413 from wavect/wsdt/quickactions
feat: quick actions
2 parents 6d539c9 + 48b7b28 commit 7c61a55

File tree

9 files changed

+146
-11
lines changed

9 files changed

+146
-11
lines changed

mobile/AppRoot.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ROUTES } from "./screens/routes";
77

88
import Welcome from "./screens/Welcome";
99

10+
import { useQuickAction } from "@/hooks/useQuickAction";
1011
import { TR, i18n } from "@/localization/translate.service";
1112
import ResetPassword from "@/screens/ResetPassword";
1213
import AppIntroductionSwiperScreen from "@/screens/onboarding/AppIntroductionSlider";
@@ -95,6 +96,8 @@ export default function App() {
9596

9697
const navContainerRef = useRef<NavigationContainerRef<any>>(null);
9798

99+
useQuickAction();
100+
98101
useEffect(() => {
99102
async function prepare() {
100103
try {

mobile/app.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,18 @@
171171
"project": "offlinery-app",
172172
"organization": "wavect"
173173
}
174-
]
174+
],
175+
[
176+
"expo-quick-actions",
177+
{
178+
"androidIcons": {
179+
"help_icon": {
180+
"foregroundImage": "./assets/quick-actions/adaptive-icon-foreground-help.png",
181+
"backgroundColor": "#36797d"
182+
}
183+
}
184+
}
185+
]
175186
],
176187
"extra": {
177188
"eas": {
30.9 KB
Loading

mobile/hooks/useQuickAction.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { i18n, TR } from "@/localization/translate.service";
2+
import { sendEmail } from "@/utils/email";
3+
import { SUPPORT_MAIL } from "@/utils/general.constants";
4+
import * as Sentry from "@sentry/react-native";
5+
import * as QuickActions from "expo-quick-actions";
6+
import { useQuickActionCallback } from "expo-quick-actions/hooks";
7+
import { useEffect } from "react";
8+
import { Platform } from "react-native";
9+
10+
enum EQuickAction {
11+
DO_NOT_DELETE = "do_not_delete",
12+
}
13+
14+
export const useQuickAction = () => {
15+
useEffect(() => {
16+
QuickActions.isSupported()
17+
.then((isSupported) => {
18+
if (isSupported) {
19+
QuickActions.setItems([
20+
{
21+
title: i18n.t(TR.quickActionDontDeleteMeTitle),
22+
subtitle: i18n.t(
23+
TR.quickActionDontDeleteMeSubTitle,
24+
),
25+
icon:
26+
Platform.OS === "ios"
27+
? "symbol:questionmark.circle"
28+
: "help_icon",
29+
id: EQuickAction.DO_NOT_DELETE,
30+
// params: { href: `/${EQuickAction.DO_NOT_DELETE}` }, // @dev href param requires useQuickActionRouting
31+
},
32+
]);
33+
}
34+
})
35+
.catch((err) => {
36+
Sentry.captureException(err, {
37+
tags: {
38+
quickActionsSupported:
39+
"notAbleToCheckQuickActionSupport",
40+
},
41+
});
42+
});
43+
}, []);
44+
// useQuickActionRouting(); // @dev only works with expo router
45+
46+
useQuickActionCallback((action) => {
47+
switch (action.id) {
48+
case EQuickAction.DO_NOT_DELETE:
49+
// TODO: Show feedback modal, explainer, etc., for now just email
50+
sendEmail(
51+
SUPPORT_MAIL,
52+
i18n.t(TR.quickActionDontDeleteMeEmailSubject),
53+
i18n.t(TR.quickActionDontDeleteMeEmailBody),
54+
);
55+
break;
56+
}
57+
});
58+
};

mobile/localization/de.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Language } from "./translate.service";
22

33
export const de: Language = {
4+
quickActionDontDeleteMeTitle: "Bitte lösch mich nicht!",
5+
quickActionDontDeleteMeSubTitle: "Ich helfe im Hintergrund.",
6+
quickActionDontDeleteMeEmailSubject: "Offlinery: Feedback (Quick-Action)",
7+
quickActionDontDeleteMeEmailBody:
8+
"Bitte lass uns wissen was dir an Offlinery nicht gefällt. Wir wollen dein knallhartes Feedback. Es hilft uns mehr als du denkst!",
49
blog: "Blog lesen",
510
retry: "Nochmal versuchen",
611
maintenanceAlertTitle: "Offlinery wird gewartet",
@@ -154,7 +159,7 @@ export const de: Language = {
154159
men: "Männer",
155160
more: "Mehr",
156161
iAmA: "Ich bin ein(e)",
157-
casual: "Casual",
162+
casual: "Nichts Ernstes",
158163
casualDescription:
159164
"Offen für was Lockeres. Bitte beachte, dass dies keine offene Einladung ist - bleib respektvoll und taste dich langsam voran.",
160165
reconnectFriends: "Mit Freunden reconnecten",

mobile/localization/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// @dev Other languages have to be typed as Language!
22

33
export const en = {
4+
quickActionDontDeleteMeTitle: "Wait! Don't delete me!",
5+
quickActionDontDeleteMeSubTitle: "I help in the background.",
6+
quickActionDontDeleteMeEmailSubject: "Offlinery: Feedback (Quick-Action)",
7+
quickActionDontDeleteMeEmailBody:
8+
"Please describe your problems and give us your honest feedback. It helps us so much more than you think!",
49
blog: "Read Blog",
510
retry: "Retry",
611
maintenanceAlertTitle: "Offlinery in maintenance",

mobile/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"expo-localization": "^16.0.1",
6363
"expo-network": "^7.0.5",
6464
"expo-notifications": "^0.29.13",
65+
"expo-quick-actions": "^4.0.2",
6566
"expo-splash-screen": "^0.29.21",
6667
"expo-status-bar": "^2.0.1",
6768
"expo-task-manager": "^12.0.5",

mobile/pnpm-lock.yaml

Lines changed: 42 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/utils/email.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Sentry from "@sentry/react-native";
2+
import { Linking } from "react-native";
3+
4+
export const sendEmail = (
5+
recipient: string,
6+
subject?: string,
7+
body?: string,
8+
) => {
9+
const url = `mailto:${recipient}?subject=${encodeURIComponent(subject ?? "")}&body=${encodeURIComponent(body ?? "")}`;
10+
11+
Linking.openURL(url).catch((err) => {
12+
console.error("Error opening mail:", err);
13+
Sentry.captureException(err, {
14+
tags: {
15+
sendEmail: "openingMail",
16+
},
17+
});
18+
});
19+
};

0 commit comments

Comments
 (0)