Skip to content

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

mobile: small fixes

Ammar Ahmed035126ab2f14
diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.js
index 1f7f8c775..c4348e132 100644
--- a/apps/mobile/app/components/auth/login.js
+++ b/apps/mobile/app/components/auth/login.js
@@ -77,8 +77,9 @@ export const Login = ({ changeMode }) => {
if (!PremiumService.get()) {
Navigation.navigate("PayWall", {
- context: "logged-in",
- state: route.params.state
+ context: "signup",
+ state: route.params.state,
+ canGoBack: false
});
} else {
Progress.present();
diff --git a/apps/mobile/app/components/auth/signup.js b/apps/mobile/app/components/auth/signup.js
index 05e52a145..a4ee709a2 100644
--- a/apps/mobile/app/components/auth/signup.js
+++ b/apps/mobile/app/components/auth/signup.js
@@ -93,7 +93,8 @@ export const Signup = ({ changeMode, welcome }) => {
setEmailVerifyMessage();
Navigation.navigate("PayWall", {
canGoBack: false,
- state: route.params.state
+ state: route.params.state,
+ context: "signup"
});
return true;
} catch (e) {
diff --git a/apps/mobile/app/components/premium/paywall.tsx b/apps/mobile/app/components/premium/paywall.tsx
index 4d6149157..6c7368c07 100644
--- a/apps/mobile/app/components/premium/paywall.tsx
+++ b/apps/mobile/app/components/premium/paywall.tsx
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import { getFeaturesTable } from "@notesnook/common";
+import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import {
@@ -42,15 +44,14 @@ import { getElevationStyle } from "../../utils/elevation";
import { openLinkInBrowser } from "../../utils/functions";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
-import { AuthMode } from "../auth/common";
import { Header } from "../header";
import { BuyPlan } from "../sheets/buy-plan";
import { Toast } from "../toast";
+import AppIcon from "../ui/AppIcon";
import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
-import { FeaturesList } from "./features-list";
-import { getFeaturesTable } from "@notesnook/common";
const Steps = {
select: 1,
@@ -132,7 +133,26 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
flex: 1
}}
>
- {routeParams.context === "signup" && step === Steps.select ? null : (
+ {step === Steps.finish ? null : routeParams.context === "signup" &&
+ step === Steps.select ? (
+ <View
+ style={{
+ height: 50,
+ justifyContent: "flex-end",
+ alignItems: "flex-end",
+ width: "100%",
+ flexDirection: "row",
+ paddingHorizontal: DefaultAppStyles.GAP
+ }}
+ >
+ <IconButton
+ name="close"
+ onPress={() => {
+ Navigation.replace("FluidPanelsView", {});
+ }}
+ />
+ </View>
+ ) : (
<Header
canGoBack={true}
onLeftMenuButtonPress={() => {
@@ -140,7 +160,11 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
setStep(Steps.select);
return;
}
- props.navigation.goBack();
+ if (routeParams.context === "signup") {
+ Navigation.replace("FluidPanelsView", {});
+ } else {
+ Navigation.goBack();
+ }
}}
title={
step === Steps.buy || step === Steps.buyWeb
@@ -151,6 +175,7 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
}
/>
)}
+
{step === Steps.select ? (
<>
<ScrollView
@@ -245,14 +270,17 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
</Paragraph>
</TouchableOpacity>
- {pricingPlans.pricingPlans.map((plan) => (
- <PricingPlanCard
- key={plan.id}
- plan={plan}
- pricingPlans={pricingPlans}
- annualBilling={annualBilling}
- />
- ))}
+ {pricingPlans.pricingPlans.map((plan) =>
+ plan.id !== "free" ? (
+ <PricingPlanCard
+ key={plan.id}
+ plan={plan}
+ setStep={setStep}
+ pricingPlans={pricingPlans}
+ annualBilling={annualBilling}
+ />
+ ) : null
+ )}
</View>
<View
@@ -459,7 +487,7 @@ After trying all the privacy security oriented note taking apps, for the price a
>
<Heading>Compare plans</Heading>
</View>
- <ComparePlans />
+ <ComparePlans pricingPlans={pricingPlans} setStep={setStep} />
<View
style={{
alignItems: "center",
@@ -497,66 +525,6 @@ After trying all the privacy security oriented note taking apps, for the price a
))}
</View>
</ScrollView>
-
- <View
- style={{
- width: "100%",
- backgroundColor: colors.primary.background,
- paddingHorizontal: 16,
- paddingVertical: 16,
- borderTopWidth: 1,
- borderTopColor: colors.primary.border,
- position: "absolute",
- paddingBottom: DefaultAppStyles.GAP_VERTICAL,
- bottom: 0
- }}
- >
- <Button
- width="100%"
- type="accent"
- title={
- pricingPlans.currentPlan?.id === "free"
- ? "I'll stay on the Free plan"
- : pricingPlans.userCanRequestTrial
- ? `Start ${annualBilling ? "14" : "7"} days free trial`
- : pricingPlans.user
- ? "Subscribe"
- : "Login to subscribe"
- }
- onPress={() => {
- if (pricingPlans.currentPlan?.id === "free") {
- if (routeParams.context === "signup") {
- Navigation.replace("FluidPanelsView", {});
- } else {
- Navigation.goBack();
- }
- }
-
- if (!pricingPlans.user) {
- Navigation.navigate("Auth", {
- mode: AuthMode.login,
- state: {
- planId: pricingPlans.currentPlan?.id,
- productId: pricingPlans.selectedProduct?.productId,
- billingType: annualBilling ? "annual" : "monthly"
- }
- });
- return;
- }
-
- if (isGithubRelease) {
- setStep(Steps.buyWeb);
- }
-
- if (
- !pricingPlans.currentPlan?.id ||
- !pricingPlans.selectedProduct
- )
- return;
- setStep(Steps.buy);
- }}
- />
- </View>
</>
) : step === Steps.buy ? (
<BuyPlan
@@ -586,9 +554,53 @@ After trying all the privacy security oriented note taking apps, for the price a
}}
/>
</View>
- ) : (
- <View />
- )}
+ ) : step === Steps.finish ? (
+ <View
+ style={{
+ width: "100%",
+ height: "100%",
+ justifyContent: "center",
+ alignItems: "center",
+ gap: DefaultAppStyles.GAP_VERTICAL,
+ maxWidth: "80%",
+ alignSelf: "center"
+ }}
+ >
+ <View
+ style={{
+ width: 60,
+ height: 60,
+ borderRadius: 200,
+ backgroundColor: colors.primary.shade,
+ justifyContent: "center",
+ alignItems: "center"
+ }}
+ >
+ <AppIcon color={colors.primary.accent} name="check" size={30} />
+ </View>
+ <Heading>Thank you for subscribing</Heading>
+ <Paragraph
+ style={{
+ textAlign: "center"
+ }}
+ >
+ We’re setting up your plan right now. We’ll notify you as soon as
+ everything is ready.
+ </Paragraph>
+
+ <Button
+ title={strings.continue()}
+ type="accent"
+ onPress={() => {
+ if (routeParams.context === "signup") {
+ Navigation.replace("FluidPanelsView", {});
+ } else {
+ Navigation.goBack();
+ }
+ }}
+ />
+ </View>
+ ) : null}
<Toast context="local" />
</SafeAreaView>
@@ -642,7 +654,10 @@ const FAQItem = (props: { question: string; answer: string }) => {
};
const ComparePlans = React.memo(
- () => {
+ (props: {
+ pricingPlans?: ReturnType<typeof usePricingPlans>;
+ setStep: (step: number) => void;
+ }) => {
const { colors } = useThemeColors();
return (
<ScrollView
@@ -742,6 +757,39 @@ const ComparePlans = React.memo(
</View>
);
})}
+
+ <View
+ style={{
+ flexDirection: "row",
+ alignItems: "center",
+ width: "100%",
+ gap: 10
+ }}
+ >
+ {["features", "free", "essential", "pro", "believer"].map(
+ (plan, index) => (
+ <View
+ style={{
+ width: index === 0 ? 150 : 120,
+ paddingHorizontal: 16,
+ paddingVertical: 8
+ }}
+ >
+ {plan !== "free" && plan !== "features" ? (
+ <Button
+ title={strings.select()}
+ type="accent"
+ fontSize={AppFontSize.xs}
+ onPress={() => {
+ props.pricingPlans?.selectPlan(plan);
+ props.setStep(Steps.buy);
+ }}
+ />
+ ) : null}
+ </View>
+ )
+ )}
+ </View>
</ScrollView>
);
},
@@ -812,11 +860,13 @@ const ReviewItem = (props: {
const PricingPlanCard = ({
plan,
pricingPlans,
- annualBilling
+ annualBilling,
+ setStep
}: {
plan: PricingPlan;
pricingPlans?: ReturnType<typeof usePricingPlans>;
annualBilling?: boolean;
+ setStep: (step: number) => void;
}) => {
const { colors } = useThemeColors();
const isSelected = pricingPlans?.currentPlan?.id === plan.id;
@@ -841,8 +891,6 @@ const PricingPlanCard = ({
annualBilling
);
- console.log("PRODUCT", product?.productId, plan.id);
-
const DefaultPricing = {
essential: "$2.99",
pro: "$5.99",
@@ -851,15 +899,17 @@ const PricingPlanCard = ({
return (
<TouchableOpacity
- activeOpacity={0.9}
+ activeOpacity={0.8}
onPress={() => {
pricingPlans?.selectPlan(plan.id);
+ setStep(Steps.buy);
}}
style={{
...getElevationStyle(3),
backgroundColor: colors.primary.background,
borderWidth: 1,
- borderColor: isSelected ? colors.primary.accent : colors.primary.border,
+ borderColor:
+ plan.id === "pro" ? colors.primary.accent : colors.primary.border,
borderRadius: 10,
padding: 16,
width: "100%",
diff --git a/apps/mobile/app/components/sheets/plan-limits/index.tsx b/apps/mobile/app/components/sheets/plan-limits/index.tsx
index 2f8e6cd6a..34387e1cd 100644
--- a/apps/mobile/app/components/sheets/plan-limits/index.tsx
+++ b/apps/mobile/app/components/sheets/plan-limits/index.tsx
@@ -1,4 +1,9 @@
-import { FeatureUsage, getFeature, getFeaturesUsage } from "@notesnook/common";
+import {
+ FeatureUsage,
+ formatBytes,
+ getFeature,
+ getFeaturesUsage
+} from "@notesnook/common";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import { useEffect, useState } from "react";
@@ -54,7 +59,11 @@ export function PlanLimits() {
{getFeature(item.id).title}
</Paragraph>
<Paragraph size={AppFontSize.sm}>
- {item.used}/{item.total} {strings.used()}
+ {item.id === "storage"
+ ? `${formatBytes(item.used)}/${formatBytes(
+ item.total
+ )} ${strings.used()}`
+ : `${item.used}/${item.total} ${strings.used()}`}
</Paragraph>
</View>
<View
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index bc7ff4583..61ddf04d5 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -75,59 +75,59 @@ export const settingsGroups: SettingSection[] = [
useHook: () => useUserStore((state) => state.user),
hidden: (current) => !current,
sections: [
- {
- id: "subscription-status",
- useHook: () => useUserStore((state) => state.user),
- hidden: (current) => !current,
- name: (current) => {
- const user = (current as User) || useUserStore.getState().user;
- if (!user) return strings.upgradePlan();
- const isBasic = user.subscription?.type === SUBSCRIPTION_STATUS.BASIC;
- const isTrial = user.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
- return isBasic || !user.subscription?.type
- ? strings.upgradePlan()
- : isTrial
- ? strings.trialStarted()
- : strings.subDetails();
- ``;
- },
- type: "component",
- component: "subscription",
- icon: "crown",
- description: (current) => {
- const user = current as User;
- if (!user) return strings.neverHesitate();
- const subscriptionDaysLeft =
- user &&
- getTimeLeft(
- parseInt(user.subscription?.expiry as unknown as string)
- );
- const expiryDate = dayjs(user?.subscription?.expiry).format(
- "MMMM D, YYYY"
- );
- const startDate = dayjs(user?.subscription?.start).format(
- "MMMM D, YYYY"
- );
+ // {
+ // id: "subscription-status",
+ // useHook: () => useUserStore((state) => state.user),
+ // hidden: (current) => !current,
+ // name: (current) => {
+ // const user = (current as User) || useUserStore.getState().user;
+ // if (!user) return strings.upgradePlan();
+ // const isBasic = user.subscription?.type === SUBSCRIPTION_STATUS.BASIC;
+ // const isTrial = user.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
+ // return isBasic || !user.subscription?.type
+ // ? strings.upgradePlan()
+ // : isTrial
+ // ? strings.trialStarted()
+ // : strings.subDetails();
+ // ``;
+ // },
+ // type: "component",
+ // component: "subscription",
+ // icon: "crown",
+ // description: (current) => {
+ // const user = current as User;
+ // if (!user) return strings.neverHesitate();
+ // const subscriptionDaysLeft =
+ // user &&
+ // getTimeLeft(
+ // parseInt(user.subscription?.expiry as unknown as string)
+ // );
+ // const expiryDate = dayjs(user?.subscription?.expiry).format(
+ // "MMMM D, YYYY"
+ // );
+ // const startDate = dayjs(user?.subscription?.start).format(
+ // "MMMM D, YYYY"
+ // );
- if (user.subscription.provider === 4) {
- return strings.subEndsOn(expiryDate);
- }
+ // if (user.subscription.provider === 4) {
+ // return strings.subEndsOn(expiryDate);
+ // }
- return user.subscription?.type === 2
- ? strings.signedUpOn(startDate)
- : user.subscription?.type === 1
- ? strings.trialEndsOn(expiryDate)
- : user.subscription?.type === 6
- ? subscriptionDaysLeft.time < -3
- ? strings.subEnded()
- : strings.accountDowngradedIn(3)
- : user.subscription?.type === 7
- ? strings.subEndsOn(expiryDate)
- : user.subscription?.type === 5
- ? strings.subRenewOn(expiryDate)
- : strings.neverHesitate();
- }
- },
+ // return user.subscription?.type === 2
+ // ? strings.signedUpOn(startDate)
+ // : user.subscription?.type === 1
+ // ? strings.trialEndsOn(expiryDate)
+ // : user.subscription?.type === 6
+ // ? subscriptionDaysLeft.time < -3
+ // ? strings.subEnded()
+ // : strings.accountDowngradedIn(3)
+ // : user.subscription?.type === 7
+ // ? strings.subEndsOn(expiryDate)
+ // : user.subscription?.type === 5
+ // ? strings.subRenewOn(expiryDate)
+ // : strings.neverHesitate();
+ // }
+ // },
{
id: "redeem-gift-code",
name: strings.redeemGiftCode(),
diff --git a/apps/mobile/app/screens/settings/user-section.jsx b/apps/mobile/app/screens/settings/user-section.jsx
index c522dc082..d9b63f624 100644
--- a/apps/mobile/app/screens/settings/user-section.jsx
+++ b/apps/mobile/app/screens/settings/user-section.jsx
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import { formatBytes } from "@notesnook/common";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import { useNetInfo } from "@react-native-community/netinfo";
@@ -38,6 +39,7 @@ import { useThemeStore } from "../../stores/use-theme-store";
import { SyncStatus, useUserStore } from "../../stores/use-user-store";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
+import { SectionItem } from "./section-item";
export const getTimeLeft = (t2) => {
let daysRemaining = dayjs(t2).diff(dayjs(), "days");
@@ -67,7 +69,7 @@ const ProfilePicPlaceholder = (props) => {
justifyContent: "center"
}}
>
- <Icon size={50} color={colors.primary.accent} name="account-outline" />
+ <Icon size={35} color={colors.primary.accent} name="account-outline" />
</View>
</TouchableOpacity>
);
@@ -118,14 +120,14 @@ const onChangePicture = () => {
const SettingsUserSection = ({ item }) => {
const { colors } = useThemeColors();
- const [user, premium] = useUserStore((state) => [state.user, state.premium]);
+ const [user] = useUserStore((state) => [state.user]);
const lastSynced = useUserStore((state) => state.lastSynced);
const lastSyncStatus = useUserStore((state) => state.lastSyncStatus);
const { isInternetReachable } = useNetInfo();
const isOffline = !isInternetReachable;
const userProfile = useUserStore((state) => state.profile);
- const used = 50;
- const total = 100;
+ const used = user.storageUsed || 0;
+ const total = user.totalStorage || 0;
return (
<>
@@ -154,9 +156,7 @@ const SettingsUserSection = ({ item }) => {
>
<View
style={{
- borderWidth: 2,
borderRadius: 100,
- borderColor: colors.primary.accent,
alignSelf: "flex-start"
}}
>
@@ -276,7 +276,7 @@ const SettingsUserSection = ({ item }) => {
{strings.storage()}
</Paragraph>
<Paragraph size={AppFontSize.xxs}>
- 50/100MB {strings.used()}
+ {formatBytes(used)}/{formatBytes(total)} {strings.used()}
</Paragraph>
</View>
<View
@@ -289,7 +289,7 @@ const SettingsUserSection = ({ item }) => {
>
<View
style={{
- backgroundColor: colors.static.black,
+ backgroundColor: colors.primary.accent,
height: 5,
width: `${(used / total) * 100}%`,
borderRadius: 10
@@ -348,9 +348,9 @@ const SettingsUserSection = ({ item }) => {
</View>
</View>
- {/* {item.sections.map((item) => (
+ {item.sections.map((item) => (
<SectionItem key={item.name} item={item} />
- ))} */}
+ ))}
</>
) : null}
</>