Skip to content

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

mobile: pricing fixes for ios

Ammar Ahmed62ae26c4645e
diff --git a/apps/mobile/app/common/database/index.ts b/apps/mobile/app/common/database/index.ts
index a968bb88d..7749686af 100644
--- a/apps/mobile/app/common/database/index.ts
+++ b/apps/mobile/app/common/database/index.ts
@@ -26,7 +26,6 @@ import {
} from "@streetwriters/kysely";
import { Platform } from "react-native";
import * as Gzip from "react-native-gzip";
-import SettingsService from "../../services/settings";
import EventSource from "../../utils/sse/even-source-ios";
import AndroidEventSource from "../../utils/sse/event-source";
import { FileStorage } from "../filesystem";
@@ -39,16 +38,29 @@ export async function setupDatabase(password?: string) {
const key = await getDatabaseKey(password);
if (!key) throw new Error(strings.databaseSetupFailed());
+ const base = `http://192.168.100.79`;
+
database.host({
- API_HOST: "https://api.notesnook.com",
- AUTH_HOST: "https://auth.streetwriters.co",
- SSE_HOST: "https://events.streetwriters.co",
- SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
- ISSUES_HOST: "https://issues.streetwriters.co",
- MONOGRAPH_HOST: "https://monogr.ph",
- ...(SettingsService.getProperty("serverUrls") || {})
+ API_HOST: `${base}:5264`,
+ AUTH_HOST: `${base}:8264`,
+ SSE_HOST: `${base}:7264`,
+ ISSUES_HOST: `${base}:2624`,
+ SUBSCRIPTIONS_HOST: `${base}:9264`,
+ MONOGRAPH_HOST: `${base}:6264`,
+ NOTESNOOK_HOST: `${base}:8788`
});
+ // database.host( {
+ // API_HOST: "https://api.notesnook.com",
+ // AUTH_HOST: "https://auth.streetwriters.co",
+ // SSE_HOST: "https://events.streetwriters.co",
+ // SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
+ // ISSUES_HOST: "https://issues.streetwriters.co",
+ // MONOGRAPH_HOST: "https://monogr.ph",
+ // NOTESNOOK_HOST: "https://notesnook.com",
+ // ...(SettingsService.getProperty("serverUrls") || {})
+ // });
+
database.setup({
storage: Storage,
eventsource: (Platform.OS === "ios"
diff --git a/apps/mobile/app/components/auth/header.tsx b/apps/mobile/app/components/auth/header.tsx
index a30f11bce..9a99494e8 100644
--- a/apps/mobile/app/components/auth/header.tsx
+++ b/apps/mobile/app/components/auth/header.tsx
@@ -19,20 +19,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useThemeColors } from "@notesnook/theme";
import { useRoute } from "@react-navigation/native";
import React from "react";
-import { Platform, View } from "react-native";
-import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
+import { View } from "react-native";
import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
import { hideAuth } from "./common";
export const AuthHeader = (props: { welcome?: boolean }) => {
const { colors } = useThemeColors();
- const insets = useGlobalSafeAreaInsets();
const route = useRoute();
return (
<View
style={{
- paddingTop: Platform.OS === "android" ? 0 : insets.top,
width: "100%"
}}
>
diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.js
index c4348e132..9d712ef1d 100644
--- a/apps/mobile/app/components/auth/login.js
+++ b/apps/mobile/app/components/auth/login.js
@@ -20,7 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
-import { TouchableOpacity, View, useWindowDimensions } from "react-native";
+import {
+ ScrollView,
+ TouchableOpacity,
+ View,
+ useWindowDimensions
+} from "react-native";
import { SheetManager } from "react-native-actions-sheet";
import { DDS } from "../../services/device-detection";
import { eSendEvent } from "../../services/event-manager";
@@ -43,6 +48,7 @@ import { ForgotPassword } from "./forgot-password";
import { AuthHeader } from "./header";
import { useLogin } from "./use-login";
import { useRoute } from "@react-navigation/native";
+import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
const LoginSteps = {
emailAuth: 1,
@@ -105,213 +111,225 @@ export const Login = ({ changeMode }) => {
<AuthHeader />
<ForgotPassword />
<Dialog context="two_factor_verify" />
- <View
+ <KeyboardAwareScrollView
style={{
- borderRadius: DDS.isTab ? 5 : 0,
- backgroundColor: colors.primary.background,
- zIndex: 10,
- width: "100%",
- height: "100%",
- alignSelf: "center"
+ width: "100%"
}}
+ contentContainerStyle={{
+ minHeight: "90%"
+ }}
+ nestedScrollEnabled
+ enableAutomaticScroll={false}
+ keyboardShouldPersistTaps="handled"
>
<View
style={{
- justifyContent: "flex-end",
- paddingHorizontal: DefaultAppStyles.GAP,
- borderBottomWidth: 0.8,
- marginBottom: DefaultAppStyles.GAP_VERTICAL,
- borderBottomColor: colors.primary.border,
- alignSelf: isTablet ? "center" : undefined,
- borderWidth: isTablet ? 1 : null,
- borderColor: isTablet ? colors.primary.border : null,
- borderRadius: isTablet ? 20 : null,
- marginTop: isTablet ? 50 : null,
- width: !isTablet ? null : "70%",
- minHeight: height * 0.4
+ borderRadius: DDS.isTab ? 5 : 0,
+ backgroundColor: colors.primary.background,
+ zIndex: 10,
+ width: "100%",
+ height: "100%",
+ alignSelf: "center"
}}
>
<View
style={{
- flexDirection: "row"
+ justifyContent: "flex-end",
+ paddingHorizontal: DefaultAppStyles.GAP,
+ borderBottomWidth: 0.8,
+ marginBottom: DefaultAppStyles.GAP_VERTICAL,
+ borderBottomColor: colors.primary.border,
+ alignSelf: isTablet ? "center" : undefined,
+ borderWidth: isTablet ? 1 : null,
+ borderColor: isTablet ? colors.primary.border : null,
+ borderRadius: isTablet ? 20 : null,
+ marginTop: isTablet ? 50 : null,
+ width: !isTablet ? null : "70%",
+ minHeight: height * 0.4
}}
>
<View
style={{
- width: 100,
- height: 5,
- backgroundColor: colors.primary.accent,
- borderRadius: 2,
- marginRight: 7
+ flexDirection: "row"
}}
- />
+ >
+ <View
+ style={{
+ width: 100,
+ height: 5,
+ backgroundColor: colors.primary.accent,
+ borderRadius: 2,
+ marginRight: 7
+ }}
+ />
- <View
+ <View
+ style={{
+ width: 20,
+ height: 5,
+ backgroundColor: colors.secondary.background,
+ borderRadius: 2
+ }}
+ />
+ </View>
+ <Heading
style={{
- width: 20,
- height: 5,
- backgroundColor: colors.secondary.background,
- borderRadius: 2
+ marginBottom: 25,
+ marginTop: DefaultAppStyles.GAP_VERTICAL
}}
- />
+ extraBold
+ size={AppFontSize.xxl}
+ >
+ {strings.loginToYourAccount()}
+ </Heading>
</View>
- <Heading
+
+ <View
style={{
- marginBottom: 25,
- marginTop: DefaultAppStyles.GAP_VERTICAL
+ width: DDS.isTab
+ ? focused
+ ? "50%"
+ : "49.99%"
+ : focused
+ ? "100%"
+ : "99.9%",
+ backgroundColor: colors.primary.background,
+ alignSelf: "center",
+ paddingHorizontal: DefaultAppStyles.GAP,
+ gap: DefaultAppStyles.GAP_VERTICAL
}}
- extraBold
- size={AppFontSize.xxl}
>
- {strings.loginToYourAccount()}
- </Heading>
- </View>
-
- <View
- style={{
- width: DDS.isTab
- ? focused
- ? "50%"
- : "49.99%"
- : focused
- ? "100%"
- : "99.9%",
- backgroundColor: colors.primary.background,
- alignSelf: "center",
- paddingHorizontal: DefaultAppStyles.GAP,
- gap: DefaultAppStyles.GAP_VERTICAL
- }}
- >
- <Input
- fwdRef={emailInputRef}
- onChangeText={(value) => {
- email.current = value;
- }}
- testID="input.email"
- onErrorCheck={(e) => setError(e)}
- returnKeyLabel="Next"
- returnKeyType="next"
- autoComplete="email"
- validationType="email"
- marginBottom={0}
- autoCorrect={false}
- autoCapitalize="none"
- errorMessage={strings.emailInvalid()}
- placeholder={strings.email()}
- defaultValue={email.current}
- editable={step === LoginSteps.emailAuth && !loading}
- onSubmit={() => {
- if (step === LoginSteps.emailAuth) {
- login();
- } else {
- passwordInputRef.current?.focus();
- }
- }}
- />
-
- {step === LoginSteps.passwordAuth && (
- <>
- <Input
- fwdRef={passwordInputRef}
- onChangeText={(value) => {
- password.current = value;
- }}
- testID="input.password"
- returnKeyLabel={strings.done()}
- returnKeyType="done"
- secureTextEntry
- autoComplete="password"
- autoCapitalize="none"
- autoCorrect={false}
- placeholder={strings.password()}
- marginBottom={0}
- editable={!loading}
- defaultValue={password.current}
- onSubmit={() => login()}
- />
- <Button
- title={strings.forgotPassword()}
- style={{
- alignSelf: "flex-end",
- paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL,
- paddingHorizontal: 0
- }}
- onPress={() => {
- if (loading) return;
- SheetManager.show("forgotpassword_sheet", email.current);
- }}
- textStyle={{
- textDecorationLine: "underline"
- }}
- fontSize={AppFontSize.xs}
- type="plain"
- />
- </>
- )}
-
- <View>
- <Button
- loading={loading}
- onPress={() => {
- if (loading) return;
- login();
+ <Input
+ fwdRef={emailInputRef}
+ onChangeText={(value) => {
+ email.current = value;
}}
- style={{
- width: "100%"
+ testID="input.email"
+ onErrorCheck={(e) => setError(e)}
+ returnKeyLabel="Next"
+ returnKeyType="next"
+ autoComplete="email"
+ validationType="email"
+ marginBottom={0}
+ autoCorrect={false}
+ autoCapitalize="none"
+ errorMessage={strings.emailInvalid()}
+ placeholder={strings.email()}
+ defaultValue={email.current}
+ editable={step === LoginSteps.emailAuth && !loading}
+ onSubmit={() => {
+ if (step === LoginSteps.emailAuth) {
+ login();
+ } else {
+ passwordInputRef.current?.focus();
+ }
}}
- type="accent"
- title={!loading ? strings.continue() : null}
- fontSize={AppFontSize.md}
/>
{step === LoginSteps.passwordAuth && (
- <Button
- title={strings.cancelLogin()}
- style={{
- alignSelf: "center",
- marginTop: DefaultAppStyles.GAP_VERTICAL,
- width: "100%"
- }}
- onPress={() => {
- if (loading) return;
- setStep(LoginSteps.emailAuth);
- setLoading(false);
- }}
- fontSize={AppFontSize.md}
- type="secondaryAccented"
- />
+ <>
+ <Input
+ fwdRef={passwordInputRef}
+ onChangeText={(value) => {
+ password.current = value;
+ }}
+ testID="input.password"
+ returnKeyLabel={strings.done()}
+ returnKeyType="done"
+ secureTextEntry
+ autoComplete="password"
+ autoCapitalize="none"
+ autoCorrect={false}
+ placeholder={strings.password()}
+ marginBottom={0}
+ editable={!loading}
+ defaultValue={password.current}
+ onSubmit={() => login()}
+ />
+ <Button
+ title={strings.forgotPassword()}
+ style={{
+ alignSelf: "flex-end",
+ paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL,
+ paddingHorizontal: 0
+ }}
+ onPress={() => {
+ if (loading) return;
+ SheetManager.show("forgotpassword_sheet", email.current);
+ }}
+ textStyle={{
+ textDecorationLine: "underline"
+ }}
+ fontSize={AppFontSize.xs}
+ type="plain"
+ />
+ </>
)}
- {!loading ? (
- <TouchableOpacity
+ <View>
+ <Button
+ loading={loading}
onPress={() => {
if (loading) return;
- changeMode(1);
+ login();
}}
- activeOpacity={0.8}
style={{
- alignSelf: "center",
- marginTop: DefaultAppStyles.GAP_VERTICAL,
- paddingVertical: DefaultAppStyles.GAP_VERTICAL
+ width: "100%"
}}
- >
- <Paragraph
- size={AppFontSize.xs}
- color={colors.secondary.paragraph}
+ type="accent"
+ title={!loading ? strings.continue() : null}
+ fontSize={AppFontSize.md}
+ />
+
+ {step === LoginSteps.passwordAuth && (
+ <Button
+ title={strings.cancelLogin()}
+ style={{
+ alignSelf: "center",
+ marginTop: DefaultAppStyles.GAP_VERTICAL,
+ width: "100%"
+ }}
+ onPress={() => {
+ if (loading) return;
+ setStep(LoginSteps.emailAuth);
+ setLoading(false);
+ }}
+ fontSize={AppFontSize.md}
+ type="secondaryAccented"
+ />
+ )}
+
+ {!loading ? (
+ <TouchableOpacity
+ onPress={() => {
+ if (loading) return;
+ changeMode(1);
+ }}
+ activeOpacity={0.8}
+ style={{
+ alignSelf: "center",
+ marginTop: DefaultAppStyles.GAP_VERTICAL,
+ paddingVertical: DefaultAppStyles.GAP_VERTICAL
+ }}
>
- {strings.dontHaveAccount()}{" "}
<Paragraph
size={AppFontSize.xs}
- style={{ color: colors.primary.accent }}
+ color={colors.secondary.paragraph}
>
- {strings.signUp()}
+ {strings.dontHaveAccount()}{" "}
+ <Paragraph
+ size={AppFontSize.xs}
+ style={{ color: colors.primary.accent }}
+ >
+ {strings.signUp()}
+ </Paragraph>
</Paragraph>
- </Paragraph>
- </TouchableOpacity>
- ) : null}
+ </TouchableOpacity>
+ ) : null}
+ </View>
</View>
</View>
- </View>
+ </KeyboardAwareScrollView>
</>
);
};
diff --git a/apps/mobile/app/components/intro/index.tsx b/apps/mobile/app/components/intro/index.tsx
index c13715202..f029fdca0 100644
--- a/apps/mobile/app/components/intro/index.tsx
+++ b/apps/mobile/app/components/intro/index.tsx
@@ -31,6 +31,7 @@ import { Button } from "../ui/button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import SettingsService from "../../services/settings";
+import { SafeAreaView } from "react-native-safe-area-context";
const Intro = () => {
const { colors } = useThemeColors();
@@ -115,7 +116,7 @@ const Intro = () => {
);
return (
- <View
+ <SafeAreaView
style={{
flex: 1,
height: "100%",
@@ -211,7 +212,7 @@ const Intro = () => {
}}
/>
</View>
- </View>
+ </SafeAreaView>
);
};
diff --git a/apps/mobile/app/components/ui/input/index.tsx b/apps/mobile/app/components/ui/input/index.tsx
index 74c433073..5faa15dbe 100644
--- a/apps/mobile/app/components/ui/input/index.tsx
+++ b/apps/mobile/app/components/ui/input/index.tsx
@@ -237,8 +237,8 @@ const Input = ({
onPress && loading ? colors.primary.accent : colors.primary.paragraph,
flexGrow: 1,
flexShrink: 1,
- paddingBottom: DefaultAppStyles.GAP_VERTICAL - 2,
- paddingTop: DefaultAppStyles.GAP_VERTICAL - 2,
+ paddingBottom: DefaultAppStyles.GAP_VERTICAL,
+ paddingTop: DefaultAppStyles.GAP_VERTICAL,
fontFamily: "OpenSans-Regular",
...(inputStyle as ViewStyle)
};
diff --git a/apps/mobile/app/screens/settings/user-section.jsx b/apps/mobile/app/screens/settings/user-section.jsx
index e6ec82484..e45f345d4 100644
--- a/apps/mobile/app/screens/settings/user-section.jsx
+++ b/apps/mobile/app/screens/settings/user-section.jsx
@@ -18,6 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { formatBytes } from "@notesnook/common";
+import {
+ SubscriptionPlan,
+ SubscriptionStatus,
+ SubscriptionType
+} from "@notesnook/core";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import { useNetInfo } from "@react-native-community/netinfo";
@@ -37,11 +42,11 @@ import { presentSheet } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import { useThemeStore } from "../../stores/use-theme-store";
import { SyncStatus, useUserStore } from "../../stores/use-user-store";
+import { planToDisplayName } from "../../utils/constants";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { SectionItem } from "./section-item";
-import { planToDisplayName } from "../../utils/constants";
-import { SubscriptionType } from "@notesnook/core";
+import { Notice } from "../../components/ui/notice";
export const getTimeLeft = (t2) => {
let daysRemaining = dayjs(t2).diff(dayjs(), "days");
@@ -120,8 +125,6 @@ const onChangePicture = () => {
});
};
-const LONG_MAX = 9223372036854776000;
-
const SettingsUserSection = ({ item }) => {
const { colors } = useThemeColors();
const [user] = useUserStore((state) => [state.user]);
@@ -133,6 +136,48 @@ const SettingsUserSection = ({ item }) => {
const used = user?.storageUsed || 0;
const total = user?.totalStorage || 0;
+ const getSubscriptionStatus = () => {
+ if (!user) return strings.neverHesitate();
+ const subscriptionDaysLeft = user && getTimeLeft(user.subscription?.expiry);
+ const expiryDate = dayjs(user?.subscription?.expiry).format(
+ "dddd, MMMM D, YYYY h:mm A"
+ );
+ const startDate = dayjs(user?.subscription?.start).format(
+ "dddd, MMMM D, YYYY h:mm A"
+ );
+
+ if (user.subscription.plan !== SubscriptionPlan.FREE) {
+ const status = user.subscription.status;
+ return status === SubscriptionStatus.TRIAL
+ ? strings.trialEndsOn(
+ dayjs(user?.subscription?.start)
+ .add(user?.subscription?.productId.includes("monthly") ? 7 : 14)
+ .format("dddd, MMMM D, YYYY h:mm A")
+ )
+ : status === SubscriptionStatus.ACTIVE
+ ? strings.subRenewOn(expiryDate)
+ : status === SubscriptionStatus.CANCELED
+ ? strings.subEndsOn(expiryDate)
+ : status === SubscriptionStatus.EXPIRED
+ ? subscriptionDaysLeft.time < -3
+ ? strings.subEnded()
+ : strings.accountDowngradedIn(3)
+ : strings.neverHesitate();
+ }
+
+ return user.subscription?.type === SubscriptionType.TRIAL
+ ? strings.trialEndsOn(expiryDate)
+ : user.subscription?.type === SubscriptionType.PREMIUM_EXPIRED
+ ? subscriptionDaysLeft.time < -3
+ ? strings.subEnded()
+ : strings.accountDowngradedIn(3)
+ : user.subscription?.type === SubscriptionType.PREMIUM_CANCELED
+ ? strings.subEndsOn(expiryDate)
+ : user.subscription?.type === SubscriptionType.PREMIUM
+ ? strings.subRenewOn(expiryDate)
+ : strings.neverHesitate();
+ };
+
return (
<>
{user ? (
@@ -281,7 +326,7 @@ const SettingsUserSection = ({ item }) => {
</Paragraph>
<Paragraph size={AppFontSize.xxs}>
{formatBytes(used)}/
- {total === LONG_MAX
+ {total === -1
? "Unlimited"
: formatBytes(total) + " " + strings.used()}
</Paragraph>
@@ -356,6 +401,15 @@ const SettingsUserSection = ({ item }) => {
/>
</View>
</View>
+
+ {user.subscription.plan === SubscriptionPlan.FREE ||
+ user.subscription.type === SubscriptionType.BASIC ? null : (
+ <Notice
+ size="small"
+ text={getSubscriptionStatus()}
+ type="information"
+ />
+ )}
</View>
{item.sections.map((item) => (
diff --git a/apps/mobile/app/services/premium.js b/apps/mobile/app/services/premium.js
index 8c3fcc1b5..60c89fadf 100644
--- a/apps/mobile/app/services/premium.js
+++ b/apps/mobile/app/services/premium.js
@@ -255,7 +255,7 @@ const subscriptions = {
try {
let result = await fetch(
__DEV__
- ? "http://192.168.43.5:4264/apple/verify"
+ ? "http://192.168.100.79:4264/apple/verify"
: "https://payments.streetwriters.co/apple/verify",
requestData
);
@@ -270,7 +270,9 @@ const subscriptions = {
} else {
await subscriptions.clear(subscription);
}
- } catch (e) {}
+ } catch (e) {
+ console.log(e);
+ }
}
}
},