Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: redeem gift code

Ammar Ahmedc2e7f7576e31
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index b69172c4c..e302a5bf4 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -78,8 +78,7 @@ import { verifyUser, verifyUserWithApplock } from "./functions";
import { SettingSection } from "./types";
import { getTimeLeft } from "./user-section";
import Clipboard from "@react-native-clipboard/clipboard";
-
-type User = any;
+import { User } from "@notesnook/core";
export const settingsGroups: SettingSection[] = [
{
@@ -119,6 +118,10 @@ export const settingsGroups: SettingSection[] = [
"MMMM D, YYYY"
);
+ if (user.subscription.provider === 4) {
+ return strings.subEndsOn(expiryDate);
+ }
+
return user.subscription?.type === 2
? strings.signedUpOn(startDate)
: user.subscription?.type === 1
@@ -134,6 +137,39 @@ export const settingsGroups: SettingSection[] = [
: strings.neverHesitate();
}
},
+ {
+ id: "redeem-gift-code",
+ name: strings.redeemGiftCode(),
+ description: strings.redeemGiftCodeDesc(),
+ hidden: (current) => {
+ return !current as boolean;
+ },
+ useHook: () =>
+ useUserStore(
+ (state) =>
+ state.user?.subscription.type == SUBSCRIPTION_STATUS.TRIAL ||
+ state.user?.subscription.type == SUBSCRIPTION_STATUS.BASIC
+ ),
+ icon: "gift",
+ modifer: () => {
+ presentDialog({
+ title: strings.redeemGiftCode(),
+ paragraph: strings.redeemGiftCodeDesc(),
+ input: true,
+ inputPlaceholder: strings.code(),
+ positiveText: strings.redeem(),
+ positivePress: async (value) => {
+ db.subscriptions.redeemCode(value).catch((e) => {
+ ToastManager.show({
+ heading: "Error redeeming code",
+ message: (e as Error).message,
+ type: "error"
+ });
+ });
+ }
+ });
+ }
+ },
{
id: "account-settings",
type: "screen",
diff --git a/apps/mobile/app/screens/settings/subscription.js b/apps/mobile/app/screens/settings/subscription.js
index fda262927..b15eb3042 100644
--- a/apps/mobile/app/screens/settings/subscription.js
+++ b/apps/mobile/app/screens/settings/subscription.js
@@ -126,18 +126,19 @@ export const Subscription = () => {
user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC ? (
<Button
- title={subscriptionProviderInfo?.title}
+ title={subscriptionProviderInfo?.title()}
onPress={() => {
presentSheet({
- title: subscriptionProviderInfo.title,
- paragraph: subscriptionProviderInfo.desc
+ title: subscriptionProviderInfo.title(),
+ paragraph: subscriptionProviderInfo.desc()
});
}}
style={{
alignSelf: "flex-start",
- borderRadius: 100
+ width: "100%",
+ paddingHorizontal: 0
}}
- fontSize={SIZE.sm}
+ fontSize={SIZE.xs}
height={30}
type="secondaryAccented"
/>
diff --git a/apps/mobile/native/fonts/MaterialCommunityIcons.ttf b/apps/mobile/native/fonts/MaterialCommunityIcons.ttf
index 57d766216..d16f589c1 100644
Binary files a/apps/mobile/native/fonts/MaterialCommunityIcons.ttf and b/apps/mobile/native/fonts/MaterialCommunityIcons.ttf differ
diff --git a/apps/mobile/scripts/optimize-fonts.mjs b/apps/mobile/scripts/optimize-fonts.mjs
index 60922dc8d..12c072294 100644
--- a/apps/mobile/scripts/optimize-fonts.mjs
+++ b/apps/mobile/scripts/optimize-fonts.mjs
@@ -81,7 +81,8 @@ const EXTRA_ICON_NAMES = [
"notebook-plus",
"arrow-right-bold-box-outline",
"arrow-up-bold",
- "login"
+ "login",
+ "gift"
];
const __filename = fileURLToPath(import.meta.url);
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index d98d8d0cb..11cfca2e6 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -4584,6 +4584,10 @@ msgstr "Recovery key text file saved"
msgid "Recovery successful!"
msgstr "Recovery successful!"
+#: src/strings.ts:2408
+msgid "Redeem"
+msgstr "Redeem"
+
#: src/strings.ts:2405
msgid "Redeem gift code"
msgstr "Redeem gift code"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 22740d93b..507b491ff 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -4564,6 +4564,10 @@ msgstr "<<<<<<< HEAD<<<<<<< HEAD"
#: src/strings.ts:1891
msgid "Recovery successful!"
+msgstr "<<<<<<< HEAD"
+
+#: src/strings.ts:2408
+msgid "Redeem"
msgstr ""
#: src/strings.ts:2405
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 5501b9524..670a809d6 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2404,5 +2404,6 @@ Use this if changes from other devices are not appearing on this device. This wi
emailCopied: () => t`Email copied`,
redeemGiftCode: () => t`Redeem gift code`,
redeemGiftCodeDesc: () => t`Enter the gift code to redeem your subscription.`,
- redeemingGiftCode: () => t`Redeeming gift code`
+ redeemingGiftCode: () => t`Redeeming gift code`,
+ redeem: () => t`Redeem`
};