Compare commits

...

6 Commits

Author SHA1 Message Date
Ammar Ahmed
a2f3ac0a47 mobile: cleanup 2026-04-29 14:02:05 +05:00
Ammar Ahmed
ec62547ba9 mobile: update ui 2026-04-29 13:58:30 +05:00
Ammar Ahmed
7f9bb42487 mobile: update ui for paywall flow 2026-04-21 11:44:13 +05:00
Ammar Ahmed
e490048912 mobile: update ui for auth screens 2026-04-21 09:17:23 +05:00
Ammar Ahmed
ce2a694ec3 mobile: update onboarding screen ui 2026-04-18 10:15:27 +05:00
Ammar Ahmed
10b02007b3 mobile: add style guide baseline 2026-04-18 10:10:28 +05:00
133 changed files with 10325 additions and 6722 deletions

View File

@@ -0,0 +1,9 @@
{
"iconSets": [
{
"inputDir": "../../packages/icons/svgs",
"fontFamily": "notesnook-icons",
"outputDir": "./fonts"
}
]
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export const FontSizes = {
XXS: 10,
XS: 12,
SM: 14,
MD: 16,
LG: 18,
XL: 20,
XXL: 32
};
export const FontFamily = {
REGULAR: "Inter-Regular", // 400
MEDIUM: "Inter-Medium", // 500
SEMI_BOLD: "Inter-SemiBold", // 600
BOLD: "Inter-Bold" // 700
};
const LineHeightMultipliers = {
"100%": 1,
"110%": 1.1,
"120%": 1.2,
"130%": 1.3,
"140%": 1.4,
"150%": 1.5
};
export type LineHeightVariants =
| "100%"
| "110%"
| "120%"
| "130%"
| "140%"
| "150%";
export const getLineHeight = (
fontSize: keyof typeof FontSizes,
type: LineHeightVariants
) => {
return FontSizes[fontSize] * LineHeightMultipliers[type];
};

View File

@@ -0,0 +1,21 @@
export const Spacing = {
LEVEL_0: 4,
LEVEL_1: 8,
LEVEL_2: 12,
LEVEL_3: 16,
LEVEL_4: 20,
LEVEL_5: 24,
LEVEL_6: 28,
LEVEL_7: 32,
LEVEL_8: 40
};
export const Radius = {
XXS: 4,
XS: 8,
S: 12,
MD: 16,
LG: 20,
LG_2: 32,
XXL: 40
};

View File

@@ -24,6 +24,9 @@ import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
import { hideAuth } from "./common";
import { AuthParams } from "../../stores/use-navigation-store";
import { ProgressPills } from "../intro/progress-pills";
import { FontSizes } from "../../common/design/font";
import { Spacing } from "../../common/design/spacing";
export const AuthHeader = (props: { welcome?: boolean }) => {
const { colors } = useThemeColors();
const route = useRoute();
@@ -37,19 +40,25 @@ export const AuthHeader = (props: { welcome?: boolean }) => {
<View
style={{
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 12,
paddingHorizontal: Spacing.LEVEL_3,
width: "100%",
height: 50,
justifyContent: !props.welcome ? "space-between" : "flex-end"
justifyContent: "space-between",
alignItems: "center"
}}
>
{props.welcome ? null : (
{props.welcome ? (
<ProgressPills activePillIndex={1} />
) : (
<IconButton
name="arrow-left"
onPress={() => {
hideAuth((route.params as AuthParams)?.context);
}}
style={{
width: 30,
height: 30
}}
size={26}
color={colors.primary.paragraph}
/>
)}
@@ -60,16 +69,16 @@ export const AuthHeader = (props: { welcome?: boolean }) => {
onPress={() => {
hideAuth();
}}
iconSize={16}
iconSize={24}
fontSize={FontSizes.SM}
type="plain"
fontFamily="REGULAR"
iconPosition="right"
icon="chevron-right"
height={25}
iconStyle={{
marginTop: 2
}}
style={{
paddingHorizontal: 6
paddingRight: 0,
paddingHorizontal: 0,
paddingVertical: 0
}}
/>
)}

View File

@@ -17,15 +17,15 @@ 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 { useThemeColors } from "@notesnook/theme";
import React, { useState } from "react";
import { SafeAreaView } from "react-native-safe-area-context";
import { useNavigationFocus } from "../../hooks/use-navigation-focus";
import { NavigationProps } from "../../services/navigation";
import { Toast } from "../toast";
import { AuthMode, initialAuthMode } from "./common";
import { Login } from "./login";
import { Signup } from "./signup";
import { useThemeColors } from "@notesnook/theme";
import { NavigationProps } from "../../services/navigation";
const Auth = ({ navigation, route }: NavigationProps<"Auth">) => {
const [currentAuthMode, setCurrentAuthMode] = useState(

View File

@@ -21,8 +21,10 @@ import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import { RouteProp, useRoute } from "@react-navigation/native";
import React, { useEffect, useState } from "react";
import { TouchableOpacity, View, useWindowDimensions } from "react-native";
import { TouchableOpacity, View } from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { db } from "../../common/database";
import { Spacing } from "../../common/design/spacing";
import { DDS } from "../../services/device-detection";
import { eSendEvent, presentSheet } from "../../services/event-manager";
import Navigation from "../../services/navigation";
@@ -33,23 +35,26 @@ import { RouteParams } from "../../stores/use-navigation-store";
import { useUserStore } from "../../stores/use-user-store";
import { eUserLoggedIn } from "../../utils/events";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { sleep } from "../../utils/time";
import { Dialog } from "../dialog";
import { ProgressPills } from "../intro/progress-pills";
import { Progress } from "../sheets/progress";
import { Button } from "../ui/button";
import Input from "../ui/input";
import {
ErrorContainer,
InputErrorProvider
} from "../ui/input/input-error-context";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { hideAuth } from "./common";
import { ForgotPassword } from "./forgot-password";
import { AuthHeader } from "./header";
import TwoFactorVerification from "./two-factor";
import { useLogin } from "./use-login";
const LoginSteps = {
emailAuth: 1,
mfaAuth: 2,
passwordAuth: 3
mfaAuth: 2
};
export const Login = ({
@@ -70,7 +75,8 @@ export const Login = ({
loading,
setLoading,
setError,
login
login,
mfaData
} = useLogin(async () => {
eSendEvent(eUserLoggedIn, true);
await sleep(500);
@@ -91,8 +97,6 @@ export const Login = ({
Progress.present();
}
});
const { width, height } = useWindowDimensions();
const isTablet = width > 600;
useEffect(() => {
async () => {
setStep(LoginSteps.emailAuth);
@@ -109,129 +113,99 @@ export const Login = ({
return (
<>
<AuthHeader />
<Dialog context="two_factor_verify" />
<View
style={{
paddingHorizontal: Spacing.LEVEL_3,
marginTop: Spacing.LEVEL_4
}}
>
<ProgressPills
count={2}
activePillIndex={step === LoginSteps.emailAuth ? 0 : 1}
/>
</View>
<KeyboardAwareScrollView
style={{
width: "100%"
}}
contentContainerStyle={{
minHeight: "90%"
minHeight: "99%"
}}
nestedScrollEnabled
enableAutomaticScroll={true}
keyboardShouldPersistTaps="handled"
>
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
zIndex: 10,
width: "100%",
height: "100%",
alignSelf: "center"
}}
>
<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 : undefined,
borderColor: isTablet ? colors.primary.border : undefined,
borderRadius: isTablet ? 20 : undefined,
marginTop: isTablet ? 50 : undefined,
width: !isTablet ? undefined : "50%",
minHeight: height * 0.4
}}
>
<InputErrorProvider>
{step === LoginSteps.emailAuth ? (
<View
style={{
flexDirection: "row"
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
zIndex: 10,
width: "100%",
alignSelf: "center",
height: "100%",
paddingHorizontal: Spacing.LEVEL_3,
paddingTop: Spacing.LEVEL_6
}}
>
<Heading
style={{
paddingBottom: Spacing.LEVEL_4
}}
fontSize="XL"
>
{strings.loginToYourAccount()}
</Heading>
<View
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
borderRadius: 2,
marginRight: 7
width: DDS.isTab
? focused
? "50%"
: "49.99%"
: focused
? "100%"
: "99.9%",
backgroundColor: colors.primary.background,
alignSelf: "center",
gap: Spacing.LEVEL_2
}}
/>
>
<Input
fwdRef={emailInputRef}
onChangeText={(value) => {
email.current = value;
}}
label="Email"
testID="input.email"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
validationType="email"
autoCorrect={false}
autoCapitalize="none"
errorMessage={strings.emailInvalid()}
placeholder="you@example.com"
defaultValue={email.current}
editable={step === LoginSteps.emailAuth && !loading}
onSubmit={() => {
if (step === LoginSteps.emailAuth) {
login();
} else {
passwordInputRef.current?.focus();
}
}}
/>
<View
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
borderRadius: 2
}}
/>
</View>
<Heading
style={{
marginBottom: 25,
marginTop: 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: DDS.isTab ? 0 : 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;
}}
label="Password"
testID="input.password"
returnKeyLabel={strings.done()}
returnKeyType="done"
@@ -239,8 +213,7 @@ export const Login = ({
autoComplete="password"
autoCapitalize="none"
autoCorrect={false}
placeholder={strings.password()}
marginBottom={0}
placeholder={"•••••••••"}
editable={!loading}
defaultValue={password.current}
onSubmit={() => {
@@ -251,7 +224,7 @@ export const Login = ({
title={strings.forgotPassword()}
style={{
alignSelf: "flex-end",
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL,
paddingVertical: 0,
paddingHorizontal: 0
}}
onPress={() => {
@@ -260,77 +233,126 @@ export const Login = ({
component: <ForgotPassword userEmail={email.current} />
});
}}
textStyle={{
textDecorationLine: "underline"
}}
fontSize={AppFontSize.xs}
fontFamily="REGULAR"
fontSize={AppFontSize.sm}
type="plain"
/>
</>
)}
<View>
<Button
loading={loading}
onPress={() => {
if (loading) return;
login();
}}
style={{
width: "100%"
}}
type="accent"
title={!loading ? strings.continue() : null}
fontSize={AppFontSize.sm}
/>
{step === LoginSteps.passwordAuth && (
<Button
title={strings.cancelLogin()}
<View
style={{
alignSelf: "center",
marginTop: DefaultAppStyles.GAP_VERTICAL,
width: "100%"
}}
onPress={() => {
if (loading) return;
setStep(LoginSteps.emailAuth);
setLoading(false);
}}
type="secondaryAccented"
/>
)}
{!loading ? (
<TouchableOpacity
onPress={() => {
if (loading) return;
changeMode(1);
}}
activeOpacity={0.8}
style={{
alignSelf: "center",
marginTop: DefaultAppStyles.GAP_VERTICAL,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
marginTop: Spacing.LEVEL_1,
gap: Spacing.LEVEL_2
}}
>
<Paragraph
size={AppFontSize.xs}
color={colors.secondary.paragraph}
>
{strings.dontHaveAccount()}{" "}
<Paragraph
size={AppFontSize.xs}
style={{ color: colors.primary.accent }}
<Button
loading={loading}
onPress={() => {
if (loading) return;
login();
}}
style={{
width: "100%"
}}
type="accent"
title={!loading ? strings.continue() : null}
fontSize={AppFontSize.sm}
/>
{!loading ? (
<TouchableOpacity
onPress={() => {
if (loading) return;
changeMode(1);
}}
activeOpacity={0.8}
style={{
alignSelf: "center",
paddingVertical: 0
}}
>
{strings.signUp()}
</Paragraph>
</Paragraph>
</TouchableOpacity>
) : null}
<Paragraph
fontSize="SM"
color={colors.secondary.paragraph}
>
{strings.dontHaveAccount()}{" "}
<Paragraph
fontSize="SM"
style={{ color: colors.primary.accent }}
fontFamily="SEMI_BOLD"
>
{strings.signUp()}
</Paragraph>
</Paragraph>
</TouchableOpacity>
) : null}
<View
style={{
marginTop: Spacing.LEVEL_3,
justifyContent: "center",
alignItems: "center"
}}
>
<ErrorContainer inputRef={emailInputRef} />
<ErrorContainer inputRef={passwordInputRef} />
</View>
</View>
</View>
</View>
</View>
</View>
) : (
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
zIndex: 10,
width: "100%",
alignSelf: "center",
height: "100%",
paddingHorizontal: Spacing.LEVEL_3,
paddingTop: Spacing.LEVEL_6
}}
>
<TwoFactorVerification
onMfaLogin={async (
mfa: any,
callback: (success: boolean) => void
) => {
try {
const success = await db.user.authenticateMultiFactorCode(
mfa.code,
mfa.method
);
await login();
if (success) {
setLoading(false);
callback && callback(true);
}
callback && callback(false);
} catch (e) {
callback && callback(false);
if ((e as Error).message === "invalid_grant") {
setLoading(false);
setStep(LoginSteps.emailAuth);
}
}
}}
mfaInfo={
mfaData.current || {
primaryMethod: "email",
secondaryMethod: "sms",
token: ""
}
}
onCancel={() => {
setLoading(false);
setStep(LoginSteps.emailAuth);
}}
/>
</View>
)}
</InputErrorProvider>
</KeyboardAwareScrollView>
</>
);

View File

@@ -28,24 +28,30 @@ import {
useWindowDimensions
} from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { SETTING_ACCOUNT_SVG } from "../../assets/images/assets";
import { db } from "../../common/database";
import { Spacing } from "../../common/design/spacing";
import { DDS } from "../../services/device-detection";
import { ToastManager } from "../../services/event-manager";
import { clearMessage, setEmailVerifyMessage } from "../../services/message";
import Navigation from "../../services/navigation";
import SettingsService from "../../services/settings";
import { RouteParams } from "../../stores/use-navigation-store";
import { useUserStore } from "../../stores/use-user-store";
import { openLinkInBrowser } from "../../utils/functions";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { ProgressPills } from "../intro/progress-pills";
import { Loading } from "../loading";
import { Button } from "../ui/button";
import Input from "../ui/input";
import {
ErrorContainer,
InputErrorProvider
} from "../ui/input/input-error-context";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { AuthHeader } from "./header";
import { SignupContext } from "./signup-context";
import { RouteParams } from "../../stores/use-navigation-store";
import SettingsService from "../../services/settings";
const SignupSteps = {
signup: 0,
@@ -139,245 +145,233 @@ export const Signup = ({
width: "100%"
}}
contentContainerStyle={{
minHeight: "90%"
minHeight: "99%"
}}
nestedScrollEnabled
keyboardShouldPersistTaps="handled"
>
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
zIndex: 10,
width: "100%",
alignSelf: "center",
height: "100%"
}}
>
<InputErrorProvider>
<View
style={{
justifyContent: "flex-end",
paddingHorizontal: 16,
marginBottom: DefaultAppStyles.GAP_VERTICAL,
borderBottomWidth: 0.8,
borderBottomColor: colors.primary.border,
alignSelf: isTablet ? "center" : undefined,
borderWidth: isTablet ? 1 : undefined,
borderColor: isTablet ? colors.primary.border : undefined,
borderRadius: isTablet ? 20 : undefined,
marginTop: isTablet ? 50 : undefined,
width: !isTablet ? undefined : "50%",
minHeight: height * 0.25
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
zIndex: 10,
width: "100%",
alignSelf: "center",
height: "100%",
paddingHorizontal: Spacing.LEVEL_3,
paddingTop: Spacing.LEVEL_6
}}
>
<View
style={{
flexDirection: "row"
}}
>
<View
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
borderRadius: 2,
marginRight: 7
}}
/>
<View
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
borderRadius: 2
}}
/>
</View>
<Heading
extraBold
style={{
marginBottom: 25,
marginTop: 10
paddingBottom: Spacing.LEVEL_4
}}
size={AppFontSize.xxl}
fontSize="XL"
>
{strings.createAccount()}
</Heading>
</View>
<View
style={{
width: DDS.isTab ? "50%" : "100%",
paddingHorizontal: DDS.isTab ? 0 : 16,
backgroundColor: colors.primary.background,
flexGrow: 1,
alignSelf: "center"
}}
>
<Input
fwdRef={emailInputRef}
onChangeText={(value) => {
email.current = value;
}}
defaultValue={email.current}
testID="input.email"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
validationType="email"
autoCorrect={false}
autoCapitalize="none"
errorMessage={strings.emailInvalid()}
placeholder={strings.email()}
blurOnSubmit={false}
onSubmit={() => {
if (!email.current) return;
passwordInputRef.current?.focus();
}}
/>
<Input
fwdRef={passwordInputRef}
onChangeText={(value) => {
password.current = value;
}}
defaultValue={password.current}
testID="input.password"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
secureTextEntry
autoComplete="password"
autoCapitalize="none"
blurOnSubmit={false}
validationType="password"
autoCorrect={false}
placeholder={strings.password()}
onSubmit={() => {
if (!password.current) return;
confirmPasswordInputRef.current?.focus();
}}
/>
<Input
fwdRef={confirmPasswordInputRef}
onChangeText={(value) => {
confirmPassword.current = value;
}}
defaultValue={confirmPassword.current}
testID="input.confirmPassword"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Signup"
returnKeyType="done"
secureTextEntry
autoComplete="password"
autoCapitalize="none"
autoCorrect={false}
blurOnSubmit={false}
validationType="confirmPassword"
customValidator={() => password.current!}
placeholder={strings.confirmPassword()}
marginBottom={12}
onSubmit={() => {
signup();
}}
/>
<Button
title={!loading ? "Continue" : null}
type="accent"
loading={loading}
onPress={() => {
signup();
}}
width="100%"
/>
<TouchableOpacity
onPress={() => {
if (loading) return;
changeMode(0);
}}
activeOpacity={0.8}
<View
style={{
gap: Spacing.LEVEL_2,
paddingBottom: Spacing.LEVEL_4
}}
>
<Input
fwdRef={emailInputRef}
onChangeText={(value) => {
email.current = value;
}}
defaultValue={email.current}
label={strings.email()}
testID="input.email"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
validationType="email"
autoCorrect={false}
autoCapitalize="none"
errorMessage={strings.emailInvalid()}
placeholder="you@example.com"
blurOnSubmit={false}
onSubmit={() => {
if (!email.current) return;
passwordInputRef.current?.focus();
}}
/>
<Input
fwdRef={passwordInputRef}
onChangeText={(value) => {
password.current = value;
}}
defaultValue={password.current}
testID="input.password"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
secureTextEntry
autoComplete="password"
autoCapitalize="none"
blurOnSubmit={false}
validationType="password"
autoCorrect={false}
label={strings.password()}
placeholder="•••••••••"
onSubmit={() => {
if (!password.current) return;
confirmPasswordInputRef.current?.focus();
}}
/>
<Input
fwdRef={confirmPasswordInputRef}
onChangeText={(value) => {
confirmPassword.current = value;
}}
defaultValue={confirmPassword.current}
testID="input.confirmPassword"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Signup"
returnKeyType="done"
secureTextEntry
autoComplete="password"
autoCapitalize="none"
autoCorrect={false}
blurOnSubmit={false}
validationType="confirmPassword"
customValidator={() => password.current || ""}
errorMessage={strings.passwordNotMatched()}
label={strings.confirmPassword()}
placeholder="•••••••••"
onSubmit={() => {
signup();
}}
/>
</View>
<View
style={{
width: DDS.isTab ? "50%" : "100%",
backgroundColor: colors.primary.background,
flexGrow: 1,
alignSelf: "center",
marginTop: 12,
paddingVertical: 12
gap: Spacing.LEVEL_2
}}
>
<Paragraph
size={AppFontSize.xs + 1}
color={colors.secondary.paragraph}
>
{strings.alreadyHaveAccount()}{" "}
<Paragraph
size={AppFontSize.xs + 1}
style={{ color: colors.primary.accent }}
>
{strings.login()}
</Paragraph>
</Paragraph>
</TouchableOpacity>
</View>
<Button
title={!loading ? "Continue" : null}
type="accent"
loading={loading}
onPress={() => {
signup();
}}
width="100%"
/>
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP,
width: DDS.isTab ? "50%" : "100%",
alignSelf: "center"
}}
>
<Paragraph
<TouchableOpacity
onPress={() => {
if (loading) return;
changeMode(0);
}}
activeOpacity={0.8}
style={{
alignSelf: "center"
}}
>
<Paragraph fontSize="SM" color={colors.primary.paragraph}>
{strings.alreadyHaveAccount()}{" "}
<Paragraph
fontSize="SM"
fontFamily="SEMI_BOLD"
style={{ color: colors.primary.accent }}
>
{strings.login()}
</Paragraph>
</Paragraph>
</TouchableOpacity>
<View
style={{
marginTop: Spacing.LEVEL_3,
justifyContent: "center",
alignItems: "center"
}}
>
<ErrorContainer inputRef={emailInputRef} />
<ErrorContainer inputRef={confirmPasswordInputRef} />
</View>
</View>
<View
style={{
marginBottom: 25,
textAlign: "center"
paddingHorizontal: DefaultAppStyles.GAP,
width: DDS.isTab ? "50%" : "100%",
alignSelf: "center"
}}
size={AppFontSize.xxs}
color={colors.secondary.paragraph}
>
{strings.signupAgreement[0]()}
<Paragraph
size={AppFontSize.xxs}
onPress={() => {
openLinkInBrowser("https://notesnook.com/tos");
}}
style={{
textDecorationLine: "underline"
marginBottom: 25,
textAlign: "center"
}}
color={colors.primary.accent}
fontSize="XS"
color={colors.primary.paragraph}
>
{" "}
{strings.signupAgreement[1]()}
</Paragraph>{" "}
{strings.signupAgreement[2]()}
<Paragraph
size={AppFontSize.xxs}
onPress={() => {
openLinkInBrowser("https://notesnook.com/privacy");
}}
style={{
textDecorationLine: "underline"
}}
color={colors.primary.accent}
>
{" "}
{strings.signupAgreement[3]()}
</Paragraph>{" "}
{strings.signupAgreement[4]()}
</Paragraph>
{strings.signupAgreement[0]()}
<Paragraph
fontSize="XS"
onPress={() => {
openLinkInBrowser("https://notesnook.com/tos");
}}
style={{
textDecorationLine: "underline"
}}
color={colors.primary.accent}
>
{" "}
{strings.signupAgreement[1]()}
</Paragraph>{" "}
{strings.signupAgreement[2]()}
<Paragraph
fontSize="XS"
onPress={() => {
openLinkInBrowser("https://notesnook.com/privacy");
}}
style={{
textDecorationLine: "underline"
}}
color={colors.primary.accent}
>
{" "}
{strings.signupAgreement[3]()}
</Paragraph>{" "}
{strings.signupAgreement[4]()}
</Paragraph>
</View>
</View>
</View>
</InputErrorProvider>
</KeyboardAwareScrollView>
</>
) : (
<>
<View
style={{
paddingHorizontal: Spacing.LEVEL_3
}}
>
<ProgressPills activePillIndex={2} />
<Loading
title={"Setting up your account..."}
svgSrc={SETTING_ACCOUNT_SVG}
description="Your account is almost ready, please wait..."
style={{
height: undefined,
marginTop: Spacing.LEVEL_6
}}
/>
</>
</View>
)}
</SignupContext.Provider>
);

View File

@@ -21,20 +21,19 @@ import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { TextInput, View } from "react-native";
import { ScrollView } from "react-native-actions-sheet";
import { db } from "../../common/database/index";
import { Radius, Spacing } from "../../common/design/spacing";
import useTimer from "../../hooks/use-timer";
import { eSendEvent, ToastManager } from "../../services/event-manager";
import { eCloseSimpleDialog } from "../../utils/events";
import { ToastManager } from "../../services/event-manager";
import { hexToRGBA, RGB_Linear_Shade } from "../../utils/colors";
import { AppFontSize } from "../../utils/size";
import { presentDialog } from "../dialog/functions";
import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
import Input from "../ui/input";
import PinInput from "../ui/pin-input/index";
import { Pressable } from "../ui/pressable";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { DefaultAppStyles } from "../../utils/styles";
import { presentDialog } from "../dialog/functions";
type MFAInfo = {
primaryMethod: string;
@@ -70,6 +69,10 @@ const TwoFactorVerification = ({
const [loading, setLoading] = useState(false);
const inputRef = useRef<TextInput>(null);
const [sending, setSending] = useState(false);
const [codeInput, setCodeInput] = useState("");
const isRecoveryCode = currentMethod.method === "recoveryCode";
const codeLength = isRecoveryCode ? 10 : 6;
const onNext = async () => {
if (!code.current || code.current.length < 6 || !currentMethod.method)
@@ -81,10 +84,7 @@ const TwoFactorVerification = ({
method: currentMethod.method,
code: code.current
},
(result) => {
if (result) {
eSendEvent(eCloseSimpleDialog, "two_factor_verify");
}
() => {
setLoading(false);
}
);
@@ -102,12 +102,14 @@ const TwoFactorVerification = ({
{
id: "sms",
title: strings.sendCodeSms(),
icon: "message-plus-outline"
icon: "chat",
iconFamily: "notesnook"
},
{
id: "email",
title: strings.sendCodeEmail(),
icon: "email-outline"
icon: "envelope-simple",
iconFamily: "notesnook"
},
{
id: "app",
@@ -117,7 +119,8 @@ const TwoFactorVerification = ({
{
id: "recoveryCode",
title: strings.recoveryCode(),
icon: "key"
icon: "lock-simple",
iconFamily: "notesnook"
}
];
@@ -149,48 +152,52 @@ const TwoFactorVerification = ({
}
}, [currentMethod.method, onSendCode]);
useEffect(() => {
setCodeInput("");
code.current = "";
}, [currentMethod.method]);
return (
<ScrollView
keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
style={{
width: "100%",
height: "100%",
backgroundColor: colors.primary.background,
paddingTop: 60
}}
<View
onLayout={() => {
setTimeout(() => {
inputRef.current?.focus();
}, 500);
}}
style={{
alignItems: "center",
gap: Spacing.LEVEL_3
}}
>
<View
style={{
alignItems: "center",
paddingHorizontal: currentMethod.method ? 12 : 0,
gap: 12
paddingHorizontal: Spacing.LEVEL_3,
width: "100%"
}}
>
<IconButton
style={{
width: 70,
height: 70
width: 50,
height: 50,
backgroundColor: colors.primary.shade,
borderRadius: Radius.XS,
marginBottom: Spacing.LEVEL_7
}}
size={50}
name="key"
size={25}
iconFamily="notesnook"
name="shield-check"
color={colors.primary.accent}
/>
<Heading
style={{
textAlign: "center"
textAlign: "center",
marginBottom: Spacing.LEVEL_1
}}
>
{currentMethod.method ? strings["2fa"]() : strings.select2faMethod()}
</Heading>
<Paragraph
style={{
width: "80%",
textAlign: "center"
}}
>
@@ -200,135 +207,160 @@ const TwoFactorVerification = ({
]?.() || strings.select2faCodeHelpText()
: strings.select2faCodeHelpText()}
</Paragraph>
</View>
{currentMethod.method === "sms" || currentMethod.method === "email" ? (
<Button
onPress={onSendCode}
type={seconds ? "plain" : "transparent"}
title={
sending
? ""
: `${
seconds
? strings.resend2faCode(`${seconds}`)
: strings.sendCode()
}`
}
loading={sending}
height={30}
/>
) : null}
{currentMethod.method ? (
<>
<Input
placeholder={
currentMethod.method === "recoveryCode"
? "xxxxx-xxxxx"
: "xxxxxx"
}
{currentMethod.method ? (
<>
<View
style={{
borderRadius: Radius.S,
borderWidth: 1,
borderColor: colors.primary.border,
paddingVertical: Spacing.LEVEL_4,
paddingHorizontal: Spacing.LEVEL_3,
width: "100%",
gap: Spacing.LEVEL_4
}}
>
<PinInput
testID={"input.totp"}
maxLength={
currentMethod.method === "recoveryCode" ? undefined : 6
}
fwdRef={inputRef}
textAlign="center"
onChangeText={(value) => {
inputRef={inputRef}
length={codeLength}
value={codeInput}
onChangeText={(value: string) => {
setCodeInput(value);
code.current = value;
}}
cursorColor={colors.selected.accent}
selectionHandleColor={colors.selected.accent}
selectionColor={colors.selected.accent}
onSubmitEditing={onNext}
height={60}
inputStyle={{
fontSize: AppFontSize.lg,
textAlign: "center",
letterSpacing: 7,
width: 250
}}
keyboardType={
currentMethod.method === "recoveryCode" ? "default" : "numeric"
}
enablesReturnKeyAutomatically
containerStyle={{
minWidth: "50%"
}}
wrapperStyle={{
height: 60
keyboardType={isRecoveryCode ? "default" : "number-pad"}
sanitize={(value: string) => {
if (isRecoveryCode) {
return value.replace(/[^0-9a-zA-Z]/g, "").toUpperCase();
}
return value.replace(/[^0-9]/g, "");
}}
/>
<Button
title={loading ? null : strings.next()}
type="accent"
width={250}
loading={loading}
onPress={onNext}
/>
<Button
title={strings.cancel()}
type="secondaryAccented"
onPress={() => {
reset();
onCancel();
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_2
}}
width={250}
/>
<Button
title={strings["2faCodeSecondaryMethodText"][
currentMethod.method as keyof (typeof strings)["2faCodeSecondaryMethodText"]
]()}
type="plain"
onPress={onRequestSecondaryMethod}
height={30}
/>
</>
) : (
<>
{getMethods().map((item) => (
<Pressable
key={item.title}
>
<Button
title={strings.cancel()}
type="secondary"
onPress={() => {
setCurrentMethod({
method: item.id,
isPrimary: false
});
reset();
onCancel();
}}
style={{
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL,
marginTop: 0,
flexDirection: "row",
borderRadius: 0,
alignItems: "center",
width: "100%",
justifyContent: "flex-start"
width: "48%"
}}
/>
<Button
title={loading ? null : strings.continue()}
type="accent"
loading={loading}
onPress={onNext}
style={{
width: "48%"
}}
/>
</View>
{currentMethod.method === "sms" ||
currentMethod.method === "email" ? (
<Button
onPress={onSendCode}
type={"plain"}
disabled={!seconds}
title={
sending
? ""
: `${
seconds
? strings.resend2faCode(`${seconds}`)
: strings.resendCode()
}`
}
loading={sending}
fontSize={AppFontSize.sm}
fontFamily="REGULAR"
style={{
paddingVertical: 0,
alignSelf: "flex-start",
paddingHorizontal: 0
}}
/>
) : null}
</View>
<Button
title={strings["2faCodeSecondaryMethodText"][
currentMethod.method as keyof (typeof strings)["2faCodeSecondaryMethodText"]
]()}
type="plain"
onPress={onRequestSecondaryMethod}
height={30}
/>
</>
) : (
<View
style={{
gap: Spacing.LEVEL_2,
width: "100%"
}}
>
{getMethods().map((item) => (
<Pressable
key={item.title}
onPress={() => {
setCurrentMethod({
method: item.id,
isPrimary: false
});
}}
style={{
padding: Spacing.LEVEL_2,
backgroundColor: colors.secondary.background,
flexDirection: "row",
borderRadius: Radius.S,
alignItems: "center",
width: "100%",
justifyContent: "flex-start",
gap: Spacing.LEVEL_1
}}
>
<IconButton
style={{
borderRadius: Radius.XS,
padding: Spacing.LEVEL_1,
width: undefined,
height: undefined,
backgroundColor: RGB_Linear_Shade(
0.04,
hexToRGBA(colors.secondary.background)
)
}}
size={17}
color={colors.primary.icon}
name={item.icon}
iconFamily={item.iconFamily as "notesnook"}
/>
<View
style={{
flexShrink: 1
}}
>
<IconButton
type="secondaryAccented"
style={{
marginRight: 10
}}
size={15}
color={colors.primary.accent}
name={item.icon}
/>
<View
style={{
flexShrink: 1
}}
>
<Paragraph size={AppFontSize.md}>{item.title}</Paragraph>
</View>
</Pressable>
))}
</>
)}
</View>
</ScrollView>
<Paragraph size={AppFontSize.sm}>{item.title}</Paragraph>
</View>
</Pressable>
))}
</View>
)}
</View>
);
};

View File

@@ -31,8 +31,7 @@ import TwoFactorVerification from "./two-factor";
export const LoginSteps = {
emailAuth: 1,
mfaAuth: 2,
passwordAuth: 3
mfaAuth: 2
};
export const useLogin = (
@@ -47,12 +46,10 @@ export const useLogin = (
const password = useRef<string>(undefined);
const emailInputRef = useRef<TextInput>(null);
const passwordInputRef = useRef<TextInput>(null);
const mfaData = useRef<any>(null);
const validateInfo = () => {
if (
(!password.current && step === LoginSteps.passwordAuth) ||
(!email.current && step === LoginSteps.emailAuth)
) {
if (!password.current || !email.current) {
ToastManager.show({
heading: strings.allFieldsRequired(),
message: strings.allFieldsRequiredDesc(),
@@ -78,47 +75,16 @@ export const useLogin = (
return;
}
const mfaInfo = await db.user.authenticateEmail(email.current);
if (mfaInfo) {
TwoFactorVerification.present(
async (mfa: any, callback: (success: boolean) => void) => {
try {
const success = await db.user.authenticateMultiFactorCode(
mfa.code,
mfa.method
);
if (success) {
setStep(LoginSteps.passwordAuth);
setLoading(false);
setTimeout(() => {
passwordInputRef.current?.focus();
}, 500);
callback && callback(true);
}
callback && callback(false);
} catch (e) {
callback && callback(false);
if ((e as Error).message === "invalid_grant") {
eSendEvent(eCloseSimpleDialog, "two_factor_verify");
setLoading(false);
setStep(LoginSteps.emailAuth);
}
}
},
mfaInfo,
() => {
eSendEvent(eCloseSimpleDialog, "two_factor_verify");
setLoading(false);
setStep(LoginSteps.emailAuth);
}
);
mfaData.current = mfaInfo;
setStep(LoginSteps.mfaAuth);
setLoading(false);
} else {
finishWithError(new Error(strings.unableToSend2faCode()));
}
break;
}
case LoginSteps.passwordAuth: {
case LoginSteps.mfaAuth: {
if (!email.current || !password.current) {
setLoading(false);
return;
@@ -181,6 +147,7 @@ export const useLogin = (
loading,
setLoading,
error,
setError
setError,
mfaData
};
};

View File

@@ -136,7 +136,7 @@ const BaseDialog = ({
? background
: transparent
? "transparent"
: "rgba(0,0,0,0.3)"
: "rgba(0,0,0,0.1)"
}}
>
<KeyboardAvoidingView

View File

@@ -28,6 +28,7 @@ import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { Button, ButtonProps } from "../ui/button";
import Paragraph from "../ui/typography/paragraph";
import { Spacing } from "../../common/design/spacing";
const DialogButtons = ({
onPressPositive,
@@ -51,21 +52,14 @@ const DialogButtons = ({
return (
<View
style={[
styles.container,
{
backgroundColor: colors.secondary.background,
height: 60,
paddingHorizontal: DefaultAppStyles.GAP,
borderTopWidth: 0.7,
borderTopColor: getColorLinearShade(
colors.secondary.background,
0.05,
isDark
)
flexDirection: "row",
gap: Spacing.LEVEL_2,
paddingHorizontal: Spacing.LEVEL_4
}
]}
>
{doneText ? (
{/* {doneText ? (
<View
style={{
flexDirection: "row",
@@ -81,37 +75,32 @@ const DialogButtons = ({
</View>
) : (
<View />
)}
)} */}
<View
<Button
onPress={onPressNegative}
fontSize={AppFontSize.sm}
testID={notesnook.ids.default.dialog.no}
type="plain-outline"
style={{
flexDirection: "row",
alignItems: "center"
width: "48.5%"
}}
>
title={negativeTitle}
/>
{onPressPositive ? (
<Button
onPress={onPressNegative}
onPress={onPressPositive}
fontSize={AppFontSize.sm}
testID={notesnook.ids.default.dialog.no}
type="plain"
testID={notesnook.ids.default.dialog.yes}
style={{
width: "48.5%"
}}
loading={loading}
bold
title={negativeTitle}
type={positiveType || "accent"}
title={positiveTitle}
/>
{onPressPositive ? (
<Button
onPress={onPressPositive}
fontSize={AppFontSize.sm}
testID={notesnook.ids.default.dialog.yes}
style={{
marginLeft: 10
}}
loading={loading}
bold
type={positiveType || "transparent"}
title={positiveTitle}
/>
) : null}
</View>
) : null}
</View>
);
};

View File

@@ -23,6 +23,7 @@ import { DDS } from "../../services/device-detection";
import { useThemeColors } from "@notesnook/theme";
import { getElevationStyle } from "../../utils/elevation";
import { getContainerBorder } from "../../utils/colors";
import { Radius } from "../../common/design/spacing";
const DialogContainer = ({
width,
@@ -44,7 +45,7 @@ const DialogContainer = ({
{
width: width || DDS.isTab ? 500 : "85%",
maxHeight: height || 450,
borderRadius: 10,
borderRadius: Radius.LG,
backgroundColor: colors.primary.background,
paddingTop: 12
},

View File

@@ -57,7 +57,6 @@ const DialogHeader = ({
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
minHeight: 50,
paddingHorizontal: padding,
...style
}}
@@ -76,7 +75,7 @@ const DialogHeader = ({
>
<Heading
style={{ textAlign: centered ? "center" : "left" }}
size={AppFontSize.lg}
fontSize="XL"
>
{title}{" "}
{titlePart ? (

View File

@@ -44,6 +44,7 @@ export type DialogInfo = {
icon?: string;
paragraphColor: string;
input: boolean;
inputLabel?: string;
inputPlaceholder: string;
defaultValue: string;
// eslint-disable-next-line @typescript-eslint/ban-types

View File

@@ -40,6 +40,7 @@ import BaseDialog from "./base-dialog";
import DialogButtons from "./dialog-buttons";
import DialogHeader from "./dialog-header";
import { DialogInfo } from "./functions";
import { Spacing } from "../../common/design/spacing";
export const Dialog = ({ context = "global" }: { context?: string }) => {
const { colors } = useThemeColors();
@@ -122,7 +123,7 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
maxHeight: 450,
borderRadius: defaultBorderRadius,
backgroundColor: colors.primary.background,
paddingTop: 12,
gap: Spacing.LEVEL_4,
...getContainerBorder(colors.primary.border, 0.5),
overflow: "hidden"
};
@@ -137,9 +138,7 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
bounce={!dialogInfo.input}
closeOnTouch={!dialogInfo.disableBackdropClosing}
background={dialogInfo.background}
transparent={
dialogInfo.transparent === undefined ? true : dialogInfo.transparent
}
transparent={dialogInfo.transparent}
onShow={async () => {
if (dialogInfo.input) {
inputRef.current?.setNativeProps({
@@ -157,25 +156,33 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
: dialogInfo.component}
{dialogInfo.component ? null : (
<View style={style}>
<DialogHeader
title={dialogInfo.title}
icon={dialogInfo.icon}
paragraph={dialogInfo.paragraph}
paragraphColor={dialogInfo.paragraphColor}
padding={12}
style={{
minHeight: 0
}}
/>
<Seperator half />
{dialogInfo.input ? (
<View
<View
style={[
{
paddingVertical: Spacing.LEVEL_4
},
style
]}
>
<View
style={[
{
paddingHorizontal: Spacing.LEVEL_3,
gap: Spacing.LEVEL_4
}
]}
>
<DialogHeader
title={dialogInfo.title}
icon={dialogInfo.icon}
paragraph={dialogInfo.paragraph}
paragraphColor={dialogInfo.paragraphColor}
style={{
paddingHorizontal: DefaultAppStyles.GAP
minHeight: 0
}}
>
/>
{dialogInfo.input ? (
<Input
fwdRef={inputRef}
autoCapitalize="none"
@@ -184,6 +191,7 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
}}
testID="input-value"
secureTextEntry={dialogInfo.secureTextEntry}
label={dialogInfo.inputLabel}
//defaultValue={dialogInfo.defaultValue}
onSubmit={() => {
onPressPositive();
@@ -193,48 +201,47 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
keyboardType={dialogInfo.keyboardType || "default"}
placeholder={dialogInfo.inputPlaceholder}
/>
</View>
) : null}
) : null}
{dialogInfo?.notice ? (
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP
}}
>
<Notice
type={dialogInfo.notice.type || "information"}
text={dialogInfo.notice.text}
/>
</View>
) : null}
{dialogInfo.check ? (
<>
<Button
onPress={() => {
setChecked(!checked);
}}
icon={
checked
? "check-circle-outline"
: "checkbox-blank-circle-outline"
}
iconColor={
checked ? colors.secondary.icon : colors.primary.icon
}
{dialogInfo?.notice ? (
<View
style={{
justifyContent: "flex-start"
paddingHorizontal: DefaultAppStyles.GAP
}}
height={35}
iconSize={20}
width="100%"
title={dialogInfo.check.info}
type={checked ? dialogInfo.check.type || "plain" : "plain"}
/>
</>
) : null}
>
<Notice
type={dialogInfo.notice.type || "information"}
text={dialogInfo.notice.text}
/>
</View>
) : null}
{dialogInfo.check ? (
<>
<Button
onPress={() => {
setChecked(!checked);
}}
icon={
checked
? "check-circle-outline"
: "checkbox-blank-circle-outline"
}
iconColor={
checked ? colors.secondary.icon : colors.primary.icon
}
style={{
justifyContent: "flex-start"
}}
height={35}
iconSize={20}
width="100%"
title={dialogInfo.check.info}
type={checked ? dialogInfo.check.type || "plain" : "plain"}
/>
</>
) : null}
</View>
<DialogButtons
onPressNegative={onNegativePress}
onPressPositive={dialogInfo.positivePress && onPressPositive}

View File

@@ -17,25 +17,24 @@ 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 { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useCallback, useEffect, useState } from "react";
import { View } from "react-native";
import { notesnook } from "../../../e2e/test.ids";
import { Radius, Spacing } from "../../common/design/spacing";
import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
import Navigation from "../../services/navigation";
import { RouteName } from "../../stores/use-navigation-store";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { eScrollEvent } from "../../utils/events";
import { AppFontSize } from "../../utils/size";
import { fluidTabsRef } from "../../utils/global-refs";
import { DefaultAppStyles } from "../../utils/styles";
import { IconButtonProps } from "../ui/icon-button";
import { Pressable } from "../ui/pressable";
import { IconButton, IconButtonProps } from "../ui/icon-button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { LeftMenus } from "./left-menus";
import { RightMenus } from "./right-menus";
export const Header = ({
renderedInRoute,
@@ -64,6 +63,9 @@ export const Header = ({
state.selectionMode
]);
const deviceMode = useSettingStore((state) => state.deviceMode);
const isTablet = deviceMode === "tablet";
const onScroll = useCallback(
(data: { x: number; y: number; id?: string; route: string }) => {
if (data.route !== renderedInRoute || data.id !== id) return;
@@ -85,34 +87,58 @@ export const Header = ({
};
}, [borderHidden, onScroll]);
const HeaderWrapper = hasSearch ? Pressable : View;
const _onLeftButtonPress = () => {
if (onLeftMenuButtonPress) return onLeftMenuButtonPress();
if (!canGoBack) {
if (fluidTabsRef.current?.isDrawerOpen()) {
Navigation.closeDrawer();
} else {
Navigation.openDrawer();
}
return;
}
Navigation.goBack();
};
return (
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP
paddingHorizontal: DefaultAppStyles.GAP,
marginBottom: Spacing.LEVEL_3
}}
>
<HeaderWrapper
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
borderRadius: 10,
paddingVertical: 3,
borderWidth: hasSearch ? 1 : 0,
borderColor: colors.primary.border,
paddingHorizontal: !hasSearch ? 0 : DefaultAppStyles.GAP_SMALL,
borderRadius: Radius.S,
paddingHorizontal: Spacing.LEVEL_2,
paddingVertical: Spacing.LEVEL_3,
backgroundColor: colors.secondary.background,
alignItems: "center"
}}
testID="search-header"
onPress={() => {
onSearch?.();
}}
>
<LeftMenus
canGoBack={canGoBack}
onLeftButtonPress={onLeftMenuButtonPress}
/>
{isTablet && !canGoBack ? null : (
<IconButton
testID={notesnook.ids.default.header.buttons.left}
left={40}
top={40}
onPress={_onLeftButtonPress}
onLongPress={() => {
Navigation.popToTop();
}}
style={{
width: 20,
height: 20
}}
size={20}
name={canGoBack ? "arrow-left" : "menu"}
iconFamily="notesnook"
color={colors.primary.icon}
/>
)}
{!title ? (
<View
@@ -123,18 +149,39 @@ export const Header = ({
borderRadius: 100
}}
/>
) : hasSearch ? (
<Paragraph>
{selectionMode
? `${selectedItemsList.length} selected`
: strings.searchInRoute(title)}
</Paragraph>
) : (
<Heading size={AppFontSize.lg}>{title}</Heading>
<Heading fontSize="XL">
{selectionMode ? `${selectedItemsList.length} selected` : title}
</Heading>
)}
<RightMenus rightButton={rightButton} />
</HeaderWrapper>
<View
style={{
flexDirection: "row",
alignItems: "center"
}}
>
{rightButton ? (
<IconButton {...rightButton} color={colors.primary.icon} />
) : null}
{hasSearch ? (
<IconButton
color={colors.primary.icon}
size={20}
onPress={() => {
onSearch?.();
}}
style={{
width: 20,
height: 20
}}
iconFamily="notesnook"
name="search"
/>
) : null}
</View>
</View>
</View>
);
};

View File

@@ -1,66 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { useThemeColors } from "@notesnook/theme";
import React from "react";
import { notesnook } from "../../../e2e/test.ids";
import Navigation from "../../services/navigation";
import { useSettingStore } from "../../stores/use-setting-store";
import { fluidTabsRef } from "../../utils/global-refs";
import { IconButton } from "../ui/icon-button";
export const LeftMenus = ({
canGoBack,
onLeftButtonPress
}: {
canGoBack?: boolean;
onLeftButtonPress?: () => void;
}) => {
const { colors } = useThemeColors();
const deviceMode = useSettingStore((state) => state.deviceMode);
const isTablet = deviceMode === "tablet";
const _onLeftButtonPress = () => {
if (onLeftButtonPress) return onLeftButtonPress();
if (!canGoBack) {
if (fluidTabsRef.current?.isDrawerOpen()) {
Navigation.closeDrawer();
} else {
Navigation.openDrawer();
}
return;
}
Navigation.goBack();
};
return isTablet && !canGoBack ? null : (
<IconButton
testID={notesnook.ids.default.header.buttons.left}
left={40}
top={40}
onPress={_onLeftButtonPress}
onLongPress={() => {
Navigation.popToTop();
}}
name={canGoBack ? "arrow-left" : "menu"}
color={colors.primary.icon}
/>
);
};

View File

@@ -0,0 +1,306 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 React from "react";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import Animated, {
Easing,
useAnimatedStyle,
useSharedValue,
withRepeat,
withSequence,
withSpring,
withTiming
} from "react-native-reanimated";
import Svg, {
Circle,
ClipPath,
Defs,
G,
Mask,
Path,
Rect
} from "react-native-svg";
const SPRING_CONFIG = {
damping: 14,
stiffness: 120,
mass: 0.8
};
// Each icon floats independently with a different phase/speed
function useFloatAnim(delay: number, range = 6) {
const y = useSharedValue(0);
React.useEffect(() => {
const start = () => {
y.value = withSequence(
withTiming(0, { duration: delay, easing: Easing.linear }),
withRepeat(
withSequence(
withTiming(-range, {
duration: 1600,
easing: Easing.inOut(Easing.sin)
}),
withTiming(range, {
duration: 1600,
easing: Easing.inOut(Easing.sin)
})
),
-1, // infinite
true // reverse
)
);
};
start();
}, []);
return y;
}
export const IntroIllustration = () => {
// Gesture-driven tilt
const tiltX = useSharedValue(0); // rotateX: finger up/down
const tiltY = useSharedValue(0); // rotateY: finger left/right
const translateX = useSharedValue(0);
const translateY = useSharedValue(0);
// Independent float offsets for each corner icon
const floatTR = useFloatAnim(0, 2); // top-right lock
const floatBR = useFloatAnim(500, 4); // bottom-right eye-off
const floatTL = useFloatAnim(260, 3); // top-left share
const floatBL = useFloatAnim(780, 2); // bottom-left document
const pan = Gesture.Pan()
.onUpdate((e) => {
// Clamp tilt to ±15 degrees and translate ±12 pts
tiltY.value = (e.translationX / 12) * 1;
tiltX.value = -(e.translationY / 12) * 1;
translateX.value = e.translationX * 0.08;
translateY.value = e.translationY * 0.08;
})
.onEnd(() => {
tiltX.value = withSpring(0, SPRING_CONFIG);
tiltY.value = withSpring(0, SPRING_CONFIG);
translateX.value = withSpring(0, SPRING_CONFIG);
translateY.value = withSpring(0, SPRING_CONFIG);
});
const containerStyle = useAnimatedStyle(() => ({
transform: [
{ perspective: 600 },
{ rotateX: `${tiltX.value}deg` },
{ rotateY: `${tiltY.value}deg` },
{ translateX: translateX.value },
{ translateY: translateY.value }
]
}));
// Derived animated styles for each floating icon
const styleTR = useAnimatedStyle(() => ({
transform: [{ translateY: floatTR.value }]
}));
const styleBR = useAnimatedStyle(() => ({
transform: [{ translateY: floatBR.value }]
}));
const styleTL = useAnimatedStyle(() => ({
transform: [{ translateY: floatTL.value }]
}));
const styleBL = useAnimatedStyle(() => ({
transform: [{ translateY: floatBL.value }]
}));
return (
<GestureDetector gesture={pan}>
<Animated.View style={containerStyle}>
<Svg width={243} height={210} viewBox="0 0 243 210" fill="none">
{/* ── Concentric background circles (static) ── */}
<Circle
cx={116}
cy={105}
r={104.75}
stroke="#1F2722"
strokeWidth={0.5}
/>
<Circle
cx={116.5}
cy={105.5}
r={95.25}
fill="#008836"
fillOpacity={0.09}
stroke="#233C2D"
strokeWidth={0.5}
/>
<Circle
cx={116.5}
cy={105.5}
r={82.25}
fill="#008836"
fillOpacity={0.09}
stroke="#233C2D"
strokeWidth={0.5}
/>
<Circle
cx={116.5}
cy={105.5}
r={62.25}
fill="#008836"
fillOpacity={0.08}
stroke="#233C2D"
strokeWidth={0.5}
/>
<Circle cx={116.5} cy={105.5} r={44.5} fill="#008836" />
{/* ── Defs ── */}
<Defs>
<ClipPath id="clip0">
<Rect width={45} height={45} x={94.5} y={83} />
</ClipPath>
<ClipPath id="clip1">
<Rect width={21.5} height={21.5} x={202.75} y={176.75} />
</ClipPath>
<Mask
id="mask0"
maskUnits="userSpaceOnUse"
x={91}
y={80}
width={52}
height={51}
>
<Path
d="M132.504 80.055H101.496C96.007 80.055 91.5574 84.5046 91.5574 89.9935V121.002C91.5574 126.491 96.007 130.94 101.496 130.94H132.504C137.993 130.94 142.443 126.491 142.443 121.002V89.9935C142.443 84.5046 137.993 80.055 132.504 80.055Z"
fill="white"
/>
</Mask>
</Defs>
{/* ── Centre logo (static) ── */}
<G clipPath="url(#clip0)">
<G mask="url(#mask0)">
<Path
d="M127.584 113.991C126.726 116.496 125.008 118.616 122.734 119.973C120.461 121.33 117.78 121.836 115.168 121.401C112.556 120.967 110.183 119.62 108.471 117.6C106.759 115.58 105.82 113.018 105.819 110.371V104.892L109.751 106.535V110.368C109.751 111.401 109.971 112.422 110.398 113.362C110.825 114.302 111.448 115.14 112.226 115.819C112.373 115.948 112.527 116.073 112.685 116.19C113.845 117.054 115.239 117.549 116.685 117.611C116.734 117.611 116.781 117.615 116.83 117.616C116.879 117.617 116.942 117.616 116.998 117.616H117.166C117.221 117.616 117.262 117.616 117.311 117.611C118.756 117.549 120.149 117.054 121.31 116.191C121.467 116.074 121.621 115.949 121.769 115.821C122.79 114.927 123.541 113.765 123.934 112.467L127.584 113.991ZM128.181 100.628V110.371C128.181 110.497 128.181 110.623 128.173 110.749L124.249 109.108V100.628C124.249 98.7551 123.523 96.9554 122.225 95.6055C120.928 94.2557 119.158 93.4604 117.287 93.3862C115.415 93.3121 113.588 93.9649 112.188 95.2078C110.787 96.4508 109.922 98.1875 109.773 100.054C109.759 100.243 109.751 100.435 109.751 100.628V103.048L105.819 101.405V89.4469H117C119.965 89.4469 122.809 90.6249 124.906 92.7217C127.003 94.8185 128.181 97.6624 128.181 100.628Z"
fill="white"
/>
</G>
</G>
</Svg>
{/* ── Floating corner icons rendered as absolute Animated.Views over the SVG ── */}
{/* Top-left — share */}
<Animated.View
style={[{ position: "absolute", top: 0, left: -10 }, styleTL]}
>
<Svg width={47} height={47} viewBox="0 0 47 47" fill="none">
<Rect
x={0.25}
y={0.25}
width={46.5}
height={46.5}
rx={7.75}
fill="#1A1D1B"
stroke="#233C2D"
strokeWidth={0.5}
/>
<Rect width={22} height={22} x={13} y={12} fill="#171F1A" />
<Path
d="M28.125 25.75C27.6663 25.7499 27.2124 25.8417 26.7899 26.0202C26.3674 26.1987 25.9851 26.4601 25.6654 26.789L21.7037 24.2427C22.0153 23.4435 22.0153 22.5565 21.7037 21.7573L25.6654 19.211C26.2605 19.8206 27.0607 20.1875 27.911 20.2406C28.7612 20.2937 29.6008 20.0292 30.2671 19.4984C30.9334 18.9675 31.3788 18.2082 31.5171 17.3677C31.6554 16.5271 31.4766 15.6651 31.0154 14.9488C30.5542 14.2326 29.8435 13.7131 29.0211 13.4911C28.1987 13.269 27.3231 13.3603 26.5641 13.7472C25.8051 14.134 25.2169 14.7889 24.9133 15.5849C24.6098 16.3808 24.6126 17.2612 24.9212 18.0552L20.9595 20.6015C20.4824 20.1117 19.8701 19.7753 19.2009 19.6353C18.5317 19.4953 17.8359 19.5581 17.2025 19.8156C16.5691 20.0731 16.0269 20.5136 15.6452 21.0808C15.2635 21.6481 15.0596 22.3163 15.0596 23C15.0596 23.6837 15.2635 24.3519 15.6452 24.9192C16.0269 25.4864 16.5691 25.9269 17.2025 26.1844C17.8359 26.4419 18.5317 26.5047 19.2009 26.3647C19.8701 26.2247 20.4824 25.8883 20.9595 25.3985L24.9212 27.9448C24.6558 28.6294 24.6165 29.3809 24.8091 30.0893C25.0018 30.7978 25.4161 31.4259 25.9916 31.8819C26.567 32.3378 27.2733 32.5975 28.007 32.6229C28.7408 32.6484 29.4634 32.4383 30.069 32.0233C30.6747 31.6084 31.1316 31.0105 31.3729 30.3171C31.6141 29.6237 31.627 28.8712 31.4097 28.17C31.1924 27.4687 30.7562 26.8554 30.1652 26.42C29.5741 25.9845 28.8591 25.7497 28.125 25.75ZM28.125 14.75C28.5329 14.75 28.9317 14.871 29.2708 15.0976C29.61 15.3242 29.8744 15.6463 30.0305 16.0232C30.1866 16.4001 30.2274 16.8148 30.1478 17.2149C30.0683 17.615 29.8718 17.9825 29.5834 18.2709C29.2949 18.5594 28.9274 18.7558 28.5273 18.8354C28.1273 18.915 27.7126 18.8741 27.3357 18.718C26.9588 18.5619 26.6367 18.2975 26.4101 17.9584C26.1834 17.6192 26.0625 17.2204 26.0625 16.8125C26.0625 16.2655 26.2798 15.7409 26.6666 15.3541C27.0533 14.9673 27.578 14.75 28.125 14.75ZM18.5 25.0625C18.092 25.0625 17.6933 24.9415 17.3541 24.7149C17.0149 24.4883 16.7506 24.1662 16.5945 23.7893C16.4384 23.4124 16.3975 22.9977 16.4771 22.5976C16.5567 22.1975 16.7531 21.83 17.0416 21.5416C17.33 21.2532 17.6975 21.0567 18.0976 20.9771C18.4977 20.8976 18.9124 20.9384 19.2892 21.0945C19.6661 21.2506 19.9882 21.515 20.2149 21.8541C20.4415 22.1933 20.5625 22.5921 20.5625 23C20.5625 23.547 20.3452 24.0716 19.9584 24.4584C19.5716 24.8452 19.047 25.0625 18.5 25.0625ZM28.125 31.25C27.717 31.25 27.3183 31.129 26.9791 30.9024C26.6399 30.6758 26.3756 30.3537 26.2195 29.9768C26.0634 29.5999 26.0225 29.1852 26.1021 28.7851C26.1817 28.385 26.3781 28.0175 26.6666 27.7291C26.955 27.4407 27.3225 27.2442 27.7226 27.1646C28.1227 27.0851 28.5374 27.1259 28.9142 27.282C29.2911 27.4381 29.6132 27.7025 29.8399 28.0416C30.0665 28.3808 30.1875 28.7796 30.1875 29.1875C30.1875 29.7345 29.9702 30.2591 29.5834 30.6459C29.1966 31.0327 28.672 31.25 28.125 31.25Z"
fill="#008836"
/>
</Svg>
</Animated.View>
{/* Top-right — lock */}
<Animated.View
style={[{ position: "absolute", top: 28, right: -5 }, styleTR]}
>
<Svg width={32} height={32} viewBox="0 0 32 32" fill="none">
<Rect
x={0.25}
y={0.25}
width={31.5}
height={31.5}
rx={7.75}
fill="#1A1D1B"
stroke="#233C2D"
strokeWidth={0.5}
/>
<Path
d="M16 14.125C15.475 14.1252 14.967 14.3144 14.57 14.658C14.172 15.0017 13.912 15.4769 13.836 15.9967C13.76 16.5165 13.874 17.0462 14.157 17.4891C14.439 17.9319 14.872 18.2583 15.375 18.4086V19.75C15.375 19.9158 15.441 20.0747 15.558 20.1919C15.675 20.3092 15.834 20.375 16 20.375C16.166 20.375 16.325 20.3092 16.442 20.1919C16.559 20.0747 16.625 19.9158 16.625 19.75V18.4086C17.128 18.2583 17.561 17.9319 17.843 17.4891C18.126 17.0462 18.24 16.5165 18.164 15.9967C18.088 15.4769 17.828 15.0017 17.43 14.658C17.033 14.3144 16.525 14.1252 16 14.125ZM16 17.25C15.815 17.25 15.633 17.195 15.479 17.092C15.325 16.989 15.205 16.8426 15.134 16.6713C15.063 16.5 15.044 16.3115 15.081 16.1296C15.117 15.9477 15.206 15.7807 15.337 15.6496C15.468 15.5185 15.635 15.4292 15.817 15.393C15.999 15.3568 16.187 15.3754 16.359 15.4464C16.53 15.5173 16.676 15.6375 16.78 15.7917C16.883 15.9458 16.937 16.1271 16.937 16.3125C16.937 16.5611 16.839 16.7996 16.663 16.9754C16.487 17.1512 16.249 17.25 16 17.25ZM22.25 11.625H19.75V9.75C19.75 8.7554 19.355 7.8016 18.652 7.0983C17.948 6.3951 16.995 6 16 6C15.005 6 14.052 6.3951 13.348 7.0983C12.645 7.8016 12.25 8.7554 12.25 9.75V11.625H9.75C9.418 11.625 9.101 11.7567 8.866 11.9911C8.632 12.2255 8.5 12.5435 8.5 12.875V21.625C8.5 21.9565 8.632 22.2745 8.866 22.5089C9.101 22.7433 9.418 22.875 9.75 22.875H22.25C22.582 22.875 22.899 22.7433 23.134 22.5089C23.368 22.2745 23.5 21.9565 23.5 21.625V12.875C23.5 12.5435 23.368 12.2255 23.134 11.9911C22.899 11.7567 22.582 11.625 22.25 11.625ZM13.5 9.75C13.5 9.087 13.763 8.4511 14.232 7.9822C14.701 7.5134 15.337 7.25 16 7.25C16.663 7.25 17.299 7.5134 17.768 7.9822C18.237 8.4511 18.5 9.087 18.5 9.75V11.625H13.5V9.75ZM22.25 21.625H9.75V12.875H22.25V21.625Z"
fill="#008836"
/>
</Svg>
</Animated.View>
{/* Bottom-left — document */}
<Animated.View
style={[{ position: "absolute", bottom: 0, left: 25 }, styleBL]}
>
<Svg width={35} height={35} viewBox="0 0 35 35" fill="none">
<Rect
x={0.25}
y={0.25}
width={34.5}
height={34.5}
rx={7.75}
fill="#1A1D1B"
stroke="#233C2D"
strokeWidth={0.5}
/>
<Rect
width={18.3333}
height={18.3333}
x={8.3334}
y={8.333}
fill="#171F1A"
/>
<Path
d="M23.6346 14.178L19.6242 10.168C19.5709 10.114 19.5077 10.072 19.4382 10.044C19.3686 10.015 19.2941 10 19.2188 10H12.3438C12.0399 10 11.7485 10.121 11.5336 10.336C11.3187 10.551 11.198 10.842 11.198 11.146V23.75C11.198 24.054 11.3187 24.345 11.5336 24.56C11.7485 24.775 12.0399 24.896 12.3438 24.896H22.6563C22.9602 24.896 23.2517 24.775 23.4666 24.56C23.6814 24.345 23.8022 24.054 23.8022 23.75V14.583C23.8022 14.508 23.7875 14.434 23.7587 14.364C23.7299 14.295 23.6878 14.231 23.6346 14.178ZM19.7917 11.956L21.8464 14.01H19.7917V11.956ZM22.6563 23.75H12.3438V11.146H18.6459V14.583C18.6459 14.735 18.7063 14.881 18.8137 14.989C18.9212 15.096 19.0669 15.156 19.2188 15.156H22.6563V23.75ZM20.3647 18.021C20.3647 18.173 20.3043 18.319 20.1969 18.426C20.0894 18.533 19.9437 18.594 19.7917 18.594H15.2084C15.0565 18.594 14.9107 18.533 14.8033 18.426C14.6959 18.319 14.6355 18.173 14.6355 18.021C14.6355 17.869 14.6959 17.723 14.8033 17.616C14.9107 17.508 15.0565 17.448 15.2084 17.448H19.7917C19.9437 17.448 20.0894 17.508 20.1969 17.616C20.3043 17.723 20.3647 17.869 20.3647 18.021ZM20.3647 20.313C20.3647 20.465 20.3043 20.61 20.1969 20.718C20.0894 20.825 19.9437 20.885 19.7917 20.885H15.2084C15.0565 20.885 14.9107 20.825 14.8033 20.718C14.6959 20.61 14.6355 20.465 14.6355 20.313C14.6355 20.161 14.6959 20.015 14.8033 19.907C14.9107 19.8 15.0565 19.74 15.2084 19.74H19.7917C19.9437 19.74 20.0894 19.8 20.1969 19.907C20.3043 20.015 20.3647 20.161 20.3647 20.313Z"
fill="#008836"
/>
</Svg>
</Animated.View>
{/* Bottom-right — eye-off */}
<Animated.View
style={[{ position: "absolute", bottom: 0, right: 5 }, styleBR]}
>
<Svg width={43} height={43} viewBox="0 0 43 43" fill="none">
<Rect
x={0.25}
y={0.25}
width={42.5}
height={42.5}
rx={7.75}
fill="#1A1D1B"
stroke="#233C2D"
strokeWidth={0.5}
/>
<G>
<Path
d="M15.028 3.408C14.969 3.341 14.898 3.287 14.818 3.248C14.738 3.21 14.651 3.187 14.562 3.182C14.473 3.178 14.384 3.191 14.301 3.22C14.217 3.25 14.14 3.296 14.074 3.356C14.008 3.416 13.955 3.488 13.917 3.569C13.88 3.649 13.858 3.737 13.855 3.825C13.851 3.914 13.865 4.003 13.896 4.086C13.926 4.17 13.973 4.246 14.034 4.311L15.65 6.089C12.6 7.961 11.288 10.847 11.23 10.978C11.192 11.064 11.172 11.157 11.172 11.251C11.172 11.345 11.192 11.438 11.23 11.524C11.259 11.59 11.971 13.167 13.552 14.749C15.659 16.855 18.321 17.969 21.25 17.969C22.756 17.977 24.246 17.667 25.623 17.059L27.471 19.092C27.53 19.159 27.601 19.213 27.681 19.252C27.761 19.29 27.848 19.313 27.937 19.317C28.026 19.322 28.115 19.309 28.199 19.28C28.282 19.25 28.359 19.204 28.425 19.144C28.491 19.084 28.544 19.012 28.582 18.931C28.62 18.851 28.641 18.763 28.645 18.675C28.648 18.586 28.634 18.497 28.604 18.414C28.573 18.33 28.526 18.254 28.465 18.189L15.028 3.408ZM19.003 9.777L22.503 13.628C21.976 13.905 21.372 13.999 20.785 13.896C20.199 13.793 19.663 13.497 19.263 13.057C18.862 12.616 18.62 12.055 18.573 11.461C18.526 10.868 18.677 10.275 19.003 9.777ZM21.25 16.625C18.665 16.625 16.407 15.685 14.537 13.833C13.77 13.07 13.117 12.2 12.6 11.25C12.993 10.512 14.251 8.446 16.576 7.103L18.088 8.762C17.503 9.511 17.201 10.443 17.237 11.394C17.273 12.344 17.643 13.251 18.283 13.955C18.923 14.658 19.791 15.113 20.733 15.238C21.676 15.364 22.633 15.152 23.434 14.64L24.672 16.001C23.58 16.42 22.419 16.631 21.25 16.625ZM21.754 8.61C21.579 8.577 21.424 8.475 21.324 8.328C21.224 8.181 21.186 7.999 21.22 7.824C21.253 7.649 21.355 7.495 21.502 7.394C21.65 7.294 21.831 7.257 22.006 7.29C22.862 7.456 23.642 7.895 24.229 8.54C24.815 9.185 25.178 10.003 25.262 10.871C25.279 11.049 25.224 11.225 25.11 11.363C24.997 11.5 24.833 11.586 24.656 11.603C24.635 11.604 24.614 11.604 24.593 11.603C24.425 11.603 24.263 11.541 24.138 11.428C24.014 11.316 23.936 11.16 23.921 10.993C23.864 10.416 23.623 9.872 23.232 9.442C22.842 9.013 22.323 8.721 21.754 8.61ZM31.268 11.524C31.232 11.603 30.382 13.486 28.466 15.202C28.4 15.263 28.324 15.31 28.24 15.34C28.156 15.371 28.067 15.384 27.978 15.38C27.889 15.376 27.802 15.354 27.721 15.316C27.641 15.277 27.569 15.223 27.509 15.157C27.45 15.091 27.404 15.013 27.375 14.929C27.346 14.845 27.334 14.755 27.339 14.666C27.345 14.577 27.368 14.491 27.408 14.411C27.447 14.331 27.502 14.26 27.57 14.201C28.51 13.357 29.299 12.359 29.905 11.25C29.386 10.299 28.732 9.429 27.963 8.666C26.093 6.815 23.835 5.875 21.25 5.875C20.705 5.874 20.162 5.918 19.624 6.007C19.537 6.022 19.447 6.02 19.36 6.001C19.274 5.982 19.192 5.945 19.119 5.894C19.047 5.843 18.985 5.778 18.938 5.703C18.891 5.627 18.859 5.544 18.844 5.456C18.83 5.369 18.833 5.279 18.853 5.193C18.873 5.106 18.91 5.025 18.962 4.953C19.014 4.88 19.079 4.819 19.155 4.773C19.231 4.726 19.315 4.695 19.402 4.682C20.013 4.581 20.631 4.53 21.25 4.531C24.179 4.531 26.841 5.645 28.948 7.752C30.529 9.333 31.241 10.912 31.27 10.978C31.308 11.064 31.328 11.157 31.328 11.251C31.328 11.345 31.308 11.438 31.27 11.524H31.268Z"
fill="#008836"
transform="translate(0, 10)"
/>
</G>
</Svg>
</Animated.View>
</Animated.View>
</GestureDetector>
);
};

View File

@@ -20,97 +20,92 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Linking, useWindowDimensions, View } from "react-native";
import { SwiperFlatList } from "react-native-swiper-flatlist";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { Linking, Platform, useWindowDimensions, View } from "react-native";
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
import { SafeAreaView } from "react-native-safe-area-context";
import { Spacing } from "../../common/design/spacing";
import useRotator from "../../hooks/use-rotator";
import Navigation from "../../services/navigation";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import SettingsService from "../../services/settings";
import { AuthMode } from "../auth/common";
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";
import { IntroIllustration } from "./illustration";
import { ProgressPills } from "./progress-pills";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
const Intro = () => {
const { colors } = useThemeColors();
const { width } = useWindowDimensions();
const insets = useGlobalSafeAreaInsets();
const isTablet = width > 600;
const rotator = useRotator([0, 1, 2], 10000, true);
const insets = useGlobalSafeAreaInsets();
const renderItem = React.useCallback(
({ item }: { item: (typeof strings.introData)[0] }) => (
<View
<Animated.View
entering={FadeIn}
exiting={FadeOut}
style={{
justifyContent: "center",
width: isTablet ? width / 2 : width,
paddingHorizontal: isTablet ? (width / 2) * 0.05 : width * 0.05
justifyContent: "flex-start"
}}
>
<View
style={{
flexDirection: "row"
gap: Spacing.LEVEL_2
}}
>
<View
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
borderRadius: 2,
marginRight: 7
}}
/>
{item.headings?.map((heading, index) =>
heading.bold ? (
<Heading
key={heading.value()}
fontFamily="SEMI_BOLD"
fontSize="XXL"
style={{
marginTop: index !== 0 ? -5 : undefined
}}
>
{heading.value()}
</Heading>
) : (
<Paragraph
style={{
marginTop: index !== 0 ? -5 : undefined
}}
fontFamily="MEDIUM"
fontSize="XL"
>
{heading.value()}
</Paragraph>
)
)}
<View
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
borderRadius: 2
}}
/>
</View>
<View
style={{
marginTop: DefaultAppStyles.GAP_VERTICAL,
maxWidth: "90%",
width: "100%"
}}
>
{item.headings?.map((heading) => (
<Heading
key={heading()}
style={{
marginBottom: 5
}}
extraBold
size={AppFontSize.xxl}
>
{heading()}
</Heading>
))}
{item.user ? (
<Paragraph fontFamily="MEDIUM" fontSize="XL">
{item.user}
</Paragraph>
) : null}
{item.body ? (
<Paragraph size={AppFontSize.sm}>{item.body()}</Paragraph>
<Paragraph color={colors.secondary.paragraph} fontSize="SM">
{item.body()}
</Paragraph>
) : null}
{item.tesimonial ? (
<Paragraph
style={{
fontStyle: "italic",
fontSize: AppFontSize.lg
}}
fontSize="SM"
color={colors.secondary.paragraph}
onPress={() => {
Linking.openURL(item.link);
// Linking.openURL(item.link);
}}
>
{item.tesimonial()} {item.user}
{item.tesimonial()}
</Paragraph>
) : null}
</View>
</View>
</Animated.View>
),
[colors.primary.accent, colors.secondary.background, isTablet, width]
);
@@ -126,17 +121,25 @@ const Intro = () => {
<View
testID="notesnook.splashscreen"
style={{
flex: 1
flex: 1,
paddingTop: Platform.OS === "android" ? 60 - insets.top : undefined
}}
>
<View
style={{
flexDirection: "row",
paddingHorizontal: Spacing.LEVEL_3
}}
>
<ProgressPills activePillIndex={0} />
</View>
<View
style={[
{
width: "100%",
borderBottomWidth: 1,
borderBottomColor: colors.primary.border,
paddingTop: insets.top + 10,
paddingBottom: insets.top + 10,
flexGrow: 1
},
isTablet && {
@@ -149,33 +152,34 @@ const Intro = () => {
}
]}
>
<SwiperFlatList
autoplay
autoplayDelay={10}
autoplayLoop={true}
index={0}
useReactNativeGestureHandler={true}
showPagination
data={strings.introData}
paginationActiveColor={colors.primary.accent}
paginationStyleItem={{
width: 10,
height: 5,
marginRight: 4,
marginLeft: 4
<View
style={{
alignItems: "center",
alignSelf: "center",
paddingVertical: Spacing.LEVEL_7
}}
paginationDefaultColor={colors.primary.border}
renderItem={renderItem}
/>
>
<IntroIllustration />
</View>
<View
style={{
paddingHorizontal: Spacing.LEVEL_3
}}
>
{strings.introData.map((item, index) =>
index !== rotator ? null : renderItem({ item })
)}
</View>
</View>
</View>
<View
style={{
width: isTablet ? "50%" : "100%",
justifyContent: "center",
gap: DefaultAppStyles.GAP_VERTICAL,
paddingHorizontal: isTablet ? 0 : DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL,
gap: Spacing.LEVEL_2,
padding: Spacing.LEVEL_3,
flexShrink: 1,
alignSelf: "center"
}}
@@ -191,7 +195,7 @@ const Intro = () => {
});
}}
type="accent"
title={strings.getStarted()}
title={strings.continue()}
/>
<Button

View File

@@ -17,41 +17,36 @@ 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 { useThemeColors } from "@notesnook/theme";
import React from "react";
import { StyleSheet, View } from "react-native";
import { IconButton, IconButtonProps } from "../ui/icon-button";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { Radius, Spacing } from "../../common/design/spacing";
export const RightMenus = ({
rightButton
}: {
rightButton?: IconButtonProps;
export const ProgressPills = (props: {
activePillIndex: number;
count?: number;
}) => {
const { colors } = useThemeColors();
return (
<View style={styles.rightBtnContainer}>
{rightButton ? (
<IconButton {...rightButton} color={colors.primary.icon} />
) : (
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_1
}}
>
{new Array(props.count || 3).fill(0).map((item, index) => (
<View
style={{
width: 40,
height: 40
width: props.activePillIndex === index ? 26 : 14,
height: 5,
backgroundColor:
props.activePillIndex === index
? colors.primary.accent
: colors.secondary.background,
borderRadius: 2
}}
/>
)}
))}
</View>
);
};
const styles = StyleSheet.create({
rightBtnContainer: {
flexDirection: "row",
alignItems: "center"
},
rightBtn: {
justifyContent: "center",
alignItems: "center"
}
});

View File

@@ -17,21 +17,25 @@ 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 { GroupHeader, GroupOptions, ItemType } from "@notesnook/core";
import {
GroupHeader,
GroupOptions,
Item,
ItemType,
VirtualizedGrouping
} from "@notesnook/core";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { View } from "react-native";
import React, { RefObject } from "react";
import { FlatList, View } from "react-native";
import { Radius, Spacing } from "../../../common/design/spacing";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
import { presentSheet } from "../../../services/event-manager";
import SettingsService from "../../../services/settings";
import { RouteName } from "../../../stores/use-navigation-store";
import { AppFontSize } from "../../../utils/size";
import { DefaultAppStyles } from "../../../utils/styles";
import Sort from "../../sheets/sort";
import { IconButton } from "../../ui/icon-button";
import { Pressable } from "../../ui/pressable";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
type SectionHeaderProps = {
item: GroupHeader;
@@ -40,7 +44,9 @@ type SectionHeaderProps = {
color?: string;
screen?: RouteName;
groupOptions: GroupOptions;
onOpenJumpToDialog: () => void;
// onOpenJumpToDialog: () => void;
data?: VirtualizedGrouping<Item>;
ref?: RefObject<FlatList>;
};
export const SectionHeader = React.memo<
@@ -53,7 +59,8 @@ export const SectionHeader = React.memo<
color,
screen,
groupOptions,
onOpenJumpToDialog
data,
ref
}: SectionHeaderProps) {
const { colors } = useThemeColors();
const isCompactModeEnabled = useIsCompactModeEnabled(
@@ -64,8 +71,9 @@ export const SectionHeader = React.memo<
<View
style={{
width: "100%",
paddingHorizontal: DefaultAppStyles.GAP,
marginBottom: DefaultAppStyles.GAP_VERTICAL
paddingHorizontal: Spacing.LEVEL_3,
marginBottom: Spacing.LEVEL_3,
marginTop: Spacing.LEVEL_3
}}
>
<View
@@ -74,56 +82,32 @@ export const SectionHeader = React.memo<
alignItems: "center",
width: "100%",
alignSelf: "center",
justifyContent: "space-between",
borderBottomWidth: 1,
borderColor: colors.primary.border,
paddingBottom: 1,
paddingTop:
index === 0
? DefaultAppStyles.GAP_VERTICAL
: DefaultAppStyles.GAP_VERTICAL_SMALL
justifyContent: "space-between"
}}
>
<Pressable
onPress={() => {
onOpenJumpToDialog();
}}
hitSlop={{ top: 10, left: 10, right: 30, bottom: 15 }}
<Paragraph
fontSize="MD"
style={{
justifyContent: "flex-start",
flexDirection: "row",
width: "auto"
alignSelf: "center",
textAlignVertical: "center"
}}
color={colors.secondary.paragraph}
>
<Heading
size={AppFontSize.xxs}
style={{
alignSelf: "center",
textAlignVertical: "center"
}}
color={color || colors.primary.accent}
>
{!item.title || item.title === ""
? strings.pinned().toUpperCase()
: item.title.toUpperCase()}
</Heading>
</Pressable>
{!item.title || item.title === "" ? strings.pinned() : item.title}
</Paragraph>
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: DefaultAppStyles.GAP_SMALL
gap: Spacing.LEVEL_1
}}
>
{index === 0 ? (
<>
<IconButton
name={
groupOptions.sortDirection === "asc"
? "sort-ascending"
: "sort-descending"
}
name={"sliders"}
iconFamily="notesnook"
color={colors.secondary.icon}
testID="icon-sort"
onPress={() => {
@@ -136,15 +120,20 @@ export const SectionHeader = React.memo<
hideGroupOptions={
screen === "Reminders" || screen === "Search"
}
data={data}
ref={ref}
/>
)
});
}}
style={{
width: 25,
height: 25
width: 30,
height: 30,
borderWidth: 1,
borderRadius: Radius.XS,
borderColor: colors.secondary.border
}}
size={AppFontSize.lg - 2}
size={16}
/>
<IconButton
hidden={
@@ -153,14 +142,16 @@ export const SectionHeader = React.memo<
screen !== "Notes"
}
style={{
width: 25,
height: 25
width: 30,
height: 30,
borderWidth: 1,
borderRadius: Radius.XXS,
borderColor: colors.secondary.border
}}
testID="icon-compact-mode"
color={colors.secondary.icon}
name={
isCompactModeEnabled ? "view-list" : "view-list-outline"
}
name={"view-list"}
iconFamily="notesnook"
onPress={() => {
SettingsService.set({
[dataType !== "notebook"
@@ -170,20 +161,10 @@ export const SectionHeader = React.memo<
: "normal"
});
}}
size={AppFontSize.lg - 2}
size={16}
/>
</>
) : null}
{/* <IconButton
style={{
width: 25,
height: 25
}}
color={colors.secondary.icon}
name={"chevron-down"}
size={SIZE.lg - 2}
/> */}
</View>
</View>
</View>

View File

@@ -28,7 +28,6 @@ import { useThemeColors } from "@notesnook/theme";
import { EntityLevel, decode } from "entities";
import React from "react";
import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
import useNavigationStore, {
RouteParams
@@ -55,6 +54,9 @@ import { TimeSince } from "../../ui/time-since";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import dayjs from "dayjs";
import { Radius, Spacing } from "../../../common/design/spacing";
import { create } from "zustand";
import { FontFamily } from "../../../common/design/font";
type NoteItemProps = {
item: Note | BaseTrashItem<Note>;
@@ -71,6 +73,24 @@ type NoteItemProps = {
renderedInRoute?: keyof RouteParams;
};
const useShowMoreStore = create<{
showMoreStatus: Record<string, boolean>;
show: (id: string) => void;
hide: (id: string) => void;
}>((set) => ({
showMoreStatus: {},
show(id) {
set((state) => ({
showMoreStatus: { ...state.showMoreStatus, [id]: true }
}));
},
hide(id) {
set((state) => ({
showMoreStatus: { ...state.showMoreStatus, [id]: false }
}));
}
}));
const NoteItem = ({
item,
isTrash,
@@ -97,68 +117,54 @@ const NoteItem = ({
const primaryColors = isEditingNote ? colors.selected : colors.primary;
const selectionMode = useSelectionStore((state) => state.selectionMode);
const [selected] = useIsSelected(item);
const showMore = useShowMoreStore((state) => state.showMoreStatus[item.id]);
const statusIcons = [
{
condition: item.conflicted,
name: "alert-circle",
color: colors.error.accent
},
{
condition: item.localOnly,
testID: "sync-off",
name: "sync-off",
color: primaryColors.icon
},
{
condition: item.readonly,
testID: "pencil-lock",
name: "pencil-lock",
color: primaryColors.icon
},
{
condition: item.pinned,
testID: "icon-pinned",
name: "pin",
color: primaryColors.icon
},
{
condition: !!locked,
testID: "lock",
name: "lock",
color: primaryColors.icon
},
{
condition: item.favorite,
testID: "star-filled",
name: "star-outline",
color: "orange"
}
];
return (
<>
<View
style={{
flexGrow: 1,
flexShrink: 1
flexShrink: 1,
gap: Spacing.LEVEL_1
}}
>
{compactMode ? null : (
<Paragraph
style={{
fontSize: AppFontSize.xxxs,
color: colors.secondary.paragraph
}}
>
{getFormattedDate(
date,
dayjs(date).isBefore(dayjs().subtract(1, "day").hour(23))
? "date"
: "time"
)}
</Paragraph>
)}
{compactMode ? (
<Paragraph
numberOfLines={1}
color={color?.colorCode || primaryColors.heading}
size={AppFontSize.sm}
style={{
paddingRight: 10
}}
>
{item.title}
</Paragraph>
) : (
<Heading
numberOfLines={1}
color={color?.colorCode || primaryColors.heading}
size={AppFontSize.sm}
style={{
paddingRight: 10
}}
>
{item.title}
</Heading>
)}
{item.headline && !compactMode ? (
<Paragraph
style={{
flexWrap: "wrap"
}}
color={primaryColors.paragraph}
numberOfLines={2}
>
{decode(item.headline, {
level: EntityLevel.HTML
})}
</Paragraph>
) : null}
{compactMode ? null : (
<View
style={{
@@ -166,50 +172,52 @@ const NoteItem = ({
justifyContent: "flex-start",
alignItems: "center",
width: "100%",
marginTop: DefaultAppStyles.GAP_VERTICAL_SMALL,
columnGap: 8,
rowGap: 4,
columnGap: Spacing.LEVEL_0,
rowGap: Spacing.LEVEL_0,
flexWrap: "wrap"
}}
>
{!isTrash ? (
<>
{item.conflicted ? (
<Icon
name="alert-circle"
size={AppFontSize.sm}
color={colors.error.accent}
/>
) : null}
{statusIcons
.filter((statusIcon) => statusIcon.condition)
.map((statusIcon) => (
<View
key={statusIcon.testID || statusIcon.name}
style={{
borderRadius: Radius.XXS,
paddingHorizontal: 3,
paddingVertical: 3,
// borderWidth: 1,
// borderColor: primaryColors.border,
flexDirection: "row",
alignItems: "center"
}}
>
<AppIcon
testID={statusIcon.testID}
name={statusIcon.name}
size={12}
iconFamily="notesnook"
color={statusIcon.color}
/>
</View>
))}
{item.localOnly ? (
<Icon
testID="sync-off"
name="sync-off"
size={AppFontSize.sm}
color={primaryColors.icon}
/>
) : null}
{item.readonly ? (
<Icon
testID="pencil-lock"
name="pencil-lock"
size={AppFontSize.sm}
color={primaryColors.icon}
/>
) : null}
{attachmentsCount > 0 ? (
{attachmentsCount !== 0 ? (
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: 2
borderRadius: Radius.XXS,
paddingHorizontal: 3,
paddingVertical: 3,
gap: Spacing.LEVEL_0
}}
>
<Icon
name="attachment"
<AppIcon
name="link"
iconFamily="notesnook"
size={AppFontSize.sm}
color={primaryColors.icon}
/>
@@ -222,78 +230,34 @@ const NoteItem = ({
</View>
) : null}
{item.pinned ? (
<Icon
testID="icon-pinned"
name="pin-outline"
size={AppFontSize.sm}
color={color?.colorCode || primaryColors.accent}
/>
) : null}
{locked ? (
<Icon
name="lock"
testID="note-locked-icon"
size={AppFontSize.sm}
color={primaryColors.icon}
/>
) : null}
{item.favorite ? (
<Icon
testID="icon-star"
name="star-outline"
size={AppFontSize.sm}
color="orange"
/>
) : null}
{reminder ? (
<ReminderTime
reminder={reminder}
color={color?.colorCode}
textStyle={{
fontSize: AppFontSize.xxs
}}
short
iconSize={AppFontSize.xxs}
style={{
justifyContent: "flex-start",
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL / 2,
alignSelf: "flex-start"
}}
/>
) : null}
{notebooks?.items
?.filter(
(item) =>
renderedInRoute !== "Notebook" ||
item.id !== useNavigationStore.getState().focusedRouteId
)
.filter((_, index) => showMore || index < 1)
.map((item) => (
<View
key={item.id}
style={{
borderRadius: 4,
borderRadius: 100,
paddingHorizontal: Spacing.LEVEL_1,
paddingVertical: 2,
backgroundColor: colors.secondary.background,
paddingHorizontal: DefaultAppStyles.GAP_SMALL / 2,
borderWidth: 0.5,
borderColor: primaryColors.border,
paddingVertical: 1,
flexDirection: "row",
alignItems: "center",
gap: DefaultAppStyles.GAP_SMALL / 2
gap: Spacing.LEVEL_0
}}
>
<AppIcon
name="book-outline"
size={AppFontSize.xxxs}
name="bookmark"
iconFamily="notesnook"
size={AppFontSize.xs}
color={colors.secondary.icon}
/>
<Paragraph
size={AppFontSize.xxxs}
fontSize="XS"
color={colors.secondary.paragraph}
>
{item.title}
@@ -301,31 +265,64 @@ const NoteItem = ({
</View>
))}
{!isTrash && !compactMode && tags
? tags.items?.map((item) =>
item.id ? (
<View
key={item.id}
style={{
borderRadius: 4,
backgroundColor: colors.secondary.background,
paddingHorizontal: DefaultAppStyles.GAP_SMALL / 2,
borderWidth: 0.5,
borderColor:
color?.colorCode || primaryColors.border,
paddingVertical: 1
}}
{tags?.items
?.filter((_, index) => showMore || index < 1)
.map((item) =>
item.id ? (
<View
key={item.id}
style={{
borderRadius: 100,
paddingHorizontal: Spacing.LEVEL_1,
paddingVertical: 2,
backgroundColor: colors.secondary.background,
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_0
}}
>
<Paragraph
size={AppFontSize.xs}
color={colors.secondary.paragraph}
>
<Paragraph
size={AppFontSize.xxxs}
color={colors.secondary.paragraph}
>
#{item.title}
</Paragraph>
</View>
) : null
)
: null}
{item.title}
</Paragraph>
</View>
) : null
)}
{(() => {
const filteredNotebooks = (notebooks?.items || []).filter(
(nb) =>
renderedInRoute !== "Notebook" ||
nb.id !== useNavigationStore.getState().focusedRouteId
);
const filteredTags = (tags?.items || []).filter((t) => t.id);
const totalNotebooks = filteredNotebooks.length;
const totalTags = filteredTags.length;
const hasMore = totalNotebooks > 1 || totalTags > 1;
if (!hasMore) return null;
const hiddenCount =
(totalNotebooks > 1 ? totalNotebooks - 1 : 0) +
(totalTags > 1 ? totalTags - 1 : 0);
return (
<Heading
size={AppFontSize.xs}
color={colors.primary.accent}
onPress={() => {
if (showMore) {
useShowMoreStore.getState().hide(item.id);
} else {
useShowMoreStore.getState().show(item.id);
}
}}
>
{showMore
? "Show less"
: `+${hiddenCount} ${strings.more()}`}
</Heading>
);
})()}
</>
) : (
<>
@@ -356,6 +353,125 @@ const NoteItem = ({
)}
</View>
)}
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_1
}}
>
{color ? (
<View
style={{
width: 8,
height: 8,
borderRadius: 100,
backgroundColor: color?.colorCode
}}
/>
) : null}
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
flexGrow: 1,
alignItems: "center"
}}
>
<Heading
numberOfLines={1}
color={primaryColors.heading}
size={AppFontSize.sm}
style={{
flexShrink: 1
}}
>
{item.title}
</Heading>
<IconButton
testID={notesnook.listitem.menu}
color={colors.secondary.icon}
name="dots-three"
iconFamily="notesnook"
size={20}
onPress={() => !noOpen && Properties.present(item)}
style={{
justifyContent: "center",
height: undefined,
width: undefined,
borderRadius: 100,
alignItems: "center"
}}
/>
</View>
</View>
{item.headline && !compactMode ? (
<Paragraph
style={{
flexWrap: "wrap"
}}
color={primaryColors.paragraph}
numberOfLines={2}
>
{decode(item.headline, {
level: EntityLevel.HTML
})}
</Paragraph>
) : null}
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_1
}}
>
{compactMode ? null : (
<View
style={{
gap: Spacing.LEVEL_0,
flexDirection: "row"
}}
>
<AppIcon size={13} name="calendar" iconFamily="notesnook" />
<Paragraph
style={{
fontSize: AppFontSize.xs,
color: colors.secondary.paragraph
}}
>
{getFormattedDate(
date,
dayjs(date).isBefore(dayjs().subtract(1, "day").hour(23))
? "date"
: "time"
)}
</Paragraph>
</View>
)}
{reminder ? (
<ReminderTime
reminder={reminder}
color={color?.colorCode}
textStyle={{
fontSize: AppFontSize.xs,
fontFamily: FontFamily.REGULAR
}}
short
iconSize={AppFontSize.xxs}
style={{
justifyContent: "flex-start",
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL / 2,
alignSelf: "flex-start",
backgroundColor: colors.primary.shade
}}
/>
) : null}
</View>
</View>
<View
style={{
@@ -366,7 +482,7 @@ const NoteItem = ({
{compactMode ? (
<>
{item.conflicted ? (
<Icon
<AppIcon
name="alert-circle"
style={{
marginRight: 6
@@ -377,7 +493,7 @@ const NoteItem = ({
) : null}
{locked ? (
<Icon
<AppIcon
name="lock"
testID="note-locked-icon"
size={AppFontSize.sm}
@@ -389,7 +505,7 @@ const NoteItem = ({
) : null}
{item.favorite ? (
<Icon
<AppIcon
testID="icon-star"
name="star-outline"
size={AppFontSize.sm}
@@ -429,22 +545,7 @@ const NoteItem = ({
/>
</View>
</>
) : (
<IconButton
testID={notesnook.listitem.menu}
color={colors.secondary.icon}
name="dots-horizontal"
size={AppFontSize.lg}
onPress={() => !noOpen && Properties.present(item)}
style={{
justifyContent: "center",
height: 35,
width: 35,
borderRadius: 100,
alignItems: "center"
}}
/>
)}
) : null}
</View>
</>
);

View File

@@ -36,7 +36,8 @@ import { useTabStore } from "../../../screens/editor/tiptap/use-tab-store";
import { editorController } from "../../../screens/editor/tiptap/utils";
import { RouteParams } from "../../../stores/use-navigation-store";
import NotePreview from "../../note-history/preview";
import SelectionWrapper, { selectItem } from "../selection-wrapper";
import SelectionWrapper from "../selection-wrapper";
import { selectItem } from "../../../stores/use-selection-store";
export const openNote = async (
item: Note,
@@ -94,6 +95,7 @@ type NoteWrapperProps = {
isRenderedInActionSheet: boolean;
locked?: boolean;
renderedInRoute?: keyof RouteParams;
hasGroupHeader?: boolean;
};
export const NoteWrapper = React.memo<
@@ -103,6 +105,7 @@ export const NoteWrapper = React.memo<
item,
index,
isRenderedInActionSheet,
hasGroupHeader,
...restProps
}: NoteWrapperProps) {
const isTrash = item.type === "trash";
@@ -113,6 +116,7 @@ export const NoteWrapper = React.memo<
onPress={() => openNote(item as Note, isTrash, isRenderedInActionSheet)}
isSheet={isRenderedInActionSheet}
item={item}
hasGroupHeader={hasGroupHeader}
index={index}
color={restProps.color?.colorCode}
>

View File

@@ -27,7 +27,8 @@ import Navigation from "../../../services/navigation";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useTrashStore } from "../../../stores/use-trash-store";
import { presentDialog } from "../../dialog/functions";
import SelectionWrapper, { selectItem } from "../selection-wrapper";
import SelectionWrapper from "../selection-wrapper";
import { selectItem } from "../../../stores/use-selection-store";
import { strings } from "@notesnook/intl";
export const openNotebook = (item: Notebook | BaseTrashItem<Notebook>) => {

View File

@@ -36,7 +36,8 @@ import { IconButton } from "../../ui/icon-button";
import { ReminderTime } from "../../ui/reminder-time";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import SelectionWrapper, { selectItem } from "../selection-wrapper";
import SelectionWrapper from "../selection-wrapper";
import { selectItem } from "../../../stores/use-selection-store";
const ReminderItem = React.memo(
({

View File

@@ -23,26 +23,9 @@ import React, { PropsWithChildren, useRef } from "react";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
import { useTabStore } from "../../../screens/editor/tiptap/use-tab-store";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { DefaultAppStyles } from "../../../utils/styles";
import { Pressable } from "../../ui/pressable";
import { View } from "react-native";
export function selectItem(item: Item) {
if (useSelectionStore.getState().selectionMode === item.type) {
const { selectionMode, clearSelection, setSelectedItem } =
useSelectionStore.getState();
if (selectionMode === item.type) {
setSelectedItem(item.id);
}
if (useSelectionStore.getState().selectedItemsList.length === 0) {
clearSelection();
}
return true;
}
return false;
}
import { Spacing } from "../../../common/design/spacing";
type SelectionWrapperProps = PropsWithChildren<{
item: Item;
@@ -51,6 +34,7 @@ type SelectionWrapperProps = PropsWithChildren<{
isSheet?: boolean;
color?: string;
index?: number;
hasGroupHeader?: boolean;
}>;
const SelectionWrapper = ({
@@ -60,6 +44,7 @@ const SelectionWrapper = ({
isSheet,
children,
color,
hasGroupHeader,
index = 0
}: SelectionWrapperProps) => {
const itemId = useRef(item.id);
@@ -86,47 +71,37 @@ const SelectionWrapper = ({
};
return (
<Pressable
customColor={
isEditingNote
? colors.selected.background
: isSheet
? colors.primary.hover
: "transparent"
}
testID={testID}
onLongPress={onLongPress}
onPress={onPress}
customSelectedColor={colors.primary.hover}
customAlpha={!isDark ? -0.02 : 0.02}
customOpacity={1}
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
width: "100%",
alignSelf: "center",
overflow: "hidden",
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: compactMode ? 4 : DefaultAppStyles.GAP_VERTICAL,
borderRadius: isSheet ? 10 : 0,
marginBottom: isSheet ? DefaultAppStyles.GAP_VERTICAL : undefined
paddingHorizontal: Spacing.LEVEL_3,
backgroundColor: isEditingNote ? colors.selected.background : undefined
}}
>
{isEditingNote ? (
<View
style={{
backgroundColor: color || colors.selected.accent,
position: "absolute",
bottom: 0,
top: 0,
left: 0,
width: 5
}}
/>
) : null}
{children}
</Pressable>
<Pressable
customColor={isSheet ? colors.primary.hover : "transparent"}
testID={testID}
onLongPress={onLongPress}
onPress={onPress}
customSelectedColor={colors.primary.hover}
customAlpha={!isDark ? -0.02 : 0.02}
customOpacity={1}
style={{
flexDirection: "row",
width: "100%",
alignSelf: "center",
overflow: "hidden",
borderRadius: 0,
marginTop: hasGroupHeader ? 0 : Spacing.LEVEL_3,
borderBottomWidth: 1,
borderBottomColor: colors.primary.border,
alignItems: "flex-start",
paddingVertical: Spacing.LEVEL_2,
paddingTop: hasGroupHeader ? 0 : Spacing.LEVEL_2
}}
>
{children}
</Pressable>
</View>
);
};

View File

@@ -28,7 +28,8 @@ import { Properties } from "../../properties";
import { IconButton } from "../../ui/icon-button";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import SelectionWrapper, { selectItem } from "../selection-wrapper";
import SelectionWrapper from "../selection-wrapper";
import { selectItem } from "../../../stores/use-selection-store";
import { strings } from "@notesnook/intl";
import { DefaultAppStyles } from "../../../utils/styles";

View File

@@ -21,10 +21,11 @@ import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Dimensions, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { Radius, Spacing } from "../../common/design/spacing";
import { Message, useMessageStore } from "../../stores/use-message-store";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import AppIcon from "../ui/AppIcon";
import { Pressable } from "../ui/pressable";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
export const Card = ({
@@ -47,15 +48,19 @@ export const Card = ({
<View
style={{
width: "100%",
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
paddingHorizontal: Spacing.LEVEL_3,
marginBottom: Spacing.LEVEL_4,
marginTop: Spacing.LEVEL_3
}}
>
<Pressable
onPress={messageBoardState.onPress}
type="plain"
style={{
paddingVertical: DefaultAppStyles.GAP_VERTICAL,
paddingVertical: Spacing.LEVEL_3,
paddingHorizontal: Spacing.LEVEL_2,
backgroundColor: colors.primary.shade,
borderRadius: Radius.S,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
@@ -66,23 +71,24 @@ export const Card = ({
style={{
flexDirection: "row",
alignItems: "center",
width: "100%"
width: "100%",
flexShrink: 1,
gap: Spacing.LEVEL_1
}}
>
<View
style={{
width: 40 * fontScale,
height: 40 * fontScale,
borderRadius: 100,
width: 34,
height: 34,
borderRadius: Radius.XXS,
alignItems: "center",
justifyContent: "center"
justifyContent: "center",
backgroundColor: colors.secondary.background
}}
>
<Icon
size={AppFontSize.xxxl}
color={
messageBoardState.type === "error" ? colors.error.icon : color
}
size={16}
color={colors.primary.icon}
allowFontScaling
name={messageBoardState.icon}
/>
@@ -90,25 +96,26 @@ export const Card = ({
<View
style={{
marginLeft: 10,
marginRight: 10
gap: Spacing.LEVEL_0
}}
>
<Paragraph
<Heading
style={{
flexWrap: "nowrap",
flexShrink: 1
}}
size={AppFontSize.sm}
fontSize="MD"
color={colors.primary.heading}
>
{messageBoardState.actionText}
</Paragraph>
<Paragraph color={colors.secondary.paragraph} size={AppFontSize.xs}>
</Heading>
<Paragraph color={colors.secondary.paragraph} fontSize="SM">
{messageBoardState.message}
</Paragraph>
</View>
</View>
<AppIcon size={24} name="chevron-right" color={colors.primary.icon} />
</Pressable>
</View>
);

View File

@@ -42,15 +42,13 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
import { View } from "react-native";
import { db } from "../../common/database";
import { useIsCompactModeEnabled } from "../../hooks/use-is-compact-mode-enabled";
import { eSendEvent } from "../../services/event-manager";
import { RouteName } from "../../stores/use-navigation-store";
import { eOpenJumpToDialog } from "../../utils/events";
import { SectionHeader } from "../list-items/headers/section-header";
import { NoteWrapper } from "../list-items/note/wrapper";
import { NotebookWrapper } from "../list-items/notebook/wrapper";
import ReminderItem from "../list-items/reminder";
import TagItem from "../list-items/tag";
import { SearchResult } from "../list-items/search-result";
import TagItem from "../list-items/tag";
type ListItemWrapperProps<TItem = Item> = {
group?: GroupingKey;
@@ -184,12 +182,8 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
dataType={item.type}
color={props.customAccentColor}
groupOptions={groupOptions}
onOpenJumpToDialog={() => {
eSendEvent(eOpenJumpToDialog, {
ref: props.scrollRef,
data: items
});
}}
ref={props.scrollRef}
data={items}
/>
) : null}
@@ -199,6 +193,9 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
color={color.current}
notebooks={notebooks.current}
reminder={reminder.current}
hasGroupHeader={
groupHeader && previousIndex.current === index && !isSheet
}
attachmentsCount={attachmentsCount.current}
date={getDate(item as Note, group)}
isRenderedInActionSheet={isSheet}
@@ -220,12 +217,8 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
dataType={item.type}
color={props.customAccentColor}
groupOptions={groupOptions}
onOpenJumpToDialog={() => {
eSendEvent(eOpenJumpToDialog, {
ref: props.scrollRef,
data: items
});
}}
ref={props.scrollRef}
data={items}
/>
) : null}
<NotebookWrapper
@@ -248,12 +241,8 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
dataType={item.type}
color={props.customAccentColor}
groupOptions={groupOptions}
onOpenJumpToDialog={() => {
eSendEvent(eOpenJumpToDialog, {
ref: props.scrollRef,
data: items
});
}}
ref={props.scrollRef}
data={items}
/>
) : null}
<ReminderItem
@@ -274,12 +263,8 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
dataType={item.type}
color={props.customAccentColor}
groupOptions={groupOptions}
onOpenJumpToDialog={() => {
eSendEvent(eOpenJumpToDialog, {
ref: props.scrollRef,
data: items
});
}}
ref={props.scrollRef}
data={items}
/>
) : null}
<TagItem
@@ -300,12 +285,8 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
dataType={item.type}
color={props.customAccentColor}
groupOptions={groupOptions}
onOpenJumpToDialog={() => {
eSendEvent(eOpenJumpToDialog, {
ref: props.scrollRef,
data: items
});
}}
ref={props.scrollRef}
data={items}
/>
) : null}
<SearchResult item={item as HighlightedResult} />

View File

@@ -18,15 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { View } from "react-native";
import { View, ViewStyle } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { ProgressBarComponent } from "../ui/svg/lazy";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { SvgView } from "../ui/svg";
import { Radius, Spacing } from "../../common/design/spacing";
export const Loading = (props: {
title?: string;
description?: string;
icon?: string;
svgSrc?: string;
style?: ViewStyle;
}) => {
const { colors } = useThemeColors();
return (
@@ -37,18 +41,37 @@ export const Loading = (props: {
backgroundColor: colors.primary.background,
justifyContent: "center",
alignItems: "center",
paddingHorizontal: 16
paddingHorizontal: 16,
...props.style
}}
>
{props.icon ? (
<Icon name={props.icon} size={80} color={colors.primary.accent} />
) : null}
{props.svgSrc ? (
<View
style={{
marginBottom: Spacing.LEVEL_7
}}
>
<SvgView
src={props.svgSrc}
style={{
width: 180,
height: 180
}}
/>
</View>
) : null}
{props.title ? (
<Heading
style={{
textAlign: "center"
textAlign: "center",
marginBottom: Spacing.LEVEL_1
}}
fontSize="XL"
>
{props.title}
</Heading>
@@ -57,8 +80,10 @@ export const Loading = (props: {
{props.description ? (
<Paragraph
style={{
textAlign: "center"
textAlign: "center",
marginBottom: Spacing.LEVEL_4
}}
fontSize="SM"
>
{props.description}
</Paragraph>
@@ -67,15 +92,15 @@ export const Loading = (props: {
<View
style={{
flexDirection: "row",
width: 100,
marginTop: 15
width: 300
}}
>
<ProgressBarComponent
height={5}
width={100}
height={7}
width={300}
animated={true}
useNativeDriver
borderRadius={Radius.XS}
indeterminate
indeterminateAnimationDuration={2000}
unfilledColor={colors.secondary.background}

View File

@@ -0,0 +1,24 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export const Steps = {
select: 1,
buy: 2,
finish: 3,
buyWeb: 4
};

View File

@@ -0,0 +1,181 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 from "react";
import { ScrollView, useWindowDimensions, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
//@ts-ignore
import usePricingPlans from "../../hooks/use-pricing-plans";
import { AppFontSize } from "../../utils/size";
import { Button } from "../ui/button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { Steps } from "./common";
export const ComparePlans = React.memo(
(props: {
pricingPlans?: ReturnType<typeof usePricingPlans>;
setStep: (step: number) => void;
}) => {
const { colors } = useThemeColors();
const { width } = useWindowDimensions();
const isTablet = width > 600;
return (
<ScrollView
horizontal
style={{
width: isTablet ? "100%" : undefined
}}
contentContainerStyle={{
flexDirection: "column"
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
width: "100%",
gap: 10
}}
>
{["Features", "Free", "Essential", "Pro", "Believer"].map(
(plan, index) => (
<View
key={plan}
style={{
width: index === 0 ? 150 : 120,
paddingHorizontal: 16,
paddingVertical: 12,
backgroundColor:
index === 0 ? colors.secondary.background : undefined,
borderBottomWidth: index === 0 ? 1 : undefined,
borderBottomColor: colors.primary.border
}}
>
<Heading size={AppFontSize.sm}>{plan}</Heading>
</View>
)
)}
</View>
{getFeaturesTable().map((item, keyIndex) => {
return (
<View
key={`${item[0] + item[1]}`}
style={{
flexDirection: "row",
alignItems: "center",
width: "100%",
gap: 10
}}
>
{item.map((featureItem, index) => (
<View
style={{
width: index === 0 ? 150 : 120,
paddingHorizontal: 16,
paddingVertical: 12,
backgroundColor:
index === 0 ? colors.secondary.background : undefined,
borderBottomWidth: index === 0 ? 1 : undefined,
borderBottomColor: colors.primary.border
}}
key={item[0] + index}
>
{typeof featureItem === "string" ? (
<Heading size={AppFontSize.sm}>
{featureItem as string}
</Heading>
) : (
<>
{typeof featureItem.caption === "string" ||
typeof featureItem.caption === "number" ? (
<Paragraph>
{featureItem.caption === "infinity"
? "∞"
: featureItem.caption}
</Paragraph>
) : typeof featureItem.caption === "boolean" ? (
<>
{featureItem.caption === true ? (
<Icon
color={colors.primary.accent}
size={AppFontSize.sm}
name="check"
/>
) : (
<Icon
size={AppFontSize.sm}
color={colors.static.red}
name="close"
/>
)}
</>
) : null}
</>
)}
</View>
))}
</View>
);
})}
<View
style={{
flexDirection: "row",
alignItems: "center",
width: "100%",
gap: 10
}}
>
{["features", "free", "essential", "pro", "believer"].map(
(plan, index) => (
<View
key={plan + "btn"}
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>
);
},
() => true
);
ComparePlans.displayName = "ComparePlans";

View File

@@ -0,0 +1,73 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { useThemeColors } from "@notesnook/theme";
import React, { useState } from "react";
import { TouchableOpacity, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
//@ts-ignore
import { AppFontSize } from "../../utils/size";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
export const FAQItem = (props: { question: string; answer: string }) => {
const [expanded, setExpanded] = useState(false);
const { colors } = useThemeColors();
return (
<TouchableOpacity
style={{
padding: 16,
backgroundColor: colors.secondary.background,
borderRadius: 10,
marginBottom: 10,
gap: 12
}}
activeOpacity={0.9}
onPress={() => {
setExpanded(!expanded);
}}
key={props.question}
>
<View
style={{
flexDirection: "row",
width: "100%",
justifyContent: "space-between"
}}
>
<Heading
style={{
flexShrink: 1
}}
size={AppFontSize.md}
>
{props.question}
</Heading>
<Icon
name={expanded ? "chevron-up" : "chevron-down"}
color={colors.secondary.icon}
size={AppFontSize.xxl}
/>
</View>
{expanded ? (
<Paragraph size={AppFontSize.md}>{props.answer}</Paragraph>
) : null}
</TouchableOpacity>
);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,332 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { SKUResponse } from "@notesnook/core";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import {
ActivityIndicator,
Text,
useWindowDimensions,
View
} from "react-native";
import * as RNIap from "react-native-iap";
//@ts-ignore
import usePricingPlans, {
PlanOverView,
PricingPlan
} from "../../hooks/use-pricing-plans";
import PremiumService from "../../services/premium";
import { getElevationStyle } from "../../utils/elevation";
import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { Steps } from "./common";
import { Radius, Spacing } from "../../common/design/spacing";
import AppIcon from "../ui/AppIcon";
import { Button } from "../ui/button";
export const PricingPlanCard = ({
plan,
pricingPlans,
annualBilling,
setStep
}: {
plan: PricingPlan;
pricingPlans?: ReturnType<typeof usePricingPlans>;
annualBilling?: boolean;
setStep: (step: number) => void;
}) => {
const { colors } = useThemeColors();
const [regionalDiscount, setRegionaDiscount] = useState<SKUResponse>();
const { width } = useWindowDimensions();
const isTablet = width > 600;
const product =
plan.subscriptions?.[
regionalDiscount?.sku ||
`notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
];
const WebPlan = pricingPlans?.getWebPlan(
plan.id,
annualBilling ? "yearly" : "monthly"
);
const price = pricingPlans?.getPrice(
pricingPlans.isGithubRelease && WebPlan
? WebPlan
: (product as RNIap.Subscription),
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
annualBilling
);
useEffect(() => {
if (pricingPlans?.isGithubRelease || !annualBilling) return;
pricingPlans
?.getRegionalDiscount(
plan.id,
pricingPlans.isGithubRelease
? (WebPlan?.period as string)
: `notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
)
.then((value) => {
setRegionaDiscount(value);
});
}, [WebPlan?.period, annualBilling, plan.id, pricingPlans]);
useEffect(() => {
if (!annualBilling) {
setRegionaDiscount(undefined);
}
}, [annualBilling]);
const isSubscribed =
product?.productId &&
pricingPlans?.user?.subscription?.productId?.includes(plan.id) &&
pricingPlans.isSubscribed();
const isNotReady =
pricingPlans?.loadingPlans || (!price && !WebPlan?.price?.gross);
return (
<View
style={{
...getElevationStyle(3),
backgroundColor: colors.secondary.background,
borderWidth: 1,
borderColor: colors.primary.border,
borderRadius: Radius.LG,
padding: 16,
flexShrink: isTablet ? 1 : undefined,
flexDirection: "column",
justifyContent: "space-between",
gap: 6
}}
>
<View>
<View
style={{
flexDirection: "row",
alignItems: "center",
width: "100%",
justifyContent: "space-between",
marginBottom: Spacing.LEVEL_1
}}
>
<Heading size={AppFontSize.xl}>{plan.name} </Heading>
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_1
}}
>
{isSubscribed ? (
<View
style={{
backgroundColor: colors.primary.accent,
borderRadius: defaultBorderRadius,
padding: Spacing.LEVEL_0,
alignItems: "center",
justifyContent: "center",
alignSelf: "flex-start",
marginBottom: Spacing.LEVEL_1
}}
>
<Heading color={colors.static.white} size={AppFontSize.xxs}>
{strings.currentPlan()}
</Heading>
</View>
) : (
<>
{regionalDiscount?.discount || WebPlan?.discount ? (
<View
style={{
backgroundColor: colors.static.red,
borderRadius: 100,
padding: Spacing.LEVEL_0,
paddingHorizontal: Spacing.LEVEL_1,
justifyContent: "center",
alignSelf: "flex-start"
}}
>
<Heading color={colors.static.white} size={AppFontSize.xxs}>
{strings.percentOff(
`${regionalDiscount?.discount || WebPlan?.discount?.amount}`
)}
</Heading>
</View>
) : null}
{plan.recommended ? (
<View
style={{
backgroundColor: colors.static.orange,
borderRadius: 100,
padding: Spacing.LEVEL_0,
paddingHorizontal: Spacing.LEVEL_1
}}
>
<Text
style={{
color: colors.static.black,
fontSize: AppFontSize.xxs
}}
>
{strings.recommended()}
</Text>
</View>
) : null}
</>
)}
</View>
</View>
<Paragraph>{plan.description}</Paragraph>
<View
style={{
marginTop: Spacing.LEVEL_3
}}
>
{pricingPlans?.loadingPlans || (!price && !WebPlan?.price?.gross) ? (
<ActivityIndicator size="small" color={colors.primary.accent} />
) : (
<View>
<Heading size={24}>
{price ||
`${WebPlan?.price?.currency} ${WebPlan?.price?.gross}`}{" "}
<Paragraph color={colors.primary.paragraph} fontSize="SM">
/{strings.month()}
</Paragraph>
</Heading>
{!product && !WebPlan ? null : (
<Paragraph
color={colors.secondary.paragraph}
size={AppFontSize.xs}
>
{annualBilling
? strings.billedAnnually(
pricingPlans?.getStandardPrice(
(product || WebPlan) as any
) as string
)
: strings.billedMonthly(
pricingPlans?.getStandardPrice(
(product || WebPlan) as any
) as string
)}
</Paragraph>
)}
</View>
)}
</View>
<View
style={{
marginVertical: Spacing.LEVEL_4,
gap: Spacing.LEVEL_2
}}
>
{Object.keys(PlanOverView[plan.id as keyof typeof PlanOverView]).map(
(item) => (
<View
key={item + plan.id}
style={{
flexDirection: "row",
width: "100%",
justifyContent: "space-between",
borderBottomColor: colors.primary.border,
borderBottomWidth: 1,
paddingBottom: Spacing.LEVEL_2
}}
>
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_1
}}
>
<AppIcon
name={
item === "storage"
? "cloud"
: item === "fileSize"
? "file"
: "image-outline"
}
size={AppFontSize.lg}
/>
<Paragraph size={AppFontSize.sm}>
{strings[item as "storage" | "hdImages" | "fileSize"]()}
</Paragraph>
</View>
<Heading size={AppFontSize.sm}>
{
PlanOverView[plan.id as keyof typeof PlanOverView][
item as "storage" | "hdImages" | "fileSize"
]
}
</Heading>
</View>
)
)}
</View>
<Button
title={strings.selectPlan()}
type={plan.id === "pro" ? "accent" : "secondary"}
style={{
width: "100%"
}}
onPress={() => {
if (isNotReady) return;
const currentPlanSubscribed =
PremiumService.get() &&
(pricingPlans?.user?.subscription?.productId ===
(product as RNIap.Subscription)?.productId ||
pricingPlans?.user?.subscription?.productId?.startsWith(
(product as RNIap.Subscription)?.productId
));
pricingPlans?.selectPlan(
plan.id,
currentPlanSubscribed
? `notesnook.${plan.id}.${
!(product as RNIap.Subscription)?.productId.includes(
"yearly"
)
? "yearly"
: "monthly"
}`
: pricingPlans.isGithubRelease
? (WebPlan?.period as string)
: (product?.productId as string)
);
setStep(Steps.buy);
}}
/>
</View>
</View>
);
};

View File

@@ -0,0 +1,84 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Image, TouchableOpacity, View } from "react-native";
//@ts-ignore
import { openLinkInBrowser } from "../../utils/functions";
import { AppFontSize } from "../../utils/size";
import Paragraph from "../ui/typography/paragraph";
import { Radius, Spacing } from "../../common/design/spacing";
import Heading from "../ui/typography/heading";
export const ReviewItem = (props: {
review: string;
user: string;
userSource: string;
link: string;
userImage?: string;
}) => {
const { colors } = useThemeColors();
return (
<TouchableOpacity
activeOpacity={1}
onPress={() => {
openLinkInBrowser(props.link);
}}
style={{
width: "100%",
padding: Spacing.LEVEL_4,
borderWidth: 1,
backgroundColor: colors.secondary.background,
borderRadius: Radius.LG,
borderColor: colors.primary.border
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: 10,
paddingBottom: Spacing.LEVEL_4
}}
>
{props.userImage ? (
<Image
source={{
uri: props.userImage
}}
style={{
width: 34,
height: 34,
borderRadius: 100
}}
/>
) : null}
<View>
<Heading size={AppFontSize.sm}>{props.user}</Heading>
<Paragraph size={AppFontSize.xs} color={colors.primary.paragraph}>
{props.userSource}
</Paragraph>
</View>
</View>
<Paragraph>{props.review}</Paragraph>
</TouchableOpacity>
);
};

View File

@@ -43,6 +43,8 @@ import ColorPicker from "../dialogs/color-picker";
import PaywallSheet from "../sheets/paywall";
import { Button } from "../ui/button";
import { Pressable } from "../ui/pressable";
import { Spacing } from "../../common/design/spacing";
import AppIcon from "../ui/AppIcon";
const ColorItem = ({ item, note }: { item: Color; note: Note }) => {
const { colors } = useThemeColors();
@@ -80,12 +82,11 @@ const ColorItem = ({ item, note }: { item: Color; note: Note }) => {
key={item.id}
onPress={toggleColor}
style={{
width: 35,
height: 35,
width: 40,
height: 40,
borderRadius: 100,
justifyContent: "center",
alignItems: "center",
marginRight: 5
alignItems: "center"
}}
>
{isLinked ? (
@@ -151,31 +152,10 @@ export const ColorTags = ({ item }: { item: Note }) => {
/>
<View
style={{
flexGrow: isTablet ? undefined : 1,
flexDirection: "row",
marginLeft: 5,
flexShrink: 2
flexDirection: "row"
}}
>
{!colorNotes || !colorNotes.length ? (
<Button
onPress={onPress}
buttonType={{
text: colors.primary.accent
}}
title={strings.addColor()}
type="secondary"
icon="plus"
iconPosition="right"
height={30}
fontSize={AppFontSize.xs}
style={{
marginRight: 5,
paddingHorizontal: DefaultAppStyles.GAP_SMALL,
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL
}}
/>
) : (
{colorNotes?.length ? (
<LegendList
data={colorNotes}
estimatedItemSize={30}
@@ -184,11 +164,14 @@ export const ColorTags = ({ item }: { item: Note }) => {
bounces={false}
renderItem={renderItem}
showsHorizontalScrollIndicator={false}
contentContainerStyle={{
gap: Spacing.LEVEL_1
}}
ListFooterComponent={
<Pressable
style={{
width: 35,
height: 35,
width: 40,
height: 40,
borderRadius: 100,
justifyContent: "center",
alignItems: "center",
@@ -197,16 +180,17 @@ export const ColorTags = ({ item }: { item: Note }) => {
type="secondary"
onPress={onPress}
>
<Icon
<AppIcon
testID="icon-plus"
iconFamily="notesnook"
name="plus"
color={colors.primary.icon}
color={colors.primary.accent}
size={AppFontSize.lg}
/>
</Pressable>
}
/>
)}
) : null}
</View>
</>
);

View File

@@ -29,6 +29,7 @@ import DateTimePickerModal from "react-native-modal-datetime-picker";
import { db } from "../../common/database";
import { Item, Note } from "@notesnook/core";
import AppIcon from "../ui/AppIcon";
import { Radius, Spacing } from "../../common/design/spacing";
export const DateMeta = ({ item }: { item: Item }) => {
const { colors, isDark } = useThemeColors();
const [isDatePickerVisible, setIsDatePickerVisible] = useState(false);
@@ -50,44 +51,52 @@ export const DateMeta = ({ item }: { item: Item }) => {
key={key}
style={{
flexDirection: "row",
width: "48.5%",
justifyContent: "space-between",
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL / 2
backgroundColor: colors.secondary.background,
borderRadius: Radius.XS,
padding: Spacing.LEVEL_2,
gap: Spacing.LEVEL_1,
alignItems: "center"
}}
>
<Paragraph size={AppFontSize.xs} color={colors.secondary.paragraph}>
{strings.dateDescFromKey(
key as
| "dateDeleted"
| "dateEdited"
| "dateModified"
| "dateCreated"
| "dateUploaded"
)}
</Paragraph>
<Paragraph
size={AppFontSize.xs}
color={colors.secondary.paragraph}
onPress={
item.type !== "note"
? undefined
: () => {
setIsDatePickerVisible(true);
}
}
>
{getFormattedDate(
key === "dateCreated"
? dateCreated
: (item[key as keyof Item] as string),
"date-time"
)}
{key === "dateCreated" && item.type === "note" ? (
<>
{" "}
<AppIcon name="pencil" size={AppFontSize.md} />
</>
) : null}
</Paragraph>
<View>
<Paragraph size={AppFontSize.xs} color={colors.secondary.paragraph}>
{strings.dateDescFromKey(
key as
| "dateDeleted"
| "dateEdited"
| "dateModified"
| "dateCreated"
| "dateUploaded"
)}
</Paragraph>
<Paragraph
size={AppFontSize.xs}
color={colors.primary.paragraph}
fontFamily="MEDIUM"
onPress={
item.type !== "note"
? undefined
: () => {
setIsDatePickerVisible(true);
}
}
>
{getFormattedDate(
key === "dateCreated"
? dateCreated
: (item[key as keyof Item] as string),
"date-time"
)}
</Paragraph>
</View>
{key === "dateCreated" && item.type === "note" ? (
<>
<AppIcon name="edit-pencil" size={10} iconFamily="notesnook" />
</>
) : null}
</View>
);
@@ -118,9 +127,10 @@ export const DateMeta = ({ item }: { item: Item }) => {
<View
style={{
borderTopWidth: 1,
borderTopColor: colors.primary.border,
paddingHorizontal: DefaultAppStyles.GAP,
paddingTop: DefaultAppStyles.GAP_VERTICAL_SMALL
borderColor: colors.primary.border,
paddingVertical: Spacing.LEVEL_2,
flexDirection: "row",
gap: Spacing.LEVEL_2
}}
>
{getDateMeta().map(renderItem)}

View File

@@ -18,14 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import React, { useEffect, useState } from "react";
import { View } from "react-native";
import { FlatList } from "react-native-actions-sheet";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { db } from "../../common/database";
import { DDS } from "../../services/device-detection";
import { eSendEvent, presentSheet } from "../../services/event-manager";
import { eOnLoadNote } from "../../utils/events";
import {
eSendEvent,
presentSheet,
sendItemUpdateEvent,
ToastManager
} from "../../services/event-manager";
import { eOnLoadNote, refreshNotesPage } from "../../utils/events";
import { fluidTabsRef } from "../../utils/global-refs";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
@@ -37,27 +41,43 @@ import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { DateMeta } from "./date-meta";
import { Items } from "./items";
import Notebooks from "./notebooks";
import { TagStrip, Tags } from "./tags";
import { Tags } from "./tags";
import { Dialog } from "../dialog";
const Line = ({ top = 6, bottom = 6 }) => {
const { colors } = useThemeColors();
return (
<View
style={{
height: 1,
backgroundColor: colors.primary.border,
width: "100%",
marginTop: top,
marginBottom: bottom
}}
/>
);
};
import AppIcon from "../ui/AppIcon";
import { Spacing } from "../../common/design/spacing";
import { Button } from "../ui/button";
import ManageTags from "../../screens/manage-tags";
import ColorPicker from "../dialogs/color-picker";
import { useRelationStore } from "../../stores/use-relation-store";
import { useMenuStore } from "../../stores/use-menu-store";
import Navigation from "../../services/navigation";
import { useIsFeatureAvailable } from "@notesnook/common";
import PaywallSheet from "../sheets/paywall";
import { useSettingStore } from "../../stores/use-setting-store";
export const Properties = ({ close = () => {}, item, buttons = [] }) => {
const { colors } = useThemeColors();
const colorFeature = useIsFeatureAvailable("colors");
const [noteNotebooks, setNoteNotebooks] = useState([]);
const [tags, setTags] = useState([]);
const [visible, setVisible] = useState(false);
const colorNotes = useMenuStore((state) => state.colorNotes);
useEffect(() => {
async function getNotebooks() {
let filteredNotebooks = await db.relations.to(item, "notebook").resolve();
return filteredNotebooks || [];
}
if (item.type === "note") {
getNotebooks().then((notebooks) => setNoteNotebooks(notebooks));
db.relations
.to(item, "tag")
.resolve()
.then((tags) => {
setTags(tags);
});
}
}, [item]);
if (!item || !item.id) {
return (
<Paragraph style={{ marginVertical: 10, alignSelf: "center" }}>
@@ -74,7 +94,8 @@ export const Properties = ({ close = () => {}, item, buttons = [] }) => {
backgroundColor: colors.primary.background,
borderBottomRightRadius: DDS.isLargeTablet() ? 10 : 1,
borderBottomLeftRadius: DDS.isLargeTablet() ? 10 : 1,
maxHeight: "100%"
maxHeight: "100%",
paddingTop: Spacing.LEVEL_3
}}
nestedScrollEnabled
bounces={false}
@@ -83,111 +104,240 @@ export const Properties = ({ close = () => {}, item, buttons = [] }) => {
renderItem={() => (
<View
style={{
gap: DefaultAppStyles.GAP_VERTICAL
gap: Spacing.LEVEL_1
}}
>
{item.type === "note" ? (
<ColorPicker
visible={visible}
setVisible={setVisible}
onColorAdded={async (color) => {
await db.relations.to(item, "color").unlink();
await db.relations.add(color, item);
useRelationStore.getState().update();
useMenuStore.getState().setColorNotes();
Navigation.queueRoutesForUpdate();
sendItemUpdateEvent(color.id, "color");
eSendEvent(refreshNotesPage);
}}
/>
) : null}
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP
paddingHorizontal: Spacing.LEVEL_3
}}
>
<View
style={{
flexDirection: "row",
justifyContent: "space-between"
}}
>
<View>
<View
style={{
flexDirection: "row",
alignItems: "center",
flexShrink: 1,
gap: 5
gap: Spacing.LEVEL_1
}}
>
{item.type === "color" ? (
<Pressable
type="accent"
accentColor={item.colorCode}
accentText={colors.static.white}
{noteNotebooks?.map((item) => (
<View
key={item.id}
style={{
width: 30,
height: 30,
borderRadius: 100,
marginRight: 10
paddingHorizontal: Spacing.LEVEL_1,
paddingVertical: 2,
backgroundColor: colors.secondary.background,
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_0
}}
/>
) : item.type === "tag" ? (
<Icon
name="pound"
size={AppFontSize.lg}
color={colors.primary.icon}
/>
) : null}
>
<AppIcon
name="bookmark"
iconFamily="notesnook"
size={AppFontSize.xs}
color={colors.secondary.icon}
/>
<Paragraph fontSize="XS" color={colors.secondary.paragraph}>
{item.title}
</Paragraph>
</View>
))}
<Heading size={AppFontSize.lg}>{item.title}</Heading>
{tags?.map((item) =>
item.id ? (
<View
key={item.id}
style={{
borderRadius: 100,
paddingHorizontal: Spacing.LEVEL_1,
paddingVertical: 2,
backgroundColor: colors.secondary.background,
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_0
}}
>
<Paragraph
size={AppFontSize.xs}
color={colors.secondary.paragraph}
>
{item.title}
</Paragraph>
</View>
) : null
)}
</View>
{item.type === "note" ? (
<IconButton
name="open-in-new"
type="plain"
color={colors.primary.icon}
size={AppFontSize.lg}
<View
style={{
flexDirection: "row",
justifyContent: "space-between"
}}
>
<View
style={{
alignSelf: "flex-start"
flexDirection: "row",
alignItems: "center",
flexShrink: 1,
gap: Spacing.LEVEL_1
}}
onPress={() => {
close();
eSendEvent(eOnLoadNote, {
item: item,
newTab: true
});
if (!DDS.isTab) {
fluidTabsRef.current?.goToPage("editor");
}
>
{item.type === "color" ? (
<Pressable
type="accent"
accentColor={item.colorCode}
accentText={colors.static.white}
style={{
width: 8,
height: 8,
borderRadius: 100
}}
/>
) : item.type === "tag" ? (
<AppIcon
name="shopping-mode"
iconFamily="evilicons"
size={AppFontSize.lg}
color={colors.primary.icon}
/>
) : null}
<Heading size={AppFontSize.xl}>{item.title}</Heading>
</View>
{item.type === "note" ? (
<IconButton
name="square-out"
iconFamily="notesnook"
type="plain"
color={colors.primary.icon}
size={AppFontSize.lg}
style={{
alignSelf: "flex-start"
}}
onPress={() => {
close();
eSendEvent(eOnLoadNote, {
item: item,
newTab: true
});
if (!DDS.isTab) {
fluidTabsRef.current?.goToPage("editor");
}
}}
/>
) : null}
</View>
{(item.type === "notebook" || item.type === "reminder") &&
item.description ? (
<Paragraph>{item.description}</Paragraph>
) : null}
{item.type === "reminder" ? (
<ReminderTime
reminder={item}
style={{
justifyContent: "flex-start",
borderWidth: 0,
alignSelf: "flex-start",
backgroundColor: "transparent",
paddingHorizontal: 0,
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL
}}
fontSize={AppFontSize.xs}
/>
) : null}
</View>
{(item.type === "notebook" || item.type === "reminder") &&
item.description ? (
<Paragraph>{item.description}</Paragraph>
<DateMeta item={item} />
{item.type === "note" && colorNotes.length > 0 ? (
<Tags close={close} item={item} />
) : null}
{item.type === "note" ? (
<TagStrip close={close} item={item} />
) : null}
{item.type === "reminder" ? (
<ReminderTime
reminder={item}
style={{
justifyContent: "flex-start",
borderWidth: 0,
alignSelf: "flex-start",
backgroundColor: "transparent",
paddingHorizontal: 0,
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL
<View
style={{
flexDirection: "row",
borderBottomWidth: 1,
borderTopWidth: colorNotes.length > 0 ? 1 : 0,
borderColor: colors.primary.border,
paddingVertical: Spacing.LEVEL_2,
paddingTop: colorNotes.length > 0 ? Spacing.LEVEL_2 : 0,
gap: Spacing.LEVEL_2
}}
>
<Button
onPress={async () => {
ManageTags.present([item.id]);
close();
}}
buttonType={{
text: colors.primary.paragraph
}}
title={strings.addTag()}
type={colorNotes?.length ? "accent-outline" : "shade"}
icon="plus"
iconFamily="notesnook"
style={{
paddingHorizontal: Spacing.LEVEL_3,
paddingVertical: Spacing.LEVEL_2,
width: colorNotes?.length > 0 ? "100%" : "48.5%"
}}
fontSize={AppFontSize.xs}
/>
) : null}
{colorNotes.length > 0 ? null : (
<Button
onPress={() => {
if (colorFeature && !colorFeature.isAllowed) {
ToastManager.show({
message: colorFeature.error,
type: "info",
context: "local",
actionText: strings.upgrade(),
func: () => {
PaywallSheet.present(colorFeature);
ToastManager.hide();
}
});
return;
}
useSettingStore.getState().setSheetKeyboardHandler(false);
setVisible(true);
}}
title={strings.addColor()}
type="secondaryAccented"
icon="plus"
iconFamily="notesnook"
style={{
width: "48.5%",
paddingHorizontal: Spacing.LEVEL_3,
paddingVertical: Spacing.LEVEL_2
}}
/>
)}
</View>
</View>
<DateMeta item={item} />
<Line bottom={0} top={0} />
{item.type === "note" ? (
<>
<Tags close={close} item={item} />
<Line bottom={0} top={0} />
</>
) : null}
{item.type === "note" ? (
{/* {item.type === "note" ? (
<Notebooks note={item} close={close} />
) : null}
) : null} */}
<Items
item={item}
buttons={buttons}

View File

@@ -27,12 +27,13 @@ import { Action, ActionId, useActions } from "../../hooks/use-actions";
import { useStoredRef } from "../../hooks/use-stored-ref";
import { DDS } from "../../services/device-detection";
import { useSettingStore } from "../../stores/use-setting-store";
import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import AppIcon from "../ui/AppIcon";
import { Button } from "../ui/button";
import { Pressable } from "../ui/pressable";
import Paragraph from "../ui/typography/paragraph";
import { Radius, Spacing } from "../../common/design/spacing";
const TOP_BAR_ITEMS: ActionId[] = [
"pin",
@@ -152,7 +153,7 @@ export const Items = ({
key={item.id}
style={{
alignItems: "center",
width: columnItemWidth - 8,
width: columnItemWidth - 10,
opacity: item.locked ? 0.5 : 1
}}
>
@@ -161,12 +162,12 @@ export const Items = ({
type={item.checked ? "shade" : "secondary"}
testID={"icon-" + item.id}
style={{
height: columnItemWidth / 1.5,
width: columnItemWidth - 8,
width: columnItemWidth - 10,
paddingVertical: Spacing.LEVEL_2,
borderRadius: 10,
justifyContent: "center",
alignItems: "center",
marginBottom: DDS.isTab ? 7 : 3.5
marginBottom: 6
}}
>
<Icon
@@ -253,7 +254,7 @@ export const Items = ({
key={item.id}
testID={"icon-" + item.id}
style={{
width: columnItemWidth - 8,
width: columnItemWidth - 10,
alignSelf: "flex-start",
gap: DefaultAppStyles.GAP_VERTICAL_SMALL
}}
@@ -261,24 +262,25 @@ export const Items = ({
<View
style={{
height: columnItemWidth / 2,
width: columnItemWidth - DefaultAppStyles.GAP_SMALL,
width: 65,
justifyContent: "center",
alignItems: "center",
borderWidth: 1,
borderRadius: defaultBorderRadius,
borderColor: item.checked
? item.activeColor || colors.primary.accent
: colors.primary.border,
overflow: "hidden"
backgroundColor: item.checked
? colors.primary.shade
: colors.secondary.background,
borderRadius: Radius.XS,
overflow: "hidden",
paddingVertical: Spacing.LEVEL_2,
paddingHorizontal: Spacing.LEVEL_2
}}
>
<Icon
name={item.icon}
allowFontScaling
size={DDS.isTab ? AppFontSize.xxl : AppFontSize.md + 4}
size={16}
color={
item.checked
? item.activeColor || colors.primary.accent
? colors.primary.icon
: item.id === "delete" || item.id === "trash"
? colors.error.icon
: colors.secondary.icon
@@ -310,7 +312,13 @@ export const Items = ({
<Paragraph
textBreakStrategy="simple"
size={AppFontSize.xxs}
fontSize="XXS"
fontFamily="MEDIUM"
color={
item.checked
? colors.primary.paragraph
: colors.secondary.paragraph
}
style={{ textAlign: "center" }}
>
{item.title}
@@ -321,8 +329,12 @@ export const Items = ({
[
colors.error.icon,
colors.primary.accent,
colors.primary.border,
colors.primary.icon,
colors.primary.paragraph,
colors.primary.shade,
colors.secondary.background,
colors.secondary.icon,
colors.secondary.paragraph,
colors.static.orange,
columnItemWidth,
topBarSorting
@@ -352,16 +364,18 @@ export const Items = ({
autoplay={false}
showPagination
paginationStyleItemActive={{
borderRadius: 2,
backgroundColor: colors.selected.background,
height: 6,
marginHorizontal: 2
borderRadius: 6,
backgroundColor: colors.selected.accent,
height: 5,
width: 20,
marginHorizontal: 3
}}
paginationStyleItemInactive={{
borderRadius: 2,
borderRadius: 6,
backgroundColor: colors.secondary.background,
height: 6,
marginHorizontal: 2
height: 5,
width: 14,
marginHorizontal: 3
}}
paginationStyle={{
position: "relative",
@@ -380,7 +394,7 @@ export const Items = ({
style={{
flexDirection: "row",
paddingHorizontal: DefaultAppStyles.GAP,
gap: 5,
gap: Spacing.LEVEL_2,
width: width
}}
>
@@ -394,7 +408,7 @@ export const Items = ({
style={{
flexDirection: "row",
flexWrap: "wrap",
gap: 5,
gap: Spacing.LEVEL_1,
paddingHorizontal: DefaultAppStyles.GAP
}}
>

View File

@@ -17,18 +17,17 @@ 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 { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import { View } from "react-native";
import { db } from "../../common/database";
import ManageTags from "../../screens/manage-tags";
import { TaggedNotes } from "../../screens/notes/tagged";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { sleep } from "../../utils/time";
import { Button } from "../ui/button";
import { ColorTags } from "./color-tags";
import { Spacing } from "../../common/design/spacing";
export const Tags = ({ item, close }) => {
const { colors } = useThemeColors();
@@ -37,32 +36,12 @@ export const Tags = ({ item, close }) => {
<View
style={{
flexDirection: "row",
flexWrap: "wrap",
alignItems: "center",
paddingHorizontal: DefaultAppStyles.GAP,
alignSelf: "center",
justifyContent: "space-between",
width: "100%"
width: "100%",
borderTopWidth: 1,
borderColor: colors.primary.border,
paddingVertical: Spacing.LEVEL_3
}}
>
<Button
onPress={async () => {
ManageTags.present([item.id]);
close();
}}
buttonType={{
text: colors.primary.accent
}}
title={strings.addTag()}
type="secondary"
icon="plus"
iconPosition="right"
fontSize={AppFontSize.xs}
style={{
paddingHorizontal: DefaultAppStyles.GAP_SMALL,
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL
}}
/>
<ColorTags item={item} />
</View>
) : null;

View File

@@ -40,6 +40,7 @@ import { getElevationStyle } from "../../../utils/elevation";
import { defaultBorderRadius } from "../../../utils/size";
import { useThemeColors } from "@notesnook/theme";
import { getContainerBorder } from "../../../utils/colors";
import { Radius, Spacing } from "../../../common/design/spacing";
export const AddNotebookSheet = ({
notebook,
@@ -127,53 +128,63 @@ export const AddNotebookSheet = ({
...getElevationStyle(5),
width: DDS.isTab ? 400 : "85%",
maxHeight: 450,
borderRadius: defaultBorderRadius,
borderRadius: Radius.LG,
backgroundColor: colors.primary.background,
paddingTop: 12,
gap: Spacing.LEVEL_4,
paddingVertical: Spacing.LEVEL_4,
...getContainerBorder(colors.primary.border, 0.5),
overflow: "hidden"
}}
>
<View
style={{
paddingHorizontal: 12
paddingHorizontal: Spacing.LEVEL_3,
gap: Spacing.LEVEL_4
}}
>
<DialogHeader
title={notebook ? strings.editNotebook() : strings.newNotebook()}
/>
<Input
fwdRef={titleInput}
testID={notesnook.ids.dialogs.notebook.inputs.title}
onChangeText={(value) => {
title.current = value;
<View
style={{
gap: Spacing.LEVEL_2
}}
onLayout={() => {
setTimeout(() => {
titleInput?.current?.focus();
}, 300);
}}
placeholder={strings.enterNotebookTitle()}
onSubmit={() => {
descriptionInput.current?.focus();
}}
returnKeyLabel="Next"
returnKeyType="next"
defaultValue={notebook ? notebook.title : title.current}
/>
>
<Input
fwdRef={titleInput}
testID={notesnook.ids.dialogs.notebook.inputs.title}
onChangeText={(value) => {
title.current = value;
}}
onLayout={() => {
setTimeout(() => {
titleInput?.current?.focus();
}, 300);
}}
placeholder={"eg. My Notebook"}
onSubmit={() => {
descriptionInput.current?.focus();
}}
label={strings.enterNotebookTitle()}
returnKeyLabel="Next"
returnKeyType="next"
defaultValue={notebook ? notebook.title : title.current}
/>
<Input
fwdRef={descriptionInput}
testID={notesnook.ids.dialogs.notebook.inputs.description}
onChangeText={(value) => {
description.current = value;
}}
placeholder={strings.enterNotebookDescription()}
returnKeyLabel={strings.next()}
returnKeyType="next"
defaultValue={notebook ? notebook.description : ""}
/>
<Input
fwdRef={descriptionInput}
testID={notesnook.ids.dialogs.notebook.inputs.description}
onChangeText={(value) => {
description.current = value;
}}
label={strings.enterNotebookDescription()}
placeholder={"eg. This is My Notebook"}
returnKeyLabel={strings.next()}
returnKeyType="next"
defaultValue={notebook ? notebook.description : ""}
/>
</View>
</View>
<DialogButtons
onPressNegative={() => {

View File

@@ -23,7 +23,6 @@ import dayjs from "dayjs";
import React, { useEffect, useState } from "react";
import {
Linking,
Platform,
ScrollView,
Text,
TouchableOpacity,
@@ -41,12 +40,15 @@ import { DefaultAppStyles } from "../../../utils/styles";
import { Button } from "../../ui/button";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { Radius, Spacing } from "../../../common/design/spacing";
import useGlobalSafeAreaInsets from "../../../hooks/use-global-safe-area-insets";
const isGithubRelease = Config.GITHUB_RELEASE === "true";
export const BuyPlan = (props: {
planId: string;
canActivateTrial?: boolean;
pricingPlans: ReturnType<typeof usePricingPlans>;
}) => {
const insets = useGlobalSafeAreaInsets();
const { colors } = useThemeColors();
const [checkoutUrl, setCheckoutUrl] = useState<string>();
const pricingPlans = props.pricingPlans;
@@ -63,6 +65,18 @@ export const BuyPlan = (props: {
: (pricingPlans.selectedProduct as RNIap.Product)?.productId
)?.includes("5");
const isAnnual = isGithubRelease
? (pricingPlans.selectedProduct as Plan)?.period === "yearly"
: (pricingPlans.selectedProduct as RNIap.Product)?.productId?.includes(
"yearly"
);
const hasTrialOffer = pricingPlans.hasTrialOffer(
props.planId,
(pricingPlans.selectedProduct as RNIap.Product)?.productId ||
(pricingPlans.selectedProduct as Plan)?.period
);
return checkoutUrl ? (
<View
style={{
@@ -88,162 +102,274 @@ export const BuyPlan = (props: {
/>
</View>
) : (
<ScrollView
contentContainerStyle={{
marginTop: DefaultAppStyles.GAP_VERTICAL
<View
style={{
flex: 1
}}
keyboardDismissMode="none"
keyboardShouldPersistTaps="always"
>
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP,
gap: DefaultAppStyles.GAP_VERTICAL
<ScrollView
contentContainerStyle={{
paddingVertical: Spacing.LEVEL_4
}}
keyboardDismissMode="none"
keyboardShouldPersistTaps="always"
>
{[
Config.GITHUB_RELEASE === "true"
? "yearly"
: `notesnook.${props.planId}.yearly`,
Config.GITHUB_RELEASE === "true"
? "monthly"
: `notesnook.${props.planId}.monthly`,
...(props.planId === "essential" || pricingPlans.isSubscribed()
? []
: [
Config.GITHUB_RELEASE === "true"
? "5-year"
: `notesnook.${props.planId}.5year`
])
].map((item) => (
<ProductItem
key={item}
pricingPlans={pricingPlans}
productId={item}
/>
))}
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
borderWidth: 1,
borderColor: colors.primary.border,
padding: DefaultAppStyles.GAP,
borderRadius: defaultBorderRadius
paddingHorizontal: DefaultAppStyles.GAP,
gap: Spacing.LEVEL_4
}}
>
<Heading color={colors.primary.paragraph} size={AppFontSize.sm}>
{strings.dueToday()}{" "}
{pricingPlans.hasTrialOffer(
props.planId,
(pricingPlans?.selectedProduct as RNIap.Product)?.productId ||
(pricingPlans?.selectedProduct as Plan)?.period
) ? (
<Text
style={{
color: colors.primary.accent
}}
>
({strings.daysFree(`${billingDuration?.duration || 0}`)})
</Text>
) : null}
</Heading>
<Paragraph color={colors.primary.paragraph}>
{pricingPlans.hasTrialOffer(
props.planId,
(pricingPlans?.selectedProduct as RNIap.Product)?.productId ||
(pricingPlans?.selectedProduct as Plan)?.period
)
? "FREE"
: pricingPlans.getStandardPrice(
pricingPlans.selectedProduct as RNIap.Subscription
)}
</Paragraph>
</View>
{pricingPlans.hasTrialOffer(
props.planId,
(pricingPlans?.selectedProduct as RNIap.Product)?.productId ||
(pricingPlans?.selectedProduct as Plan)?.period
) ? (
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
borderWidth: 1,
borderColor: colors.primary.border,
padding: DefaultAppStyles.GAP,
borderRadius: defaultBorderRadius
gap: Spacing.LEVEL_2
}}
>
<Paragraph color={colors.secondary.paragraph}>
{strings.due(
dayjs()
.add(billingDuration?.duration || 0, "day")
.format("DD MMMM")
)}
</Paragraph>
<Paragraph color={colors.secondary.paragraph}>
{pricingPlans.getStandardPrice(
pricingPlans.selectedProduct as RNIap.Subscription
)}
</Paragraph>
</View>
) : null}
{pricingPlans.hasTrialOffer(
props.planId,
(pricingPlans.selectedProduct as RNIap.Product)?.productId ||
(pricingPlans.selectedProduct as Plan)?.period
) || is5YearPlanSelected ? (
<View
style={{
gap: DefaultAppStyles.GAP_VERTICAL,
borderWidth: 1,
borderColor: colors.primary.border,
padding: DefaultAppStyles.GAP,
borderRadius: defaultBorderRadius
}}
>
{(is5YearPlanSelected
? strings["5yearPlanConditions"]()
: [
strings.trialPlanConditions[0](
billingDuration?.duration as number as never
),
...(isGithubRelease
? []
: [strings.trialPlanConditions[1](Platform.OS as never)])
]
).map((item) => (
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: 10,
flex: 1
}}
{[
Config.GITHUB_RELEASE === "true"
? "yearly"
: `notesnook.${props.planId}.yearly`,
Config.GITHUB_RELEASE === "true"
? "monthly"
: `notesnook.${props.planId}.monthly`,
...(props.planId === "essential" || pricingPlans.isSubscribed()
? []
: [
Config.GITHUB_RELEASE === "true"
? "5-year"
: `notesnook.${props.planId}.5year`
])
].map((item) => (
<ProductItem
key={item}
>
<Icon
color={colors.primary.accent}
size={AppFontSize.lg}
name="check"
/>
<Paragraph
style={{
flexShrink: 1
}}
>
{item}
</Paragraph>
</View>
pricingPlans={pricingPlans}
productId={item}
/>
))}
</View>
) : null}
<Paragraph
fontFamily="MEDIUM"
fontSize="MD"
color={colors.secondary.paragraph}
>
{strings.paymentSummary()}
</Paragraph>
<View
style={{
borderWidth: 1,
borderColor: colors.primary.border,
borderRadius: Radius.S,
backgroundColor: colors.secondary.background,
padding: Spacing.LEVEL_3
}}
>
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
}}
>
<View
style={{
gap: Spacing.LEVEL_1
}}
>
<Heading color={colors.primary.paragraph} size={AppFontSize.md}>
{strings.dueToday()}{" "}
</Heading>
<Paragraph>
{hasTrialOffer ? (
<Text>
{strings.freeTrialIncludes(
billingDuration?.duration || 0
)}
</Text>
) : is5YearPlanSelected ? (
strings.billingType.annual()
) : null}
</Paragraph>
</View>
<Heading color={colors.primary.paragraph} fontSize="SM">
{hasTrialOffer
? "Free"
: pricingPlans.getStandardPrice(
pricingPlans.selectedProduct as RNIap.Subscription
)}
</Heading>
</View>
{hasTrialOffer ? (
<>
<View
style={{
width: "100%",
height: 1,
backgroundColor: colors.primary.border,
marginVertical: Spacing.LEVEL_2
}}
/>
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
}}
>
<View
style={{
gap: Spacing.LEVEL_1
}}
>
<Heading
color={colors.primary.paragraph}
size={AppFontSize.md}
>
{strings.nextBillingDate()}
</Heading>
<Paragraph>
{dayjs()
.add(billingDuration?.duration || 0, "day")
.format("DD MMMM,YYYY")}{" "}
*{" "}
{isAnnual
? strings.billingType.annual()
: is5YearPlanSelected
? strings.billingType.oneTime()
: strings.billingType.monthly()}
</Paragraph>
</View>
<Heading fontSize="SM" color={colors.primary.accent}>
{pricingPlans.getStandardPrice(
pricingPlans.selectedProduct as RNIap.Subscription
)}
</Heading>
</View>
</>
) : null}
</View>
<Paragraph
fontFamily="MEDIUM"
fontSize="MD"
color={colors.secondary.paragraph}
>
{strings.whatsIncluded()}
</Paragraph>
<View
style={{
gap: Spacing.LEVEL_2,
borderWidth: 1,
borderColor: colors.primary.border,
padding: Spacing.LEVEL_3,
borderRadius: Radius.S,
backgroundColor: colors.secondary.background,
marginBottom: 27
}}
>
{[
strings.planWhatsIncluded.unlimitedNotes(),
strings.planWhatsIncluded.endToEnd(),
strings.planWhatsIncluded.allDevices(),
hasTrialOffer
? strings.planWhatsIncluded.freeTrial(
billingDuration?.duration || 0
)
: undefined,
hasTrialOffer ? strings.planWhatsIncluded.remind() : undefined,
...(is5YearPlanSelected
? strings["5yearPlanConditions"]()
: ([] as string[]))
].map((item) =>
!item ? null : (
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: Spacing.LEVEL_1,
flex: 1
}}
key={item}
>
<Icon
color={colors.primary.accent}
size={AppFontSize.lg}
name="check"
/>
<Paragraph
style={{
flexShrink: 1
}}
>
{item}
</Paragraph>
</View>
)
)}
<Paragraph
style={{
marginTop: Spacing.LEVEL_0
}}
fontSize="XS"
>
<Heading fontSize="XS">{strings.note()}: </Heading>
{is5YearPlanSelected
? strings.oneTimePurchase()
: strings.cancelAnytimeAlt()}
</Paragraph>
</View>
<Paragraph
style={{
textAlign: "center"
}}
color={colors.secondary.paragraph}
size={AppFontSize.xs}
>
{strings.subTerms[0]()}{" "}
<Text
style={{
color: colors.primary.accent
}}
onPress={() => {
openLinkInBrowser("https://notesnook.com/privacy");
}}
>
{strings.subTerms[1]()}
</Text>{" "}
{strings.subTerms[2]()}{" "}
<Text
style={{
color: colors.primary.accent
}}
onPress={() => {
openLinkInBrowser("https://notesnook.com/tos");
}}
>
{strings.subTerms[3]()}
</Text>
</Paragraph>
</View>
</ScrollView>
<View
style={{
backgroundColor: colors.secondary.background,
width: "100%",
padding: Spacing.LEVEL_3,
marginBottom: -insets.bottom,
paddingBottom: insets.bottom,
borderTopWidth: 1,
borderTopColor: colors.primary.border
}}
>
<Button
width="100%"
type="accent"
@@ -278,50 +404,8 @@ export const BuyPlan = (props: {
);
}}
/>
<Paragraph
style={{
textAlign: "center"
}}
color={colors.secondary.paragraph}
size={AppFontSize.xs}
>
{is5YearPlanSelected
? strings.oneTimePurchase()
: strings.cancelAnytimeAlt()}
</Paragraph>
<Paragraph
style={{
textAlign: "center"
}}
color={colors.secondary.paragraph}
size={AppFontSize.xs}
>
{strings.subTerms[0]()}{" "}
<Text
style={{
textDecorationLine: "underline"
}}
onPress={() => {
openLinkInBrowser("https://notesnook.com/privacy");
}}
>
{strings.subTerms[1]()}
</Text>{" "}
{strings.subTerms[2]()}{" "}
<Text
style={{
textDecorationLine: "underline"
}}
onPress={() => {
openLinkInBrowser("https://notesnook.com/tos");
}}
>
{strings.subTerms[3]()}
</Text>
</Paragraph>
</View>
</ScrollView>
</View>
);
};
@@ -410,7 +494,13 @@ const ProductItem = (props: {
style={{
flexDirection: "row",
gap: 10,
opacity: isSubscribed ? 0.5 : 1
opacity: isSubscribed ? 0.5 : 1,
backgroundColor: colors.secondary.background,
padding: Spacing.LEVEL_2,
borderRadius: Radius.S,
borderWidth: 1,
borderColor: colors.primary.border,
justifyContent: "space-between"
}}
activeOpacity={0.9}
onPress={() => {
@@ -429,60 +519,85 @@ const ProductItem = (props: {
);
}}
>
<Icon
name={isSelected ? "radiobox-marked" : "radiobox-blank"}
color={isSelected ? colors.primary.accent : colors.secondary.icon}
size={AppFontSize.lg}
/>
<View>
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_1
}}
>
<Icon
name={isSelected ? "radiobox-marked" : "radiobox-blank"}
color={isSelected ? colors.primary.accent : colors.secondary.icon}
size={AppFontSize.lg}
/>
<View
style={{
flexDirection: "row",
gap: DefaultAppStyles.GAP_VERTICAL_SMALL
gap: Spacing.LEVEL_1
}}
>
<Heading size={AppFontSize.md}>
{isAnnual
? strings.yearly()
: is5YearProduct
? strings.fiveYearPlan()
: strings.monthly()}
</Heading>
<View
style={{
flexDirection: "row",
gap: DefaultAppStyles.GAP_VERTICAL_SMALL
}}
>
<Heading size={AppFontSize.md}>
{isAnnual
? strings.yearly()
: is5YearProduct
? strings.fiveYearPlan()
: strings.monthly()}
</Heading>
{discountValue ? (
<View
style={{
backgroundColor: colors.static.red,
borderRadius: defaultBorderRadius,
paddingHorizontal: 6,
alignItems: "center",
justifyContent: "center"
}}
>
<Heading color={colors.static.white} size={AppFontSize.xs}>
{strings.bestValue()} - {strings.percentOff(`${discountValue}`)}
</Heading>
</View>
) : null}
{discountValue ? (
<View
style={{
backgroundColor: colors.primary.accent,
borderRadius: defaultBorderRadius,
padding: Spacing.LEVEL_0,
alignItems: "center",
justifyContent: "center"
}}
>
<Paragraph color={colors.static.white} size={AppFontSize.xxs}>
{strings.percentOff(`${discountValue}`)}
</Paragraph>
</View>
) : null}
{isSubscribed ? (
<View
style={{
backgroundColor: colors.primary.accent,
borderRadius: defaultBorderRadius,
paddingHorizontal: 6,
alignItems: "center",
justifyContent: "center"
}}
>
<Heading color={colors.static.white} size={AppFontSize.xs}>
{strings.currentPlan()}
</Heading>
</View>
) : null}
{isSubscribed ? (
<View
style={{
backgroundColor: colors.primary.accent,
borderRadius: defaultBorderRadius,
paddingHorizontal: 6,
alignItems: "center",
justifyContent: "center"
}}
>
<Heading color={colors.static.white} size={AppFontSize.xs}>
{strings.currentPlan()}
</Heading>
</View>
) : null}
</View>
<Paragraph>
{is5YearProduct
? strings.billingType.oneTime()
: isAnnual
? strings.billingType.annual()
: strings.billingType.monthly()}
</Paragraph>
</View>
</View>
<Paragraph size={AppFontSize.md}>
<View
style={{
gap: Spacing.LEVEL_1
}}
>
<Heading size={AppFontSize.sm}>
{isAnnual || is5YearProduct
? `${props.pricingPlans.getPrice(
product as RNIap.Subscription,
@@ -493,15 +608,17 @@ const ProductItem = (props: {
? 1
: 0,
isAnnual
)}/${strings.month()}`
)}`
: null}
{!isAnnual && !is5YearProduct
? `${props.pricingPlans.getStandardPrice(
product as RNIap.Subscription
)}/${strings.month()}`
)}`
: null}
</Paragraph>
</Heading>
<Paragraph size={AppFontSize.xs}>/month</Paragraph>
</View>
</TouchableOpacity>
);

View File

@@ -18,15 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
GroupHeader,
GroupingKey,
GroupOptions,
Item,
ItemType,
SortOptions
SortOptions,
VirtualizedGrouping
} from "@notesnook/core";
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React, { useState } from "react";
import { View } from "react-native";
import React, { RefObject, useEffect, useRef, useState } from "react";
import { FlatList, View } from "react-native";
import { db } from "../../../common/database";
import { eSendEvent } from "../../../services/event-manager";
import Navigation from "../../../services/navigation";
@@ -42,48 +45,68 @@ import { Button } from "../../ui/button";
import { Pressable } from "../../ui/pressable";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { Radius, Spacing } from "../../../common/design/spacing";
import { getElevationStyle } from "../../../utils/elevation";
import { useMessageStore } from "../../../stores/use-message-store";
const Sort = ({
type,
screen,
hideGroupOptions
hideGroupOptions,
hideJumpToSection,
ref,
data
}: {
type: ItemType;
screen?: RouteName;
hideGroupOptions?: boolean;
hideJumpToSection?: boolean;
data?: VirtualizedGrouping<Item>;
ref?: RefObject<FlatList>;
}) => {
const { colors } = useThemeColors();
const [groups, setGroups] = useState<
{
index: number;
group: GroupHeader;
}[]
>();
const offsets = useRef<number[]>([]);
const scrollRef = useRef<RefObject<FlatList>>(undefined);
const [currentIndex, setCurrentIndex] = useState(0);
const currentScrollPosition = useRef(0);
const groupType =
screen === "Archive"
? "archive"
: screen === "Search"
? "search"
: screen === "Notes"
? "home"
: screen === "Trash" || type === "trash"
? "trash"
: ((type + "s") as GroupingKey);
? "search"
: screen === "Notes"
? "home"
: screen === "Trash" || type === "trash"
? "trash"
: ((type + "s") as GroupingKey);
const [groupOptions, setGroupOptions] = useState(
db.settings.getGroupOptions(groupType)
);
const getSortButtonTitle = () => {
const { sortDirection, groupBy, sortBy } = groupOptions || {};
const getSortButtonTitle = (type: "asc" | "desc") => {
const { groupBy, sortBy } = groupOptions || {};
const isAlphabetical = groupBy === "abc" || sortBy === "title";
const isDueDate = sortBy === "dueDate";
const isRelevance = sortBy === "relevance";
if (sortDirection === "asc") {
if (type === "asc") {
if (isAlphabetical) return strings.aToZ();
if (isDueDate) return strings.earliestFirst();
if (isRelevance) return strings.leastRelevantFirst();
return strings.oldNew();
return strings.oldestFirst();
} else {
if (isAlphabetical) return strings.zToA();
if (isDueDate) return strings.latestFirst();
if (isRelevance) return strings.mostRelevantFirst();
return strings.newOld();
return strings.newestFirst();
}
};
@@ -111,13 +134,49 @@ const Sort = ({
await updateGroupOptions(_groupOptions);
};
useEffect(() => {
data?.groups?.().then((groups) => {
setGroups(groups);
offsets.current = [];
groups.map((item, index) => {
let offset = 35 * index;
let groupIndex = item.index;
const messageState = useMessageStore.getState().message;
const msgOffset = messageState?.visible ? 60 : 10;
groupIndex = groupIndex + 1;
groupIndex = groupIndex - (index + 1);
offset = offset + groupIndex * 100 + msgOffset;
offsets.current.push(offset);
});
const index = offsets.current?.findIndex((o, i) => {
return (
o <= currentScrollPosition.current + 100 &&
offsets.current[i + 1] - 100 > currentScrollPosition.current
);
});
setCurrentIndex(index < 0 ? 0 : index);
});
}, [data]);
const onPress = (item: { index: number; group: GroupHeader }) => {
scrollRef.current?.current?.scrollToIndex({
index: item.index,
animated: true
});
close();
};
return (
<View
style={{
width: "100%",
backgroundColor: colors.primary.background,
justifyContent: "space-between",
gap: DefaultAppStyles.GAP_SMALL
gap: Spacing.LEVEL_3,
paddingTop: Spacing.LEVEL_3
}}
>
<View
@@ -128,9 +187,9 @@ const Sort = ({
paddingHorizontal: DefaultAppStyles.GAP
}}
>
<Heading size={AppFontSize.lg}>{strings.sortBy()}</Heading>
<Heading fontSize="LG">{strings.sortBy()}</Heading>
<Button
{/* <Button
title={getSortButtonTitle()}
icon={
groupOptions?.sortDirection === "asc"
@@ -145,14 +204,16 @@ const Sort = ({
paddingHorizontal: DefaultAppStyles.GAP_SMALL
}}
onPress={setOrderBy}
/>
/> */}
</View>
<View
style={{
flexDirection: "column",
justifyContent: "flex-start",
borderBottomColor: colors.primary.border
borderBottomColor: colors.primary.border,
paddingHorizontal: Spacing.LEVEL_3,
gap: Spacing.LEVEL_3
}}
>
{Object.keys(SORT).map((item) => {
@@ -173,43 +234,95 @@ const Sort = ({
}
return (
<Pressable
<View
key={item}
type={groupOptions?.sortBy === item ? "selected" : "plain"}
noborder
style={{
width: "100%",
justifyContent: "space-between",
flexDirection: "row",
borderRadius: 0,
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
}}
onPress={async () => {
const _groupOptions: GroupOptions = {
...groupOptions,
sortBy:
type === "trash"
? "dateDeleted"
: (item as SortOptions["sortBy"])
};
await updateGroupOptions(_groupOptions);
gap: Spacing.LEVEL_2
}}
>
<Paragraph>
{strings.sortByStrings[
item as keyof typeof strings.sortByStrings
]()}
</Paragraph>
<Pressable
type={
groupOptions?.sortBy === item ? "selected" : "plain-outline"
}
style={{
width: "100%",
justifyContent: "space-between",
flexDirection: "row",
borderRadius: Radius.XS,
paddingHorizontal: Spacing.LEVEL_2,
paddingVertical: Spacing.LEVEL_2
}}
onPress={async () => {
const _groupOptions: GroupOptions = {
...groupOptions,
sortBy:
type === "trash"
? "dateDeleted"
: (item as SortOptions["sortBy"])
};
await updateGroupOptions(_groupOptions);
}}
>
<Paragraph>
{strings.sortByStrings[
item as keyof typeof strings.sortByStrings
]()}
</Paragraph>
{groupOptions?.sortBy === item ? (
<AppIcon
size={AppFontSize.lg}
name="check"
color={colors.selected.accent}
/>
{groupOptions?.sortBy === item ? (
<AppIcon
size={AppFontSize.lg}
name="checkbox"
iconFamily="notesnook"
color={[colors.selected.accent, "white"]}
/>
) : null}
</Pressable>
{groupOptions.sortBy === item ? (
<View
style={{
backgroundColor: colors.secondary.background,
borderRadius: Radius.S,
padding: Spacing.LEVEL_1,
flexDirection: "row",
gap: Spacing.LEVEL_2
}}
>
<Button
style={{
flexGrow: 1,
borderRadius: Radius.XS,
...(groupOptions?.sortDirection === "desc"
? getElevationStyle(10)
: {})
}}
type={
groupOptions?.sortDirection === "desc"
? "accent-background"
: "plain"
}
title={getSortButtonTitle("desc")}
/>
<Button
style={{
flexGrow: 1,
borderRadius: Radius.XS,
...(groupOptions?.sortDirection === "asc"
? getElevationStyle(10)
: {})
}}
type={
groupOptions?.sortDirection === "asc"
? "accent-background"
: "plain"
}
title={getSortButtonTitle("asc")}
/>
</View>
) : null}
</Pressable>
</View>
);
})}
</View>
@@ -221,18 +334,19 @@ const Sort = ({
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
paddingHorizontal: Spacing.LEVEL_3,
paddingBottom: Spacing.LEVEL_3
}}
>
<Heading size={AppFontSize.lg}>{strings.groupBy()}</Heading>
<Heading fontSize="LG">{strings.groupBy()}</Heading>
</View>
<View
style={{
borderRadius: 0,
flexDirection: "row",
flexWrap: "wrap"
flexWrap: "wrap",
paddingHorizontal: Spacing.LEVEL_3,
gap: Spacing.LEVEL_2
}}
>
{Object.keys(GROUP).map((item) => (
@@ -241,16 +355,14 @@ const Sort = ({
type={
groupOptions?.groupBy === GROUP[item as keyof typeof GROUP]
? "selected"
: "plain"
: "plain-outline"
}
noborder
style={{
width: "100%",
justifyContent: "space-between",
flexDirection: "row",
borderRadius: 0,
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
width: "auto",
borderRadius: 100,
paddingHorizontal: Spacing.LEVEL_3,
paddingVertical: Spacing.LEVEL_1
}}
onPress={async () => {
const _groupOptions: GroupOptions = {
@@ -260,24 +372,82 @@ const Sort = ({
await updateGroupOptions(_groupOptions);
}}
>
<Paragraph>
<Paragraph
fontFamily={
groupOptions?.groupBy === GROUP[item as keyof typeof GROUP]
? "SEMI_BOLD"
: "REGULAR"
}
color={
groupOptions?.groupBy === GROUP[item as keyof typeof GROUP]
? colors.primary.paragraph
: colors.secondary.paragraph
}
>
{strings.groupByStrings[
item as keyof typeof strings.groupByStrings
]()}
</Paragraph>
{groupOptions.groupBy === item ? (
<AppIcon
size={AppFontSize.lg}
name="check"
color={colors.selected.accent}
/>
) : null}
</Pressable>
))}
</View>
</>
) : null}
{!hideJumpToSection && groups ? (
<>
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingHorizontal: Spacing.LEVEL_3,
paddingBottom: Spacing.LEVEL_3
}}
>
<Heading fontSize="LG">{strings.jumpToGroup()}</Heading>
</View>
<View
style={{
flexDirection: "row",
flexWrap: "wrap",
paddingHorizontal: Spacing.LEVEL_3,
gap: Spacing.LEVEL_2
}}
>
{groups?.map((item, index) => {
return (
<Pressable
key={item.group.id}
onPress={() => onPress(item)}
type={currentIndex === index ? "selected" : "plain-outline"}
style={{
minWidth: "20%",
width: null,
borderRadius: 100,
paddingHorizontal: Spacing.LEVEL_3,
paddingVertical: Spacing.LEVEL_1
}}
>
<Paragraph
size={AppFontSize.sm}
fontFamily={
currentIndex === index ? "SEMI_BOLD" : "REGULAR"
}
color={colors.primary.paragraph}
style={{
textAlign: "center"
}}
>
{item.group.title}
</Paragraph>
</Pressable>
);
})}
</View>
</>
) : null}
</View>
);
};

View File

@@ -21,7 +21,6 @@ import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { db } from "../../common/database";
import { useGroupOptions } from "../../hooks/use-group-options";
import { presentSheet, ToastManager } from "../../services/event-manager";
@@ -34,9 +33,7 @@ import { DefaultAppStyles } from "../../utils/styles";
import { presentDialog } from "../dialog/functions";
import { AddNotebookSheet } from "../sheets/add-notebook";
import Sort from "../sheets/sort";
import { IconButton } from "../ui/icon-button";
import { Pressable } from "../ui/pressable";
import Paragraph from "../ui/typography/paragraph";
import { SideMenuHome } from "./side-menu-home";
import { SideMenuNotebooks } from "./side-menu-notebooks";
import { SideMenuTags } from "./side-menu-tags";
@@ -44,12 +41,14 @@ import {
useSideMenuNotebookSelectionStore,
useSideMenuTagsSelectionStore
} from "./stores";
import { TabBarButton } from "./tab-bar-button";
import { useSideBarDraggingStore } from "./dragging-store";
import { Button } from "../ui/button";
import SettingsService from "../../services/settings";
import { isFeatureAvailable } from "@notesnook/common";
import PaywallSheet from "../sheets/paywall";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { Spacing } from "../../common/design/spacing";
/**
* Simple Tab View Implementation for the Side bar
@@ -77,7 +76,7 @@ type SimpleTabViewProps = {
};
const createSceneMap = (
scenes: Record<string, React.ComponentType<any>>
scenes: Record<string, React.ComponentType<unknown>>
): ((props: { route: SimpleRoute }) => React.ReactNode) => {
// eslint-disable-next-line react/display-name
return ({ route }: { route: SimpleRoute }) => {
@@ -216,55 +215,61 @@ const TabBar = (props: SimpleTabBarProps) => {
const getIcon = (key: string) => {
switch (key) {
case "home":
return "home-outline";
return "home";
case "notebooks":
return "book-outline";
return "bookmark";
case "tags":
return "pound";
return "shopping-mode";
default:
return "home-outline";
return "home";
}
};
return (
<View
style={{
flexDirection: "row",
width: "100%",
justifyContent: "space-between",
backgroundColor: colors.primary.background,
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_SMALL,
borderTopWidth: 1,
borderTopColor: colors.primary.border
paddingHorizontal: Spacing.LEVEL_3
}}
>
{isSelectionEnabled ? (
<>
{[
{
title: "Select all",
icon: "check-all"
},
{
title: "Delete",
icon: "delete"
},
{
title: "Move",
icon: "arrow-right-bold-box-outline",
hidden:
!notebookSelectionEnabled || props.navigationState.index !== 1
},
{
title: "Close",
icon: "close"
}
].map((item) =>
item.hidden ? null : (
<>
<Pressable
<View
style={{
flexDirection: "row",
width: "100%",
justifyContent: "space-between",
backgroundColor: colors.primary.background,
borderTopWidth: 1,
borderTopColor: colors.primary.border,
paddingTop: Spacing.LEVEL_2
}}
>
{isSelectionEnabled ? (
<>
{[
{
title: "Select all",
icon: "checks"
},
{
title: "Delete",
icon: "trash"
},
{
title: "Move",
icon: "drive-file-move",
hidden:
!notebookSelectionEnabled || props.navigationState.index !== 1
},
{
title: "Close",
icon: "close"
}
].map((item) =>
item.hidden ? null : (
<TabBarButton
key={item.title}
icon={item.icon}
label={item.title}
onPress={async () => {
switch (item.title) {
case "Select all": {
@@ -325,216 +330,172 @@ const TabBar = (props: SimpleTabBarProps) => {
}
}
}}
/>
)
)}
</>
) : (
<>
{dragging ? (
<Button
onPress={() => {
useSideBarDraggingStore.setState({
dragging: false
});
}}
style={{
width: "100%"
}}
type="accent"
testID="check"
title={strings.done()}
icon={"check"}
iconSize={AppFontSize.lg - 2}
/>
) : (
<>
<View
style={{
borderRadius: 10,
paddingVertical: 2,
width: "25%"
flexDirection: "row",
gap: Spacing.LEVEL_2
}}
type="plain"
>
<Icon
name={item.icon}
color={colors.primary.icon}
size={AppFontSize.lg}
/>
<Paragraph
color={colors.primary.paragraph}
size={AppFontSize.xxxs - 1}
>
{item.title}
</Paragraph>
</Pressable>
</>
)
)}
</>
) : (
<>
{dragging ? (
<Button
onPress={() => {
useSideBarDraggingStore.setState({
dragging: false
});
}}
style={{
width: "100%"
}}
type="accent"
testID="check"
title={strings.done()}
icon={"check"}
iconSize={AppFontSize.lg - 2}
/>
) : (
<>
<View
style={{
flexDirection: "row",
gap: DefaultAppStyles.GAP_SMALL
}}
>
{props.navigationState.routes.map((route, index) => {
const isFocused = props.navigationState.index === index;
{props.navigationState.routes.map((route, index) => {
const isFocused = props.navigationState.index === index;
return (
<Pressable
key={route.key}
testID={`tab-${route.key}`}
onPress={() => {
props.jumpTo(route.key);
switch (route.key) {
case "notebooks":
Navigation.routeNeedsUpdate(
"Notebooks",
Navigation.routeUpdateFunctions.Notebooks
);
break;
case "tags":
Navigation.routeNeedsUpdate(
"Tags",
Navigation.routeUpdateFunctions.Tags
);
break;
default:
break;
}
}}
style={{
borderRadius: 10,
paddingVertical: 2,
width: 40,
height: 40
}}
type={isFocused ? "selected" : "plain"}
>
<Icon
name={getIcon(route.key)}
color={
isFocused ? colors.selected.icon : colors.primary.icon
}
size={AppFontSize.lg}
return (
<TabBarButton
key={route.key}
testID={`tab-${route.key}`}
icon={getIcon(route.key)}
label={route.title || ""}
isActive={isFocused}
onPress={() => {
props.jumpTo(route.key);
switch (route.key) {
case "notebooks":
Navigation.routeNeedsUpdate(
"Notebooks",
Navigation.routeUpdateFunctions.Notebooks
);
break;
case "tags":
Navigation.routeNeedsUpdate(
"Tags",
Navigation.routeUpdateFunctions.Tags
);
break;
default:
break;
}
}}
/>
</Pressable>
);
})}
</View>
);
})}
</View>
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: DefaultAppStyles.GAP_SMALL
}}
>
{props.navigationState.index > 0 ? (
<>
<IconButton
name="plus"
testID="sidebar-add-button"
size={AppFontSize.lg - 2}
top={10}
color={colors.primary.icon}
onPress={async () => {
if (props.navigationState.index === 1) {
const notebooksFeature =
await isFeatureAvailable("notebooks");
if (!notebooksFeature.isAllowed) {
PaywallSheet.present(notebooksFeature);
return;
}
AddNotebookSheet.present();
} else {
const tagsFeature = await isFeatureAvailable("tags");
if (!tagsFeature.isAllowed) {
PaywallSheet.present(tagsFeature);
return;
}
presentDialog({
title: strings.addTag(),
paragraph: strings.addTagDesc(),
input: true,
positiveText: "Add",
positivePress: async (tag) => {
if (tag) {
await db.tags.add({
title: tag
});
useTagStore.getState().refresh();
return true;
}
ToastManager.show({
context: "local",
type: "error",
message: strings.allFieldsRequired()
});
return false;
}
});
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: DefaultAppStyles.GAP_SMALL
}}
>
{props.navigationState.index > 0 ? (
<>
<TabBarButton
icon="plus"
testID="sidebar-add-button"
label={
props.navigationState.index === 1 ? "Notebook" : "Tag"
}
}}
style={{
width: 35,
height: 35
}}
/>
onPress={async () => {
if (props.navigationState.index === 1) {
const notebooksFeature =
await isFeatureAvailable("notebooks");
if (!notebooksFeature.isAllowed) {
PaywallSheet.present(notebooksFeature);
return;
}
<IconButton
name={
groupOptions?.sortDirection === "asc"
? "sort-ascending"
: "sort-descending"
}
top={10}
testID="sidebar-sort-button"
color={colors.primary.icon}
onPress={() => {
presentSheet({
component: (
<Sort
type={
props.navigationState.index === 1
? "notebook"
: "tag"
AddNotebookSheet.present();
} else {
const tagsFeature =
await isFeatureAvailable("tags");
if (!tagsFeature.isAllowed) {
PaywallSheet.present(tagsFeature);
return;
}
presentDialog({
title: strings.addTag(),
inputLabel: "Enter title",
inputPlaceholder: "eg. journal",
input: true,
positiveText: "Add",
positivePress: async (tag) => {
if (tag) {
await db.tags.add({
title: tag
});
useTagStore.getState().refresh();
return true;
}
ToastManager.show({
context: "local",
type: "error",
message: strings.allFieldsRequired()
});
return false;
}
hideGroupOptions
/>
)
});
}}
style={{
width: 35,
height: 35
}}
size={AppFontSize.lg - 2}
/>
</>
) : null}
});
}
}}
/>
{props.navigationState.index === 0 ? (
<>
<IconButton
onPress={() => {
useThemeStore.getState().setColorScheme();
}}
style={{
width: 28,
height: 28
}}
top={10}
testID="sidebar-theme-button"
color={colors.primary.icon}
name={isDark ? "weather-night" : "weather-sunny"}
size={AppFontSize.lg - 2}
/>
</>
) : null}
</View>
</>
)}
</>
)}
<TabBarButton
icon={
groupOptions?.sortDirection === "asc"
? "sort-ascending"
: "sort-descending"
}
testID="sidebar-sort-button"
label="Sort"
onPress={() => {
presentSheet({
component: (
<Sort
type={
props.navigationState.index === 1
? "notebook"
: "tag"
}
hideGroupOptions
/>
)
});
}}
/>
</>
) : null}
{props.navigationState.index === 0 ? (
<>
<TabBarButton
icon={isDark ? "dark-mode-outline" : "sun"}
testID="sidebar-theme-button"
label={isDark ? "Dark" : "Light"}
onPress={() => {
useThemeStore.getState().setColorScheme();
}}
/>
</>
) : null}
</View>
</>
)}
</>
)}
</View>
</View>
);
};

View File

@@ -20,10 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useRef, useState } from "react";
import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { useTotalNotes } from "../../hooks/use-db-item";
import { db } from "../../common/database";
import { Radius, Spacing } from "../../common/design/spacing";
import {
eSubscribeEvent,
subscribeToItemUpdate
@@ -32,14 +32,14 @@ import Navigation from "../../services/navigation";
import useNavigationStore, {
RouteParams
} from "../../stores/use-navigation-store";
import { useRelationStore } from "../../stores/use-relation-store";
import { eAfterSync, eMenuItemUpdate } from "../../utils/events";
import { SideMenuItem } from "../../utils/menu-items";
import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { AppFontSize } from "../../utils/size";
import { Pressable } from "../ui/pressable";
import Paragraph from "../ui/typography/paragraph";
import { useSideBarDraggingStore } from "./dragging-store";
import { useRelationStore } from "../../stores/use-relation-store";
import AppIcon from "../ui/AppIcon";
export function MenuItem({
item,
@@ -142,29 +142,31 @@ export function MenuItem({
style={{
width: "100%",
alignSelf: "center",
borderRadius: defaultBorderRadius,
borderRadius: Radius.XS,
flexDirection: "row",
paddingHorizontal: DefaultAppStyles.GAP_SMALL,
paddingHorizontal: Spacing.LEVEL_1,
justifyContent: "space-between",
alignItems: "center",
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL
paddingVertical: Spacing.LEVEL_1,
marginBottom: Spacing.LEVEL_0
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
gap: DefaultAppStyles.GAP_SMALL
gap: Spacing.LEVEL_1
}}
>
{renderIcon ? (
renderIcon(item, AppFontSize.md)
) : (
<Icon
<AppIcon
style={{
textAlignVertical: "center",
textAlign: "left"
}}
iconFamily="notesnook"
allowFontScaling
name={item.icon}
color={
@@ -182,14 +184,15 @@ export function MenuItem({
color={
isFocused ? colors.selected.paragraph : colors.primary.paragraph
}
size={AppFontSize.sm}
fontFamily={isFocused ? "MEDIUM" : "REGULAR"}
fontSize="SM"
>
{item.title}
</Paragraph>
</View>
<Paragraph
size={AppFontSize.xxs}
fontSize="XS"
color={
isFocused ? colors.primary.paragraph : colors.secondary.paragraph
}

View File

@@ -24,19 +24,20 @@ import { StoreApi, UseBoundStore } from "zustand";
import { useTotalNotes } from "../../hooks/use-db-item";
import {
eSubscribeEvent,
eUnSubscribeEvent,
ToastManager
eUnSubscribeEvent
} from "../../services/event-manager";
import { TreeItem } from "../../stores/create-notebook-tree-stores";
import { SelectionStore } from "../../stores/item-selection-store";
import { eOnNotebookUpdated } from "../../utils/events";
import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import AppIcon from "../ui/AppIcon";
import { IconButton } from "../ui/icon-button";
import { Pressable } from "../ui/pressable";
import Paragraph from "../ui/typography/paragraph";
import { useRelationStore } from "../../stores/use-relation-store";
import { Radius, Spacing } from "../../common/design/spacing";
import Heading from "../ui/typography/heading";
import { AddNotebookSheet } from "../sheets/add-notebook";
export const NotebookItem = ({
index,
@@ -72,7 +73,7 @@ export const NotebookItem = ({
const notebook = item.notebook;
const isFocused = focused;
const { totalNotes, getTotalNotes } = useTotalNotes("notebook");
const updater = useRelationStore(state => state.updater);
const updater = useRelationStore((state) => state.updater);
const getTotalNotesRef = React.useRef(getTotalNotes);
getTotalNotesRef.current = getTotalNotes;
const { colors } = useThemeColors();
@@ -94,20 +95,31 @@ export const NotebookItem = ({
};
}, [item.notebook.id, notebook.id, onItemUpdate]);
const itemPadding =
item.depth === 0 ? undefined : item.depth < 6 ? 15 * item.depth : 15 * 5;
return (
<View
style={{
paddingLeft:
item.depth === 0
? undefined
: item.depth < 6
? 15 * item.depth
: 15 * 5,
paddingLeft: itemPadding,
width: "100%",
marginTop: 2,
opacity: item.disabled ? 0.5 : 1
opacity: item.disabled ? 0.5 : 1,
paddingBottom: Spacing.LEVEL_0
}}
>
{item.depth > 0 ? (
<View
style={{
height: "100%",
width: 1,
backgroundColor: colors.primary.border,
top: 0,
bottom: 0,
position: "absolute",
left: itemPadding
}}
/>
) : null}
<Pressable
type={isFocused || selected ? "selected" : "transparent"}
onLongPress={onLongPress}
@@ -155,46 +167,38 @@ export const NotebookItem = ({
width: "100%",
alignItems: "center",
flexDirection: "row",
borderRadius: defaultBorderRadius,
paddingRight: DefaultAppStyles.GAP_SMALL
borderRadius: Radius.XS,
paddingVertical: Spacing.LEVEL_1,
paddingHorizontal: Spacing.LEVEL_1,
marginBottom:
expanded && item.hasChildren ? Spacing.LEVEL_0 : undefined
// borderLeftWidth: item.depth > 0 ? 1 : undefined,
// borderLeftColor: colors.primary.border
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center"
alignItems: "center",
gap: Spacing.LEVEL_1
}}
>
<IconButton
size={AppFontSize.md}
color={
selected || isFocused ? colors.selected.icon : colors.primary.icon
}
testID={item.hasChildren ? `expand-notebook-${index}` : ""}
onPress={() => {
if (item.hasChildren && !disableExpand) {
onToggleExpanded?.();
} else {
onPress?.();
{item.depth === 0 ? (
<AppIcon
size={AppFontSize.md}
color={
selected || isFocused
? colors.selected.icon
: colors.primary.icon
}
}}
top={0}
left={50}
bottom={0}
right={40}
style={{
width: 32,
height: 32,
borderRadius: defaultBorderRadius
}}
name={
!item.hasChildren || disableExpand
? "book-outline"
: expanded
? "chevron-down"
: "chevron-right"
}
/>
testID={item.hasChildren ? `expand-notebook-${index}` : ""}
style={{
borderRadius: defaultBorderRadius
}}
iconFamily="notesnook"
name={"bookmark"}
/>
) : null}
<Paragraph
color={
@@ -208,7 +212,7 @@ export const NotebookItem = ({
<View
style={{
gap: DefaultAppStyles.GAP_SMALL,
gap: Spacing.LEVEL_1,
flexDirection: "row",
alignItems: "center",
justifyContent: "center"
@@ -217,24 +221,20 @@ export const NotebookItem = ({
{selectionEnabled ? (
<View
style={{
width: 25,
height: 25,
justifyContent: "center",
alignItems: "center"
}}
>
<AppIcon
name={selected ? "checkbox-outline" : "checkbox-blank-outline"}
name={selected ? "checkbox" : "box-empty"}
iconFamily="notesnook"
size={AppFontSize.md}
color={selected ? colors.selected.icon : colors.primary.icon}
/>
</View>
) : (
<>
<Paragraph
size={AppFontSize.xxs}
color={colors.secondary.paragraph}
>
<Paragraph fontSize="SM" color={colors.secondary.paragraph}>
{totalNotes?.(notebook?.id) || 0}
</Paragraph>
</>
@@ -260,8 +260,81 @@ export const NotebookItem = ({
}}
/>
) : null}
{item.hasChildren ? (
<IconButton
size={12}
color={
selected || isFocused
? colors.selected.icon
: colors.primary.icon
}
testID={item.hasChildren ? `expand-notebook-${index}` : ""}
onPress={() => {
if (item.hasChildren && !disableExpand) {
onToggleExpanded?.();
}
}}
top={0}
left={20}
bottom={0}
right={20}
style={{
borderRadius: defaultBorderRadius,
width: undefined,
height: undefined
}}
iconFamily="notesnook"
name={expanded ? "chevron-up" : "chevron-down"}
/>
) : null}
</View>
</Pressable>
{expanded && item.hasChildren && !selectionEnabled ? (
<View
style={{
width: "100%",
paddingLeft: (item.depth + 1) * 15
}}
>
<View
style={{
height: "100%",
width: 1,
backgroundColor: colors.primary.border,
top: 0,
bottom: 0,
position: "absolute",
left: (item.depth + 1) * 15
}}
/>
<Pressable
style={{
// borderLeftWidth: 1,
// borderLeftColor: colors.primary.border,
flexDirection: "row",
gap: Spacing.LEVEL_1,
justifyContent: "flex-start",
paddingVertical: Spacing.LEVEL_1,
paddingHorizontal: Spacing.LEVEL_1,
alignItems: "center"
}}
onPress={() => {
AddNotebookSheet.present(undefined, item.notebook);
}}
>
<AppIcon
name="plus"
size={14}
style={{
marginTop: -2
}}
iconFamily="notesnook"
/>
<Heading fontSize="SM">Create sub-notebook</Heading>
</Pressable>{" "}
</View>
) : null}
</View>
);
};

View File

@@ -70,7 +70,7 @@ export const PinnedSection = React.memo(
menuPins.map((item) => ({
id: item.id,
title: item.title,
icon: item.type === "notebook" ? "notebook-outline" : "pound",
icon: item.type === "notebook" ? "bookmark" : "shopping-mode",
dataType: item.type,
data: item,
onPress: onPress,

View File

@@ -30,6 +30,7 @@ import { Pressable } from "../ui/pressable";
import { SvgView } from "../ui/svg";
import Heading from "../ui/typography/heading";
import { useSideBarDraggingStore } from "./dragging-store";
import { Radius, Spacing } from "../../common/design/spacing";
const SettingsIcon = () => {
const { colors } = useThemeColors();
@@ -77,31 +78,31 @@ export const SideMenuHeader = (props: { rightButtons?: IconButtonProps[] }) => {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
borderBottomWidth: 1,
borderBottomColor: colors.primary.border,
paddingBottom: DefaultAppStyles.GAP,
paddingHorizontal: DefaultAppStyles.GAP
}}
>
<View
style={{
flexDirection: "row",
gap: DefaultAppStyles.GAP_SMALL,
gap: Spacing.LEVEL_1,
alignItems: "center"
}}
>
<View
style={{
backgroundColor: "black",
width: 28,
height: 28,
borderRadius: 10
width: 26,
height: 26,
borderRadius: Radius.XS,
overflow: "hidden"
}}
>
<SvgView width={28} height={28} src={NOTESNOOK_LOGO_SVG} />
<SvgView width={26} height={26} src={NOTESNOOK_LOGO_SVG} />
</View>
<Heading size={AppFontSize.lg}>Notesnook</Heading>
<Heading lineHeight="120%" fontSize="XL">
Notesnook
</Heading>
</View>
<View

View File

@@ -38,6 +38,7 @@ import { ColorSection } from "./color-section";
import { MenuItem } from "./menu-item";
import { PinnedSection } from "./pinned-section";
import { SideMenuHeader } from "./side-menu-header";
import { Spacing } from "../../common/design/spacing";
const pro = {
title: strings.upgradePlan(),
@@ -71,8 +72,7 @@ export function SideMenuHome() {
height: "100%",
width: "100%",
backgroundColor: colors.primary.background,
gap: DefaultAppStyles.GAP,
paddingTop: DefaultAppStyles.GAP_VERTICAL
paddingTop: Spacing.LEVEL_1
}}
>
<SideMenuHeader />
@@ -129,7 +129,8 @@ export function SideMenuHome() {
</>
)}
style={{
paddingHorizontal: DefaultAppStyles.GAP
paddingHorizontal: DefaultAppStyles.GAP,
marginTop: Spacing.LEVEL_3
}}
nestedScrollEnabled={false}
/>

View File

@@ -23,9 +23,15 @@ import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import Paragraph from "../ui/typography/paragraph";
import { SideMenuHeader } from "./side-menu-header";
import Heading from "../ui/typography/heading";
import { Spacing } from "../../common/design/spacing";
import { Button } from "../ui/button";
type SideMenuListEmptyProps = {
placeholder: string;
placeholderTitle: string;
placeholderBody: string;
placeholderButtonTitle: string;
onPressPlaceholderButton: () => void;
isLoading?: boolean;
};
@@ -76,9 +82,39 @@ export const SideMenuListEmpty = (props: SideMenuListEmptyProps) => {
))}
</View>
) : (
<Paragraph size={AppFontSize.xs} color={colors.secondary.paragraph}>
{props.placeholder}
</Paragraph>
<View
style={{
alignItems: "center",
gap: Spacing.LEVEL_1
}}
>
<Heading size={AppFontSize.md} color={colors.secondary.paragraph}>
{props.placeholderTitle}
</Heading>
<Paragraph
style={{
textAlign: "center",
maxWidth: "60%"
}}
fontSize="SM"
color={colors.secondary.paragraph}
>
{props.placeholderBody}
</Paragraph>
<Button
title={props.placeholderButtonTitle}
onPress={props.onPressPlaceholderButton}
fontSize={AppFontSize.sm}
style={{
marginTop: Spacing.LEVEL_2,
paddingVertical: Spacing.LEVEL_2,
paddingHorizontal: Spacing.LEVEL_2
}}
type="accent-outline"
icon="plus"
/>
</View>
)}
</View>
</View>

View File

@@ -41,6 +41,9 @@ import {
} from "./stores";
import { LegendList } from "@legendapp/list";
import { useRelationStore } from "../../stores/use-relation-store";
import { AddNotebookSheet } from "../sheets/add-notebook";
import { Spacing } from "../../common/design/spacing";
import AppIcon from "../ui/AppIcon";
useSideMenuNotebookSelectionStore.setState({
multiSelect: true
});
@@ -53,7 +56,7 @@ export const SideMenuNotebooks = () => {
const [filteredNotebooks, setFilteredNotebooks] = React.useState(notebooks);
const searchTimer = React.useRef<NodeJS.Timeout>(undefined);
const lastQuery = React.useRef<string>(undefined);
const updater = useRelationStore(state => state.updater);
const updater = useRelationStore((state) => state.updater);
const loadRootNotebooks = React.useCallback(async () => {
if (!filteredNotebooks) return;
const _notebooks: Notebook[] = [];
@@ -81,7 +84,7 @@ export const SideMenuNotebooks = () => {
useEffect(() => {
updateNotebooks();
}, [updateNotebooks,updater]);
}, [updateNotebooks, updater]);
useEffect(() => {
(async () => {
@@ -136,7 +139,12 @@ export const SideMenuNotebooks = () => {
>
{!notebooks || notebooks.placeholders.length === 0 ? (
<SideMenuListEmpty
placeholder={strings.emptyPlaceholders("notebook")}
placeholderTitle={strings.noNotebooksYet()}
placeholderBody={strings.notebooksEmptyBody()}
placeholderButtonTitle={strings.createNotebook()}
onPressPlaceholderButton={() => {
AddNotebookSheet.present();
}}
isLoading={isLoading}
/>
) : (
@@ -151,7 +159,8 @@ export const SideMenuNotebooks = () => {
<View
style={{
backgroundColor: colors.primary.background,
paddingTop: DefaultAppStyles.GAP_VERTICAL
paddingTop: Spacing.LEVEL_1,
paddingBottom: Spacing.LEVEL_3
}}
>
<SideMenuHeader />
@@ -159,34 +168,44 @@ export const SideMenuNotebooks = () => {
}
renderItem={renderItem}
/>
<View
style={{
width: "100%",
paddingHorizontal: DefaultAppStyles.GAP,
backgroundColor: colors.primary.background,
borderTopColor: colors.primary.border,
borderTopWidth: 1,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
paddingHorizontal: Spacing.LEVEL_3
}}
>
<TextInput
placeholder="Filter notebooks..."
<View
style={{
fontFamily: "Inter-Regular",
fontSize: AppFontSize.xs,
paddingTop: 0,
paddingBottom: 0
width: "100%",
backgroundColor: colors.primary.background,
borderTopColor: colors.primary.border,
borderTopWidth: 1,
paddingVertical: DefaultAppStyles.GAP_VERTICAL,
flexDirection: "row",
justifyContent: "space-between"
}}
cursorColor={colors.primary.accent}
onChangeText={async (value: string) => {
searchTimer.current && clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(async () => {
lastQuery.current = value;
updateNotebooks();
}, 500);
}}
placeholderTextColor={colors.primary.placeholder}
/>
>
<TextInput
placeholder={strings.filterNotebooks()}
style={{
fontFamily: "Inter-Regular",
fontSize: AppFontSize.xs,
paddingTop: 0,
paddingBottom: 0
}}
cursorColor={colors.primary.accent}
onChangeText={async (value: string) => {
searchTimer.current && clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(async () => {
lastQuery.current = value;
updateNotebooks();
}, 500);
}}
placeholderTextColor={colors.primary.placeholder}
/>
<AppIcon name="funnel" size={14} iconFamily="notesnook" />
</View>
</View>
</>
)}
@@ -235,8 +254,7 @@ const NotebookItemWrapper = React.memo(
return (
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP,
marginTop: index === 0 ? DefaultAppStyles.GAP_VERTICAL : 0
paddingHorizontal: Spacing.LEVEL_3
}}
>
<NotebookItem

View File

@@ -25,10 +25,12 @@ import { TextInput, View } from "react-native";
import { DatabaseLogger, db } from "../../common/database";
import { useDBItem, useTotalNotes } from "../../hooks/use-db-item";
import { TaggedNotes } from "../../screens/notes/tagged";
import { presentDialog } from "../dialog/functions";
import Navigation from "../../services/navigation";
import { ToastManager } from "../../services/event-manager";
import useNavigationStore from "../../stores/use-navigation-store";
import { useTags } from "../../stores/use-tag-store";
import { AppFontSize, defaultBorderRadius } from "../../utils/size";
import { useTags, useTagStore } from "../../stores/use-tag-store";
import { AppFontSize } from "../../utils/size";
import { DefaultAppStyles } from "../../utils/styles";
import { Properties } from "../properties";
import AppIcon from "../ui/AppIcon";
@@ -39,6 +41,7 @@ import { SideMenuListEmpty } from "./side-menu-list-empty";
import { useSideMenuTagsSelectionStore } from "./stores";
import { LegendList, LegendListRenderItemProps } from "@legendapp/list";
import { useRelationStore } from "../../stores/use-relation-store";
import { Radius, Spacing } from "../../common/design/spacing";
const TagItem = (props: {
tags: VirtualizedGrouping<Tag>;
@@ -56,7 +59,7 @@ const TagItem = (props: {
const totalNotes = useTotalNotes("tag");
const totalNotesRef = React.useRef(totalNotes);
totalNotesRef.current = totalNotes;
const updater = useRelationStore(state => state.updater);
const updater = useRelationStore((state) => state.updater);
useEffect(() => {
if (item?.id) {
@@ -67,9 +70,8 @@ const TagItem = (props: {
return (
<View
style={{
paddingHorizontal: DefaultAppStyles.GAP,
marginTop:
(props.id as number) === 0 ? DefaultAppStyles.GAP_VERTICAL : 2
paddingHorizontal: Spacing.LEVEL_3,
marginBottom: Spacing.LEVEL_0
}}
>
{item ? (
@@ -116,30 +118,23 @@ const TagItem = (props: {
width: "100%",
alignItems: "center",
flexDirection: "row",
borderRadius: defaultBorderRadius,
paddingRight: DefaultAppStyles.GAP_SMALL
borderRadius: Radius.XS,
padding: Spacing.LEVEL_1
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center"
alignItems: "center",
gap: Spacing.LEVEL_1
}}
>
<View
style={{
width: 32,
height: 32,
justifyContent: "center",
alignItems: "center"
}}
>
<AppIcon
size={AppFontSize.md}
color={isFocused ? colors.selected.icon : colors.primary.icon}
name="pound"
/>
</View>
<AppIcon
size={16}
color={isFocused ? colors.selected.icon : colors.primary.icon}
name="shopping-mode"
iconFamily="notesnook"
/>
<Paragraph
color={
@@ -169,9 +164,9 @@ const TagItem = (props: {
</View>
) : (
<>
{item?.id && totalNotes.totalNotes?.(item?.id) ? (
{item?.id && totalNotes.totalNotes?.(item?.id) !== undefined ? (
<Paragraph
size={AppFontSize.xxs}
size={AppFontSize.sm}
color={colors.secondary.paragraph}
>
{totalNotes.totalNotes(item?.id)}
@@ -232,6 +227,32 @@ export const SideMenuTags = () => {
setLoading(false);
}, [tags]);
const onPressAddTag = React.useCallback(() => {
presentDialog({
title: strings.addTag(),
// paragraph: strings.addTagDesc(),
input: true,
inputLabel: "Enter title",
inputPlaceholder: "eg. journal",
positiveText: strings.add(),
positivePress: async (tag) => {
if (tag) {
await db.tags.add({
title: tag
});
useTagStore.getState().refresh();
return true;
}
ToastManager.show({
context: "local",
type: "error",
message: strings.allFieldsRequired()
});
return false;
}
});
}, []);
useEffect(() => {
if (!isLoading) {
updateTags();
@@ -253,7 +274,10 @@ export const SideMenuTags = () => {
>
{!tags || tags?.placeholders.length === 0 ? (
<SideMenuListEmpty
placeholder={strings.emptyPlaceholders("tag")}
placeholderTitle={strings.noTagsYet()}
placeholderBody={strings.tagsEmptyBody()}
placeholderButtonTitle={strings.addTag()}
onPressPlaceholderButton={onPressAddTag}
isLoading={loading}
/>
) : (
@@ -269,7 +293,8 @@ export const SideMenuTags = () => {
<View
style={{
backgroundColor: colors.primary.background,
paddingTop: DefaultAppStyles.GAP_VERTICAL
paddingTop: Spacing.LEVEL_1,
paddingBottom: Spacing.LEVEL_3
}}
>
<SideMenuHeader />
@@ -279,36 +304,45 @@ export const SideMenuTags = () => {
/>
<View
style={{
width: "100%",
paddingHorizontal: DefaultAppStyles.GAP,
backgroundColor: colors.primary.background,
borderTopColor: colors.primary.border,
borderTopWidth: 1,
paddingVertical: DefaultAppStyles.GAP_VERTICAL
paddingHorizontal: Spacing.LEVEL_3
}}
>
<TextInput
placeholder="Filter tags..."
<View
style={{
fontFamily: "Inter-Regular",
fontSize: AppFontSize.xs,
paddingTop: 0,
paddingBottom: 0
width: "100%",
backgroundColor: colors.primary.background,
borderTopColor: colors.primary.border,
borderTopWidth: 1,
paddingVertical: DefaultAppStyles.GAP_VERTICAL,
flexDirection: "row",
justifyContent: "space-between"
}}
cursorColor={colors.primary.accent}
onChangeText={async (value) => {
searchTimer.current && clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(async () => {
try {
lastQuery.current = value;
updateTags();
} catch (e) {
DatabaseLogger.error(e);
}
}, 100);
}}
placeholderTextColor={colors.primary.placeholder}
/>
>
<TextInput
placeholder={strings.filterTags()}
style={{
fontFamily: "Inter-Regular",
fontSize: AppFontSize.xs,
paddingTop: 0,
paddingBottom: 0
}}
cursorColor={colors.primary.accent}
onChangeText={async (value) => {
searchTimer.current && clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(async () => {
try {
lastQuery.current = value;
updateTags();
} catch (e) {
DatabaseLogger.error(e);
}
}, 100);
}}
placeholderTextColor={colors.primary.placeholder}
/>
<AppIcon name="funnel" size={14} iconFamily="notesnook" />
</View>
</View>
</>
)}

View File

@@ -0,0 +1,111 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Pressable } from "../ui/pressable";
import Paragraph from "../ui/typography/paragraph";
import Animated, {
useAnimatedStyle,
useSharedValue,
withSpring
} from "react-native-reanimated";
import { Radius, Spacing } from "../../common/design/spacing";
import AppIcon from "../ui/AppIcon";
type TabBarButtonProps = {
icon: string;
label?: string;
onPress: () => void;
isActive?: boolean;
testID?: string;
};
export const TabBarButton = ({
icon,
label,
onPress,
isActive = false,
testID
}: TabBarButtonProps) => {
const { colors } = useThemeColors();
const scale = useSharedValue(1);
const animatedIconStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }]
}));
const handlePress = () => {
scale.value = withSpring(0.85, {
damping: 100,
mass: 1,
overshootClamping: false
});
setTimeout(() => {
scale.value = withSpring(1, {
damping: 100,
mass: 1,
overshootClamping: false
});
}, 100);
onPress();
};
return (
<Pressable
testID={testID}
onPress={handlePress}
style={{
borderRadius: 10,
paddingVertical: 2,
width: undefined,
gap: label ? Spacing.LEVEL_1 : 0,
backgroundColor: "transparent",
borderWidth: 0
}}
type={"plain"}
>
<Animated.View
style={[
{
backgroundColor: isActive ? colors.primary.shade : undefined,
borderRadius: Radius.XS,
padding: Spacing.LEVEL_1
},
animatedIconStyle
]}
>
<AppIcon
name={icon}
iconFamily="notesnook"
color={isActive ? colors.selected.icon : colors.primary.icon}
size={16}
/>
</Animated.View>
{label && (
<Paragraph fontFamily={isActive ? "MEDIUM" : "REGULAR"} fontSize={"XS"}>
{label}
</Paragraph>
)}
</Pressable>
);
};

View File

@@ -22,6 +22,10 @@ import { ColorValue, TextProps } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import EvilIcon from "react-native-vector-icons/EvilIcons";
import { AppFontSize } from "../../../utils/size";
import { createNanoIconSet } from "react-native-nano-icons";
import glyphMap from "../../../../fonts/notesnook-icons.glyphmap.json";
const NotesnookIcon = createNanoIconSet(glyphMap);
export interface IconProps extends TextProps {
/**
@@ -43,9 +47,9 @@ export interface IconProps extends TextProps {
* Color of the icon
*
*/
color?: ColorValue | number | undefined;
color?: ColorValue | ColorValue[] | number | undefined;
iconFamily?: "evilicons" | "material";
iconFamily?: "evilicons" | "material" | "notesnook";
}
export default function AppIcon({
@@ -59,6 +63,12 @@ export default function AppIcon({
color={colors.primary.icon}
{...(props as any)}
/>
) : iconFamily === "notesnook" ? (
<NotesnookIcon
size={AppFontSize.md}
color={colors.primary.icon}
{...(props as any)}
/>
) : (
<Icon
size={AppFontSize.md}

View File

@@ -26,13 +26,15 @@ import {
ViewStyle,
useWindowDimensions
} from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { AppFontSize, defaultBorderRadius } from "../../../utils/size";
import { DefaultAppStyles } from "../../../utils/styles";
import NativeTooltip from "../../../utils/tooltip";
import { Pressable, PressableProps, useButton } from "../pressable";
import Heading from "../typography/heading";
import Paragraph from "../typography/paragraph";
import { Spacing } from "../../../common/design/spacing";
import { FontFamily } from "../../../common/design/font";
import AppIcon, { IconProps } from "../AppIcon";
export interface ButtonProps extends PressableProps {
height?: number;
icon?: string;
@@ -44,6 +46,7 @@ export interface ButtonProps extends PressableProps {
title?: string | null;
loading?: boolean;
width?: string | number | null;
fontFamily?: keyof typeof FontFamily;
buttonType?: {
text?: ColorValue;
selected?: ColorValue;
@@ -54,6 +57,7 @@ export interface ButtonProps extends PressableProps {
bold?: boolean;
iconColor?: ColorValue;
iconStyle?: TextStyle;
iconFamily?: IconProps["iconFamily"];
proTag?: boolean;
allowFontScaling?: boolean;
}
@@ -64,7 +68,8 @@ export const Button = ({
loading = false,
title = null,
icon,
fontSize = AppFontSize.sm,
fontFamily = "SEMI_BOLD",
fontSize = AppFontSize.md,
type = "transparent",
iconSize = AppFontSize.md,
style = {},
@@ -75,11 +80,12 @@ export const Button = ({
textStyle,
iconPosition = "left",
buttonType,
bold,
bold = true,
iconColor,
fwdRef,
proTag,
iconStyle,
iconFamily,
allowFontScaling = true,
...restProps
}: ButtonProps) => {
@@ -138,8 +144,9 @@ export const Button = ({
<ActivityIndicator color={textColor} size={fontSize + 4} />
) : null}
{icon && !loading && iconPosition === "left" ? (
<Icon
<AppIcon
name={icon}
iconFamily={iconFamily}
allowFontScaling={allowFontScaling}
style={[{ marginRight: 0 }, iconStyle as any]}
color={iconColor || buttonType?.text || textColor}
@@ -152,11 +159,18 @@ export const Button = ({
color={textColor as string}
size={fontSize}
numberOfLines={1}
fontFamily={fontFamily}
allowFontScaling={allowFontScaling}
style={[
{
marginLeft: icon || (loading && iconPosition === "left") ? 5 : 0,
marginRight: icon || (loading && iconPosition === "right") ? 5 : 0
marginLeft:
icon || (loading && iconPosition === "left")
? Spacing.LEVEL_1
: 0,
marginRight:
icon || (loading && iconPosition === "right")
? Spacing.LEVEL_1
: 0
},
textStyle
]}
@@ -166,10 +180,11 @@ export const Button = ({
)}
{icon && !loading && iconPosition === "right" ? (
<Icon
<AppIcon
name={icon}
iconFamily={iconFamily}
allowFontScaling
style={[{ marginLeft: 0 }, iconStyle as any]}
style={[iconStyle as any]}
color={iconColor || buttonType?.text || textColor}
size={iconSize}
/>

View File

@@ -25,10 +25,10 @@ import {
TextStyle,
useWindowDimensions
} from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { hexToRGBA, RGB_Linear_Shade } from "../../../utils/colors";
import { AppFontSize } from "../../../utils/size";
import NativeTooltip from "../../../utils/tooltip";
import AppIcon, { IconProps } from "../AppIcon";
import { Pressable, PressableProps } from "../pressable";
export interface IconButtonProps extends PressableProps {
name: string;
@@ -42,6 +42,8 @@ export interface IconButtonProps extends PressableProps {
tooltipText?: string;
tooltipPosition?: number;
iconStyle?: TextStyle;
iconProps?: IconProps;
iconFamily?: IconProps["iconFamily"];
}
export const IconButton = ({
@@ -59,7 +61,9 @@ export const IconButton = ({
tooltipText,
type = "plain",
fwdRef,
iconProps,
tooltipPosition = NativeTooltip.POSITIONS.TOP,
iconFamily,
...restProps
}: IconButtonProps) => {
const { colors } = useThemeColors();
@@ -100,8 +104,10 @@ export const IconButton = ({
...style
}}
>
<Icon
<AppIcon
{...iconProps}
name={name}
iconFamily={iconFamily}
style={iconStyle as any}
allowFontScaling
color={

View File

@@ -17,9 +17,12 @@ 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 React, { RefObject, useState } from "react";
import { useThemeColors } from "@notesnook/theme";
import phone from "phone";
import React, { RefObject, useRef, useState } from "react";
import {
ColorValue,
findNodeHandle,
NativeSyntheticEvent,
TextInput,
TextInputProps,
@@ -28,21 +31,17 @@ import {
View,
ViewStyle
} from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import isURL from "validator/lib/isURL";
import { Spacing } from "../../../common/design/spacing";
import {
ERRORS_LIST,
validateEmail,
validatePass,
validateUsername
} from "../../../services/validation";
import { useThemeColors } from "@notesnook/theme";
import { getElevationStyle } from "../../../utils/elevation";
import { defaultBorderRadius, AppFontSize } from "../../../utils/size";
import { AppFontSize, defaultBorderRadius } from "../../../utils/size";
import { IconButton } from "../icon-button";
import Paragraph from "../typography/paragraph";
import phone from "phone";
import isURL from "validator/lib/isURL";
import { DefaultAppStyles } from "../../../utils/styles";
import { useInputError } from "./input-error-context";
interface InputProps extends TextInputProps {
fwdRef?: RefObject<TextInput | null>;
@@ -80,6 +79,7 @@ interface InputProps extends TextInputProps {
containerStyle?: ViewStyle;
wrapperStyle?: ViewStyle;
flexGrow?: number;
label?: string;
}
const Input = ({
@@ -93,7 +93,7 @@ const Input = ({
secureTextEntry,
customColor,
customValidator,
marginBottom = 10,
marginBottom = 0,
button,
onBlurInput,
onPress,
@@ -103,6 +103,7 @@ const Input = ({
buttons,
marginRight,
buttonLeft,
label,
flexGrow = 1,
inputStyle = {},
containerStyle = {},
@@ -110,6 +111,9 @@ const Input = ({
...restProps
}: InputProps) => {
const { colors, isDark } = useThemeColors();
const errorCtx = useInputError();
const internalRef = useRef<TextInput>(null);
const activeRef = fwdRef ?? internalRef;
const [error, setError] = useState(false);
const [focus, setFocus] = useState(false);
const [secureEntry, setSecureEntry] = useState(true);
@@ -118,11 +122,17 @@ const Input = ({
SHORT_PASS: false
});
type ErrorKey = keyof typeof errorList;
const reportError = (message: string | null) => {
if (!errorCtx) return;
const nativeId = findNodeHandle(activeRef.current);
if (nativeId !== null) errorCtx.setError(nativeId, message);
};
const color = error
? colors.error.border
: focus
? customColor || colors.selected.border
: colors.primary.border;
? customColor || colors.selected.border
: colors.primary.border;
const validate = async (value: string) => {
if (!validationType) return;
@@ -134,34 +144,30 @@ const Input = ({
});
return;
}
let isError:
| boolean
| string
| { SHORT_PASS?: boolean; isValid?: boolean }
| undefined = undefined;
let isValid: boolean | string | undefined = undefined;
switch (validationType) {
case "password":
isError = validatePass(value);
isValid = validatePass(value);
break;
case "email":
isError = validateEmail(value);
isValid = validateEmail(value);
break;
case "username":
isError = validateUsername(value);
isValid = validateUsername(value);
break;
case "confirmPassword":
isError = customValidator && value === customValidator();
isValid = customValidator && value === customValidator();
break;
case "url":
isError = isURL(value, { allow_underscores: true });
isValid = isURL(value, { allow_underscores: true });
break;
case "phonenumber": {
const result = phone(value, {
strictDetection: true,
validateMobilePrefix: true
});
isError = result.isValid;
isValid = result.isValid;
if (result.isValid) {
onChangeText && onChangeText(result.phoneNumber);
}
@@ -170,23 +176,10 @@ const Input = ({
}
}
if (validationType === "password") {
let hasError = false;
const errors = isError as { [name: string]: boolean };
Object.keys(errors).forEach((e) => {
//ts-ignore
if (errors[e] === true) {
hasError = true;
}
});
setError(hasError);
onErrorCheck && onErrorCheck(hasError);
setErrorList(errors as { SHORT_PASS: boolean });
} else {
setError(!isError);
onErrorCheck && onErrorCheck(!isError);
}
const hasError = !isValid;
setError(hasError);
onErrorCheck && onErrorCheck(hasError);
reportError(hasError ? (errorMessage ?? null) : null);
};
const onChange = (value: string) => {
@@ -198,6 +191,7 @@ const Input = ({
setErrorList({
SHORT_PASS: false
});
reportError(null);
}
};
@@ -218,15 +212,15 @@ const Input = ({
const style: ViewStyle = {
borderWidth: 1,
borderRadius: defaultBorderRadius,
borderColor: color,
borderColor: error ? colors.static.red : color,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingHorizontal: DefaultAppStyles.GAP,
paddingHorizontal: Spacing.LEVEL_2,
paddingRight:
buttons || button || secureTextEntry || error
? DefaultAppStyles.GAP
: DefaultAppStyles.GAP,
? Spacing.LEVEL_3
: Spacing.LEVEL_3,
...containerStyle
};
@@ -235,10 +229,10 @@ const Input = ({
fontSize: fontSize,
color:
onPress && loading ? colors.primary.accent : colors.primary.paragraph,
paddingTop: Spacing.LEVEL_3,
paddingBottom: Spacing.LEVEL_3,
flexGrow: 1,
flexShrink: 1,
paddingBottom: DefaultAppStyles.GAP_VERTICAL,
paddingTop: DefaultAppStyles.GAP_VERTICAL,
fontFamily: "Inter-Regular",
...(inputStyle as ViewStyle)
};
@@ -253,6 +247,17 @@ const Input = ({
...wrapperStyle
}}
>
{label ? (
<Paragraph
style={{
marginBottom: Spacing.LEVEL_1
}}
color={colors.primary.paragraph}
fontSize="XS"
>
{label}
</Paragraph>
) : undefined}
<TouchableOpacity
disabled={!loading}
onPress={onPress}
@@ -263,7 +268,8 @@ const Input = ({
<TextInput
{...restProps}
ref={fwdRef}
ref={activeRef}
onLayout={restProps.onLayout}
editable={!loading && restProps.editable}
onChangeText={onChange}
onBlur={onBlur}
@@ -326,87 +332,9 @@ const Input = ({
}}
/>
)}
{error && (
<IconButton
name="alert-circle-outline"
top={10}
bottom={10}
onPress={() => {
setShowError(!showError);
}}
size={20}
style={{
width: 25,
marginLeft: 5
}}
color={colors.error.icon}
/>
)}
</View>
{error && showError && errorMessage ? (
<View
style={{
position: "absolute",
backgroundColor: colors.secondary.background,
paddingVertical: 3,
paddingHorizontal: DefaultAppStyles.GAP_SMALL / 2,
borderRadius: 2.5,
...getElevationStyle(2),
top: 0
}}
>
<Paragraph
size={AppFontSize.xs}
style={{
textAlign: "right",
textAlignVertical: "bottom"
}}
>
<Icon
name="alert-circle-outline"
size={AppFontSize.xs}
color={colors.error.icon}
/>{" "}
{errorMessage}
</Paragraph>
</View>
) : null}
</TouchableOpacity>
</View>
{validationType === "password" && focus && (
<View
style={{
marginTop: -5,
marginBottom: 5
}}
>
{Object.keys(errorList).filter(
(k) => errorList[k as ErrorKey] === true
).length !== 0
? Object.keys(ERRORS_LIST).map((error) => (
<View
key={ERRORS_LIST[error as ErrorKey]}
style={{
flexDirection: "row",
alignItems: "center"
}}
>
<Icon
name={errorList[error as ErrorKey] ? "close" : "check"}
color={errorList[error as ErrorKey] ? "red" : "green"}
/>
<Paragraph style={{ marginLeft: 5 }} size={AppFontSize.xs}>
{ERRORS_LIST[error as ErrorKey]}
</Paragraph>
</View>
))
: null}
</View>
)}
</>
);
};

View File

@@ -0,0 +1,120 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 React, {
createContext,
RefObject,
useCallback,
useContext,
useMemo,
useRef,
useState
} from "react";
import { findNodeHandle, TextInput, View } from "react-native";
import Paragraph from "../typography/paragraph";
import { useThemeColors } from "@notesnook/theme";
import { Spacing } from "../../../common/design/spacing";
import AppIcon from "../AppIcon";
interface InputErrorContextType {
setError: (nativeId: number, message: string | null) => void;
getError: (nativeId: number) => string | null;
}
const InputErrorContext = createContext<InputErrorContextType | null>(null);
export function InputErrorProvider({
children
}: {
children: React.ReactNode;
}) {
const [errors, setErrors] = useState<Map<number, string | null>>(new Map());
const setError = useCallback((nativeId: number, message: string | null) => {
setErrors((prev) => {
const next = new Map(prev);
if (message === null) {
next.delete(nativeId);
} else {
next.set(nativeId, message);
}
return next;
});
}, []);
const getError = useCallback(
(nativeId: number) => errors.get(nativeId) ?? null,
[errors]
);
const value = useMemo(() => ({ setError, getError }), [setError, getError]);
return (
<InputErrorContext.Provider value={value}>
{children}
</InputErrorContext.Provider>
);
}
export function useInputError() {
return useContext(InputErrorContext);
}
interface ErrorContainerProps {
inputRef: RefObject<TextInput | null>;
}
export function ErrorContainer({ inputRef }: ErrorContainerProps) {
const ctx = useInputError();
const { colors } = useThemeColors();
const nativeIdRef = useRef<number | null>(null);
if (!ctx) return null;
// Resolve the native ID lazily — the ref's current may not be set on first
// render but will be by the time the input mounts and registers an error.
const nativeId =
nativeIdRef.current ??
(inputRef.current
? (nativeIdRef.current = findNodeHandle(inputRef.current))
: null);
const message = nativeId !== null ? ctx.getError(nativeId) : null;
if (!message) return null;
return (
<View
style={{
flexDirection: "row",
gap: Spacing.LEVEL_1
}}
>
<AppIcon
name="warning-circle"
color={colors.static.red}
iconFamily="notesnook"
size={16}
/>
<Paragraph color={colors.static.red} fontSize="SM">
{message}
</Paragraph>
</View>
);
}

View File

@@ -0,0 +1,340 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 { useThemeColors } from "@notesnook/theme";
import Clipboard from "@react-native-clipboard/clipboard";
import React, { RefObject, useEffect, useMemo, useRef, useState } from "react";
import {
AppState,
AppStateStatus,
KeyboardTypeOptions,
TextInput,
TextInputKeyPressEvent,
TextInputProps,
TouchableOpacity,
View
} from "react-native";
import { Radius, Spacing } from "../../../common/design/spacing";
import { AppFontSize } from "../../../utils/size";
type PinInputProps = {
value: string;
length: number;
testID?: string;
autoFocus?: boolean;
inputRef?: RefObject<TextInput | null>;
keyboardType?: KeyboardTypeOptions;
onSubmitEditing?: TextInputProps["onSubmitEditing"];
onChangeText: (value: string) => void;
sanitize?: (value: string) => string;
};
const defaultSanitizer = (value: string) => value;
const PinInput = ({
value,
length,
testID,
autoFocus,
inputRef,
keyboardType = "number-pad",
onSubmitEditing,
onChangeText,
sanitize = defaultSanitizer
}: PinInputProps) => {
const { colors } = useThemeColors();
const inputRefs = useRef<Array<TextInput | null>>([]);
const appStateRef = useRef<AppStateStatus>(AppState.currentState);
const lastAutoFilledValue = useRef<string>("");
const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
const normalizeToCells = useMemo(
() => (raw: string) => {
const sanitized = sanitize(raw).slice(0, length);
const next = Array.from({ length }, () => "");
sanitized.split("").forEach((char, index) => {
next[index] = char;
});
return next;
},
[length, sanitize]
);
const [cells, setCells] = useState<string[]>(() => normalizeToCells(value));
const emitChange = React.useCallback(
(nextCells: string[]) => {
onChangeText(nextCells.join(""));
},
[onChangeText]
);
const focusCell = React.useCallback(
(index: number) => {
const clampedIndex = Math.max(0, Math.min(index, length - 1));
requestAnimationFrame(() => {
inputRefs.current[clampedIndex]?.focus();
});
},
[length]
);
useEffect(() => {
if (autoFocus) {
focusCell(0);
}
}, [autoFocus, focusCell]);
useEffect(() => {
// Parent-driven resets should clear all slots.
if (!value) {
setCells(Array.from({ length }, () => ""));
return;
}
// Parent-driven complete values (OTP autofill, test paste) should sync.
if (value.length >= length) {
setCells(normalizeToCells(value));
}
}, [length, normalizeToCells, value]);
const onCellChange = (index: number, text: string) => {
const sanitized = sanitize(text);
const nextCells = [...cells];
if (!sanitized) {
nextCells[index] = "";
setCells(nextCells);
emitChange(nextCells);
return;
}
const chars = sanitized.split("");
let cursor = index;
chars.forEach((char) => {
if (cursor < length) {
nextCells[cursor] = char;
cursor += 1;
}
});
setCells(nextCells);
emitChange(nextCells);
if (cursor < length) {
focusCell(cursor);
} else {
inputRefs.current[length - 1]?.blur();
}
};
const onCellKeyPress = (index: number, event: TextInputKeyPressEvent) => {
if (event.nativeEvent.key !== "Backspace") return;
const nextCells = [...cells];
if (nextCells[index]) {
nextCells[index] = "";
setCells(nextCells);
emitChange(nextCells);
return;
}
if (index > 0) {
nextCells[index - 1] = "";
setCells(nextCells);
emitChange(nextCells);
focusCell(index - 1);
}
};
const onBulkInputChange = (text: string) => {
const sanitized = sanitize(text).slice(0, length);
const nextCells = normalizeToCells(sanitized);
setCells(nextCells);
emitChange(nextCells);
if (sanitized.length < length) {
focusCell(sanitized.length);
}
};
const applyClipboardCode = React.useCallback(
(clipboardText: string) => {
const sanitized = sanitize(clipboardText).slice(0, length);
if (sanitized.length !== length) return;
const currentJoined = cells.join("");
if (
currentJoined === sanitized ||
lastAutoFilledValue.current === sanitized
) {
return;
}
const nextCells = normalizeToCells(sanitized);
setCells(nextCells);
emitChange(nextCells);
lastAutoFilledValue.current = sanitized;
inputRefs.current[length - 1]?.blur();
},
[cells, emitChange, length, normalizeToCells, sanitize]
);
useEffect(() => {
const readClipboardAndApply = async () => {
try {
const clipboardText = await Clipboard.getString();
if (!clipboardText) return;
// Prefer not to override a fully entered code while user is interacting.
if (cells.join("").length >= length) return;
applyClipboardCode(clipboardText);
} catch {
// Ignore clipboard access failures.
}
};
const subscription = AppState.addEventListener("change", (nextState) => {
const wasInBackground =
appStateRef.current === "background" ||
appStateRef.current === "inactive";
if (wasInBackground && nextState === "active") {
void readClipboardAndApply();
}
appStateRef.current = nextState;
});
return () => {
subscription.remove();
};
}, [cells, length, normalizeToCells, sanitize, applyClipboardCode]);
return (
<View
style={{
width: "100%"
}}
>
<View
style={{
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
flexWrap: "nowrap",
rowGap: Spacing.LEVEL_1,
columnGap: Spacing.LEVEL_1,
borderWidth: 1,
borderColor: colors.primary.border,
borderRadius: Radius.S,
paddingVertical: Spacing.LEVEL_3,
paddingHorizontal: Spacing.LEVEL_2
}}
>
{cells.map((char, index) => {
const isActive = focusedIndex === index;
return (
<TouchableOpacity
key={`${index}`}
activeOpacity={0.9}
onPress={() => focusCell(index)}
>
<View
style={{
width: 16,
height: 16,
borderBottomWidth: 2,
borderBottomColor: isActive
? colors.selected.accent
: colors.primary.shade,
justifyContent: "center",
alignItems: "center"
}}
>
<TextInput
ref={(ref) => {
inputRefs.current[index] = ref;
if (index === 0 && inputRef) {
inputRef.current = ref;
}
}}
disableFullscreenUI={true}
value={char}
maxLength={1}
keyboardType={keyboardType}
onChangeText={(text) => onCellChange(index, text)}
onKeyPress={(event) => onCellKeyPress(index, event)}
onFocus={() => setFocusedIndex(index)}
onBlur={() => {
setFocusedIndex((current) =>
current === index ? null : current
);
}}
autoCorrect={false}
autoComplete="off"
textContentType="oneTimeCode"
inputMode="numeric"
importantForAutofill="yes"
selectionColor={colors.selected.accent}
style={{
width: "100%",
height: "100%",
textAlign: "center",
fontSize: AppFontSize.sm,
color: colors.primary.paragraph,
padding: 0,
margin: 0
}}
onSubmitEditing={onSubmitEditing}
blurOnSubmit={index === length - 1}
returnKeyType={index === length - 1 ? "done" : "next"}
/>
</View>
</TouchableOpacity>
);
})}
</View>
{/* Hidden aggregate input for full-code paste/autofill and test compatibility. */}
<TextInput
testID={testID}
value={cells.join("")}
keyboardType={keyboardType}
onChangeText={onBulkInputChange}
maxLength={length}
autoCorrect={false}
autoComplete="off"
textContentType="oneTimeCode"
importantForAutofill="yes"
style={{
position: "absolute",
opacity: 0,
width: 1,
height: 1
}}
/>
</View>
);
};
export default PinInput;

View File

@@ -50,6 +50,8 @@ export interface PressableProps extends RNPressableProps {
type ButtonTypes =
| "plain"
| "plain-outline"
| "accent-background"
| "transparent"
| "accent"
| "shade"
@@ -61,7 +63,8 @@ type ButtonTypes =
| "error"
| "errorShade"
| "warn"
| "selected";
| "selected"
| "accent-outline";
type ButtonVariant = {
primary: string;
@@ -92,6 +95,14 @@ const buttonTypes = (
isDark
)
},
"plain-outline": {
primary: "transparent",
text: colors.primary.paragraph,
selected: colors.primary.hover,
borderWidth: 1,
borderColor: colors.primary.border,
borderSelectedColor: colors.primary.border
},
transparent: {
primary: "transparent",
text: colors.primary.accent,
@@ -105,7 +116,7 @@ const buttonTypes = (
},
secondary: {
primary: colors.secondary.background,
text: colors.secondary.paragraph,
text: colors.primary.paragraph,
selected: colors.secondary.background,
borderWidth: 0.8,
borderColor: getColorLinearShade(colors.secondary.background, 0.05, isDark),
@@ -167,6 +178,20 @@ const buttonTypes = (
false
)
},
"accent-background": {
primary: colors.primary.background,
text: colors.primary.accent,
selected: colors.primary.background,
borderWidth: 0
},
"accent-outline": {
primary: "transparent",
text: colors.primary.accent,
selected: accent || colors.primary.accent,
borderWidth: 1,
borderColor: accent || colors.primary.accent,
borderSelectedColor: accent || colors.primary.accent
},
inverted: {
primary: colors.primary.background,
text: colors.primary.accent,
@@ -268,8 +293,8 @@ export const Pressable = ({
const opacity = customOpacity
? customOpacity
: type === "accent"
? 1
: colorOpacity;
? 1
: colorOpacity;
const alpha = customAlpha ? customAlpha : isDark ? 0.03 : -0.03;
const { fontScale } = useWindowDimensions();
const growFactor = 1 + (fontScale - 1) / 8;

View File

@@ -19,13 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { isReminderActive } from "@notesnook/core";
import React from "react";
import { ViewStyle } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { defaultBorderRadius, AppFontSize } from "../../../utils/size";
import { AppFontSize } from "../../../utils/size";
import { Button, ButtonProps } from "../button";
import { getFormattedReminderTime } from "@notesnook/common";
import { Reminder } from "@notesnook/core";
import { DefaultAppStyles } from "../../../utils/styles";
import { Radius } from "../../../common/design/spacing";
export const ReminderTime = ({
checkIsActive = true,
@@ -55,8 +55,9 @@ export const ReminderTime = ({
title={time}
key={reminder.id}
icon="bell"
iconFamily="notesnook"
fontSize={AppFontSize.xs}
iconSize={AppFontSize.sm}
iconSize={12}
type="secondary"
buttonType={
isTodayOrTomorrow
@@ -70,7 +71,7 @@ export const ReminderTime = ({
}}
style={{
height: "auto",
borderRadius: defaultBorderRadius,
borderRadius: Radius.XXS,
borderColor: colors.primary.border,
paddingHorizontal: DefaultAppStyles.GAP_SMALL,
...(style as ViewStyle)

View File

@@ -0,0 +1,39 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 React from "react";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { Spacing } from "../../../common/design/spacing";
const LineSeparator = ({ padding }: { padding: keyof typeof Spacing }) => {
const { colors } = useThemeColors();
return (
<View
style={{
width: "100%",
height: 1,
backgroundColor: colors.primary.border
// marginVertical: Spacing[padding]
}}
/>
);
};
export default LineSeparator;

View File

@@ -27,6 +27,7 @@ import { useUserStore } from "../../../stores/use-user-store";
import { getContainerBorder } from "../../../utils/colors";
import { NotesnookModule } from "../../../utils/notesnook-module";
import { Toast } from "../../toast";
import { Spacing } from "../../../common/design/spacing";
/**
*
@@ -68,8 +69,9 @@ const SheetWrapper = ({
width: largeTablet || smallTablet ? width : "100%",
backgroundColor: colors.primary.background,
zIndex: 10,
borderTopRightRadius: 15,
borderTopLeftRadius: 15,
borderTopRightRadius: 35,
paddingTop: Spacing.LEVEL_4,
borderTopLeftRadius: 35,
alignSelf: "center",
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0,

View File

@@ -18,23 +18,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import { DimensionValue, View } from "react-native";
import { DimensionValue, View, ViewStyle } from "react-native";
import { SvgXml } from "./lazy";
export const SvgView = ({
width = 250,
height = 250,
src
src,
style
}: {
width?: DimensionValue;
height?: DimensionValue;
src?: string;
style?: ViewStyle;
}) => {
if (!src) return null;
return (
<View
style={{
height: width || 250,
width: height || 250
width: height || 250,
...style
}}
>
<SvgXml xml={src} width="100%" height="100%" />

View File

@@ -19,21 +19,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Platform, Text, TextProps, ViewStyle } from "react-native";
import { Text, TextProps, ViewStyle } from "react-native";
import { AppFontSize } from "../../../utils/size";
import {
FontFamily,
FontSizes,
getLineHeight,
LineHeightVariants
} from "../../../common/design/font";
interface HeadingProps extends TextProps {
color?: string;
/**
* @deprecated Use fontSize prop instead
*/
size?: number;
extraBold?: boolean;
fontSize?: keyof typeof FontSizes;
fontFamily?: keyof typeof FontFamily;
lineHeight?: LineHeightVariants;
}
const extraBoldStyle = {
fontFamily: Platform.OS === "android" ? "Inter-Bold" : undefined,
fontWeight: Platform.OS === "ios" ? "800" : undefined
fontFamily: FontFamily.BOLD
};
const boldStyle = {
fontFamily: Platform.OS === "android" ? "Inter-SemiBold" : undefined,
fontWeight: Platform.OS === "ios" ? "600" : undefined
fontFamily: FontFamily.SEMI_BOLD
};
const Heading = ({
@@ -41,23 +52,34 @@ const Heading = ({
size = AppFontSize.xl,
style,
extraBold,
fontSize,
fontFamily,
lineHeight = "100%",
...restProps
}: HeadingProps) => {
const { colors } = useThemeColors();
return (
<Text
allowFontScaling={true}
{...restProps}
allowFontScaling={true}
style={[
{
fontSize: size || AppFontSize.xl,
color: color || colors.primary.heading
fontSize: fontSize ? FontSizes[fontSize] : size || AppFontSize.xl,
color: color || colors.primary.heading,
lineHeight:
fontSize && lineHeight
? getLineHeight(fontSize, lineHeight)
: undefined
},
extraBold ? (extraBoldStyle as ViewStyle) : (boldStyle as ViewStyle),
fontFamily
? { fontFamily: FontFamily[fontFamily] }
: extraBold
? (extraBoldStyle as ViewStyle)
: (boldStyle as ViewStyle),
style
]}
></Text>
/>
);
};

View File

@@ -21,14 +21,30 @@ import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { Text, TextProps } from "react-native";
import { AppFontSize } from "../../../utils/size";
import {
FontFamily,
FontSizes,
getLineHeight,
LineHeightVariants
} from "../../../common/design/font";
interface ParagraphProps extends TextProps {
color?: string;
/**
* @deprecated Use fontSize prop instead
*/
size?: number;
fontSize?: keyof typeof FontSizes;
fontFamily?: keyof typeof FontFamily;
lineHeight?: LineHeightVariants;
}
const Paragraph = ({
color,
size = AppFontSize.sm,
style,
fontSize,
fontFamily,
lineHeight,
...restProps
}: ParagraphProps) => {
const { colors } = useThemeColors();
@@ -36,12 +52,16 @@ const Paragraph = ({
return (
<Text
{...restProps}
allowFontScaling={true}
style={[
{
fontSize: size || AppFontSize.sm,
fontSize: fontSize ? FontSizes[fontSize] : size || AppFontSize.xl,
color: color || colors.primary.paragraph,
fontWeight: "400",
fontFamily: "Inter-Regular"
fontFamily: fontFamily ? FontFamily[fontFamily] : FontFamily.REGULAR,
lineHeight:
fontSize && lineHeight
? getLineHeight(fontSize, lineHeight)
: undefined
},
style
]}

View File

@@ -36,22 +36,22 @@ export const PlanOverView = {
free: {
storage: `50 MB/mo`,
fileSize: `1 MB`,
hdImages: false
hdImages: "No"
},
essential: {
storage: `1 GB`,
fileSize: `100 MB/mo`,
hdImages: false
hdImages: "No"
},
pro: {
storage: `10 GB/mo`,
fileSize: `1 GB`,
hdImages: true
hdImages: "Yes"
},
believer: {
storage: `25 GB/mo`,
fileSize: `5 GB`,
hdImages: true
hdImages: "Yes"
}
};

View File

@@ -18,20 +18,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useEffect, useRef, useState } from "react";
import "../services/tip-manager";
/**
* A hook that can be used to rotate values in an array.
* It will return random item in an array after given interval
*/
function useRotator<T>(data: T[], interval = 3000): T | null {
function useRotator<T>(
data: T[],
interval = 3000,
sequential = false
): T | null {
//@ts-ignore Added sample() method to Array.prototype to get random value.
const [current, setCurrent] = useState<T>(data.sample());
const [current, setCurrent] = useState<T>(
sequential ? data[0] : data.sample()
);
const intervalRef = useRef<NodeJS.Timeout>(undefined);
const currentRef = useRef<T>(undefined);
const indexRef = useRef<number>(0);
currentRef.current = current;
useEffect(() => {
intervalRef.current = setInterval(() => {
//@ts-ignore Added sample() method to Array.prototype to get random value.
setCurrent(data.sample());
if (sequential) {
indexRef.current = (indexRef.current + 1) % data.length;
setCurrent(data[indexRef.current]);
} else {
//@ts-ignore Added sample() method to Array.prototype to get random value.
setCurrent(data.sample());
}
}, interval);
return () => {
@@ -39,7 +53,7 @@ function useRotator<T>(data: T[], interval = 3000): T | null {
clearInterval(intervalRef.current);
}
};
}, [data, interval]);
}, [data, interval, sequential]);
return current;
}

View File

@@ -30,6 +30,7 @@ import SettingsService from "../../services/settings";
import useNavigationStore from "../../stores/use-navigation-store";
import { useNotes } from "../../stores/use-notes-store";
import { openEditor } from "../notes/common";
import LineSeparator from "../../components/ui/seperator/line-separator";
export const Home = ({ navigation, route }: NavigationProps<"Notes">) => {
const [notes, loading] = useNotes();
@@ -66,6 +67,8 @@ export const Home = ({ navigation, route }: NavigationProps<"Notes">) => {
onPressDefaultRightButton={openEditor}
/>
<LineSeparator padding="LEVEL_3" />
<DelayLayout wait={loading}>
<List
data={notes}

View File

@@ -27,7 +27,7 @@ import {
useSettingStore
} from "../stores/use-setting-store";
import { NotesnookModule } from "../utils/notesnook-module";
import { scale, updateSize } from "../utils/size";
import { scale } from "../utils/size";
import { DatabaseLogger } from "../common/database";
import { useUserStore } from "../stores/use-user-store";
import ScreenGuardModule from "react-native-screenguard";
@@ -123,7 +123,6 @@ function init() {
scale.fontScale = settings.fontScale;
}
updateSize();
useSettingStore.getState().setSettings({ ...settings });
migrateAppLock();
setPrivacyScreen(settings);

View File

@@ -32,18 +32,12 @@ export const ERRORS_LIST = {
SHORT_PASS: strings.passTooShort()
};
export function validatePass(password) {
let errors = {
SHORT_PASS: false
};
if (password?.length < 8) {
errors.SHORT_PASS = true;
export function validatePass(password, length = 8) {
if (password?.length < length) {
return true;
} else {
errors.SHORT_PASS = false;
return false;
}
return errors;
}
export function validateUsername(username) {

View File

@@ -17,7 +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 { ItemType } from "@notesnook/core";
import { Item, ItemType } from "@notesnook/core";
import { create } from "zustand";
export interface SelectionStore {
@@ -62,3 +62,20 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
set({ selectionMode: undefined, selectedItemsList: [] });
}
}));
export function selectItem(item: Item) {
if (useSelectionStore.getState().selectionMode === item.type) {
const { selectionMode, clearSelection, setSelectedItem } =
useSelectionStore.getState();
if (selectionMode === item.type) {
setSelectedItem(item.id);
}
if (useSelectionStore.getState().selectedItemsList.length === 0) {
clearSelection();
}
return true;
}
return false;
}

View File

@@ -36,10 +36,10 @@ export const STORE_LINK =
export const GROUP = {
default: "default",
none: "none",
abc: "abc",
year: "year",
month: "month",
week: "week",
month: "month"
abc: "abc"
};
export const SORT = {

View File

@@ -37,28 +37,16 @@ export const MenuItemsList: SideMenuItem[] = [
dataType: "note",
id: "Notes",
title: "Notes",
icon: "note-outline",
icon: "note",
type: "side-menu-item"
},
// {
// dataType: "notebook",
// id: "Notebooks",
// title: "Notebooks",
// icon: "book-outline"
// },
{
dataType: "note",
id: "Favorites",
title: "Favorites",
icon: "star-outline",
icon: "star",
type: "side-menu-item"
},
// {
// dataType: "tag",
// id: "Tags",
// title: "Tags",
// icon: "pound"
// },
{
dataType: "reminder",
id: "Reminders",
@@ -70,7 +58,7 @@ export const MenuItemsList: SideMenuItem[] = [
dataType: "monograph",
id: "Monographs",
title: "Monographs",
icon: "text-box-multiple-outline",
icon: "book-open",
onPress: () => {
Navigation.closeDrawer();
Monographs.navigate();
@@ -88,7 +76,7 @@ export const MenuItemsList: SideMenuItem[] = [
dataType: "note",
id: "Trash",
title: "Trash",
icon: "delete-outline",
icon: "trash",
type: "side-menu-item"
}
];

View File

@@ -19,10 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Dimensions, PixelRatio, Platform } from "react-native";
import { DDS } from "../../services/device-detection";
import { FontSizes } from "../../common/design/font";
import { Radius } from "../../common/design/spacing";
export const scale = {
fontScale: 1
};
let windowSize = Dimensions.get("window");
let adjustedWidth = windowSize.width * PixelRatio.get();
let adjustedHeight = windowSize.height * PixelRatio.get();
@@ -37,77 +40,64 @@ export const getDeviceSize = () => {
return Platform.isPad ? diagonalSize + 2 : diagonalSize;
};
const getDpi = (pd) => {
return 160 * pd;
};
const correction = (size, multiplier) => {
let dSize = getDeviceSize();
if (dSize <= 4.5 && pixelDensity <= 3) {
return size * 0.85;
} else if (dSize <= 5.3 && pixelDensity <= 3) {
return size * 0.93;
} else if (dSize > 5.3 && dSize < 7 && pixelDensity < 3 && !DDS.isTab) {
if (Platform.OS === "ios") {
return size;
}
return size * 0.97;
} else if (dSize <= 7 && pixelDensity >= 3 && !DDS.isTab) {
return size * 0.98;
} else if (dSize >= 6.5 && dSize <= 7.2 && DDS.isTab) {
return size * multiplier;
} else if (dSize > 7.2 && dSize <= 8.5 && DDS.isTab) {
return size * 0.92;
} else if (dSize > 8.5 && dSize <= 9.2 && DDS.isTab) {
return size * 0.92;
} else if (dSize > 9.2 && dSize <= 10.5 && DDS.isTab) {
return size * 0.95;
} else if (dSize > 10.5) {
return size * 1;
} else {
return size;
}
};
// const getDpi = (pd) => {
// return 160 * pd;
// };
// const correction = (size, multiplier) => {
// let dSize = getDeviceSize();
// if (dSize <= 4.5 && pixelDensity <= 3) {
// return size * 0.85;
// } else if (dSize <= 5.3 && pixelDensity <= 3) {
// return size * 0.93;
// } else if (dSize > 5.3 && dSize < 7 && pixelDensity < 3 && !DDS.isTab) {
// if (Platform.OS === "ios") {
// return size;
// }
// return size * 0.97;
// } else if (dSize <= 7 && pixelDensity >= 3 && !DDS.isTab) {
// return size * 0.98;
// } else if (dSize >= 6.5 && dSize <= 7.2 && DDS.isTab) {
// return size * multiplier;
// } else if (dSize > 7.2 && dSize <= 8.5 && DDS.isTab) {
// return size * 0.92;
// } else if (dSize > 8.5 && dSize <= 9.2 && DDS.isTab) {
// return size * 0.92;
// } else if (dSize > 9.2 && dSize <= 10.5 && DDS.isTab) {
// return size * 0.95;
// } else if (dSize > 10.5) {
// return size * 1;
// } else {
// return size;
// }
// };
export const normalize = (size) => {
let pd = pixelDensity;
if (pd === 1 || pd < 1) {
return correction(size, 0.82);
} else if (pd > 1 && pd <= 1.5) {
return correction(size, 0.7);
} else if (pd > 1.5 && pd <= 2) {
return correction(size, 0.9);
} else if (pd > 2 && pd <= 3) {
return correction(size, 0.93);
} else if (pd > 3) {
return correction(size, 1);
}
return size;
// let pd = pixelDensity;
// if (pd === 1 || pd < 1) {
// return correction(size, 0.82);
// } else if (pd > 1 && pd <= 1.5) {
// return correction(size, 0.7);
// } else if (pd > 1.5 && pd <= 2) {
// return correction(size, 0.9);
// } else if (pd > 2 && pd <= 3) {
// return correction(size, 0.93);
// } else if (pd > 3) {
// return correction(size, 1);
// }
};
function getSize() {
return {
xxxs: normalize(11.5) * scale.fontScale,
xxs: normalize(12.5) * scale.fontScale,
xs: normalize(13.5) * scale.fontScale,
sm: normalize(14.5) * scale.fontScale,
md: normalize(16.5) * scale.fontScale,
lg: normalize(20) * scale.fontScale,
xl: normalize(22) * scale.fontScale,
xxl: normalize(25) * scale.fontScale,
xxxl: normalize(30) * scale.fontScale
xxxs: FontSizes.XXS,
xxs: FontSizes.XXS,
xs: FontSizes.XS,
sm: FontSizes.SM,
md: FontSizes.MD,
lg: FontSizes.LG,
xl: FontSizes.XL,
xxl: FontSizes.XXL,
xxxl: FontSizes.XXL
};
}
export const AppFontSize = getSize();
export function updateSize() {
const newSize = getSize();
for (const key in AppFontSize) {
AppFontSize[key] = newSize[key];
}
ph = normalize(10) * scale.fontScale;
pv = normalize(10) * scale.fontScale;
}
export const defaultBorderRadius = 8; // border radius
export var ph = normalize(10); // padding horizontal
export var pv = normalize(10); // padding vertical
export const opacity = 0.5; // active opacity
export const defaultBorderRadius = Radius.S; // border radius

View File

@@ -19,6 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
export const DefaultAppStyles = {
GAP: 16,
GAP_SMALL: 8,
GAP_VERTICAL: 10,
GAP_VERTICAL: 12,
GAP_VERTICAL_SMALL: 6
};

View File

@@ -0,0 +1 @@
{"m":{"f":"notesnook-icons","u":1024,"z":1020,"s":59648,"h":"83a1ac81fdaaf076cb52c3ad793c668b4be2ce48e94af989b74c69660096843b"},"i":{"archive":[1024,[[59648,"#666666"]]],"bell":[1024,[[59649,"#666666"]]],"book-open":[1024,[[59650,"#666666"]]],"bookmark":[1024,[[59651,"#666666"]]],"box-empty":[1024,[[59652,"#B0B0B1"]]],"calendar":[1024,[[59653,"rgba(102,102,102,0.8)"]]],"chat":[1024,[[59654,"white"]]],"checkbox":[1024,[[59655,"#008836"],[59656,"white"]]],"checks":[1024,[[59657,"#181818"]]],"chevron-down":[1024,[[59658,"#181818"]]],"chevron-up":[1024,[[59659,"#181818"]]],"close":[1024,[[59660,"#666666"]]],"dark-mode-outline":[1024,[[59661,"currentColor"]]],"dots-three":[1024,[[59662,"#202020"]]],"drive-file-move":[1088,[[59663,"#666666"]]],"envelope-simple":[1024,[[59664,"white"]]],"funnel":[1024,[[59665,"#666666"]]],"home":[1024,[[59666,"#181818"]]],"link":[560,[[59667,"#666666"]]],"lock-simple":[1024,[[59668,"white"]]],"menu":[1024,[[59669,"#181818"]]],"note":[1024,[[59670,"#181818"]]],"pin":[939,[[59671,"#666666"]]],"plus":[1024,[[59672,"#666666"]]],"search":[1024,[[59673,"#181818"]]],"shield-check":[1024,[[59674,"#008836"]]],"shopping-mode":[1024,[[59675,"#666666"]]],"sliders":[1024,[[59676,"#181818"]]],"sort-ascending":[1024,[[59677,"#666666"]]],"sort-descending":[1024,[[59678,"currentColor"]]],"star-filled":[1024,[[59679,"#E5C131"]]],"star":[1024,[[59680,"#666666"]]],"sun":[1024,[[59681,"#666666"]]],"trash":[1024,[[59682,"#666666"]]],"view-list":[1024,[[59683,"#181818"]]],"warning-circle":[1024,[[59684,"#BB3431"]]]}}

Binary file not shown.

View File

@@ -28,18 +28,18 @@ Object.defineProperty(global, "Buffer", {
}
});
if (__DEV__ && Config.isTesting !== "true") {
const messages =
require("@notesnook/intl/dist/locales/$pseudo-LOCALE.json").messages;
i18n.load({
en: messages
});
} else {
const messages = require("@notesnook/intl/dist/locales/$en.json").messages;
i18n.load({
en: messages
});
}
// if (!__DEV__ && Config.isTesting !== "true") {
// const messages =
// require("@notesnook/intl/dist/locales/$pseudo-LOCALE.json").messages;
// i18n.load({
// en: messages
// });
// } else {
const messages = require("@notesnook/intl/dist/locales/$en.json").messages;
i18n.load({
en: messages
});
// }
i18n.activate("en");
setI18nGlobal(i18n);

View File

@@ -1,43 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Add to Notes</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
<key>RCTNewArchEnabled</key>
<true/>
</dict>
</plist>
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Add to Notes</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
<key>RCTNewArchEnabled</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>svgs.ttf</string>
<string>notesnook-icons.ttf</string>
</array>
</dict>
</plist>

View File

@@ -386,6 +386,7 @@
240525450DF9ABA0F332B52E /* [CP] Copy Pods Resources */,
65A7F34B255687E600699170 /* Embed App Extensions */,
48C834D962D612F18A0388B3 /* [CP] Embed Pods Frameworks */,
5C222D5F8D0742BFAE9C4245 /* Copy nanoicons fonts */,
);
buildRules = (
);
@@ -721,6 +722,20 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
5C222D5F8D0742BFAE9C4245 /* Copy nanoicons fonts */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy nanoicons fonts";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\n NANOICONS_DIR=\"${PROJECT_DIR}/nanoicons-fonts\"\n if [ -d \"$NANOICONS_DIR\" ]; then\n cp \"$NANOICONS_DIR\"/*.ttf \"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/\" 2>/dev/null || true\n fi\n ";
};
658D06A625A7446E008C70C0 /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;

View File

@@ -99,6 +99,7 @@
<string>Inter-Bold.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>EvilIcons.ttf</string>
<string>notesnook-icons.ttf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>

View File

@@ -2085,6 +2085,34 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- react-native-nano-icons (0.1.8):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- react-native-netinfo (11.4.1):
- React-Core
- react-native-notification-sounds (0.5.5):
@@ -3543,6 +3571,7 @@ DEPENDENCIES:
- react-native-in-app-review (from `../node_modules/react-native-in-app-review`)
- "react-native-keep-awake (from `../node_modules/@sayem314/react-native-keep-awake`)"
- react-native-mmkv-storage (from `../node_modules/react-native-mmkv-storage`)
- react-native-nano-icons (from `../node_modules/react-native-nano-icons`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-notification-sounds (from `../node_modules/react-native-notification-sounds`)
- react-native-orientation-locker (from `../node_modules/react-native-orientation-locker`)
@@ -3752,6 +3781,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@sayem314/react-native-keep-awake"
react-native-mmkv-storage:
:path: "../node_modules/react-native-mmkv-storage"
react-native-nano-icons:
:path: "../node_modules/react-native-nano-icons"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-notification-sounds:
@@ -3968,6 +3999,7 @@ SPEC CHECKSUMS:
react-native-in-app-review: 1516ba69d60d58053b7eb3aaaf8d2a5a74af8b57
react-native-keep-awake: a351e6f67006b47f316ae2b17ee8ee69386167f4
react-native-mmkv-storage: e84980084e371a9c2230bbde071536a7e1539406
react-native-nano-icons: 118c99a62175c3f4737ff21e85252c90158816fb
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
react-native-notification-sounds: ce106d58df0dd384bccbd2e84fb53accab7cc068
react-native-orientation-locker: cc6f357b289a2e0dd2210fea0c52cb8e0727fdaa

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -118,6 +118,7 @@
"react-native-material-menu": "^2.0.0",
"react-native-mmkv-storage": "^12.0.1",
"react-native-modal-datetime-picker": "14.0.0",
"react-native-nano-icons": "^0.1.8",
"react-native-navigation-bar-color": "2.0.2",
"react-native-nitro-cloud-uploader": "^1.0.9",
"react-native-nitro-modules": "^0.32.0",

View File

@@ -1,6 +1,6 @@
const isGithubRelease = false;
const config = {
commands: require("@callstack/repack/commands/rspack")
// commands: require("@callstack/repack/commands/rspack")
};
if (!config.dependencies) config.dependencies = {};

View File

@@ -128,7 +128,8 @@ const EXTRA_ICON_NAMES = [
"identifier",
"image-area",
"clock-outline",
"delete-sweep-outline"
"delete-sweep-outline",
"image-outline"
];
const __filename = fileURLToPath(import.meta.url);

View File

@@ -0,0 +1,11 @@
{
"name": "@notesnook/icons",
"version": "2.1.3",
"main": "./svgs",
"exports": {
".": "./svgs",
"./*": "./svgs/*"
},
"license": "GPL-3.0-or-later",
"sideEffects": false
}

View File

@@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 5.33331V14H2V5.33331" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.3334 2H0.666748V5.33333H15.3334V2Z" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M6.66675 8H9.33341" stroke="#666666" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 454 B

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 5.33331C12 4.27245 11.5786 3.25503 10.8284 2.50489C10.0783 1.75474 9.06087 1.33331 8 1.33331C6.93913 1.33331 5.92172 1.75474 5.17157 2.50489C4.42143 3.25503 4 4.27245 4 5.33331C4 9.99998 2 11.3333 2 11.3333H14C14 11.3333 12 9.99998 12 5.33331Z" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M9.15335 14C9.03614 14.2021 8.86791 14.3698 8.6655 14.4864C8.46309 14.6029 8.2336 14.6643 8.00001 14.6643C7.76643 14.6643 7.53694 14.6029 7.33453 14.4864C7.13212 14.3698 6.96389 14.2021 6.84668 14" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 740 B

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.33325 2H5.33325C6.0405 2 6.71877 2.28095 7.21887 2.78105C7.71897 3.28115 7.99992 3.95942 7.99992 4.66667V14C7.99992 13.4696 7.7892 12.9609 7.41413 12.5858C7.03906 12.2107 6.53035 12 5.99992 12H1.33325V2Z" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M14.6667 2H10.6667C9.95942 2 9.28115 2.28095 8.78105 2.78105C8.28095 3.28115 8 3.95942 8 4.66667V14C8 13.4696 8.21071 12.9609 8.58579 12.5858C8.96086 12.2107 9.46957 12 10 12H14.6667V2Z" stroke="#666666" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 688 B

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.6665 1.33331C3.56986 1.33331 2.6665 2.23667 2.6665 3.33331V12.6666C2.6665 13.7633 3.56986 14.6666 4.6665 14.6666H13.3332V13.3333H4.6665C4.28982 13.3333 3.99984 13.0433 3.99984 12.6666C3.99984 12.29 4.28982 12 4.6665 12H13.3332V10.6666V1.33331H10.6665H6.6665H4.6665ZM4.6665 2.66665H6.6665V8.08201L7.71598 7.34633L8.6665 6.67836L10.6665 8.08201V2.66665H11.9998V10.6666H4.6665C4.43194 10.6666 4.20976 10.7159 3.99984 10.7916V3.33331C3.99984 2.95663 4.28982 2.66665 4.6665 2.66665ZM7.99984 2.66665H9.33317V5.51821L8.6665 5.05076L7.99984 5.51821V2.66665Z" fill="#666666"/>
</svg>

After

Width:  |  Height:  |  Size: 683 B

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 0.5H12C13.933 0.5 15.5 2.067 15.5 4V12C15.5 13.933 13.933 15.5 12 15.5H4C2.067 15.5 0.5 13.933 0.5 12V4C0.5 2.067 2.067 0.5 4 0.5Z" stroke="#B0B0B1"/>
</svg>

After

Width:  |  Height:  |  Size: 266 B

View File

@@ -0,0 +1,10 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1253_14453)">
<path d="M10 1.5H9.5V0.5H8.5V1.5H3.5V0.5H2.5V1.5H2C1.45 1.5 1 1.95 1 2.5V10.5C1 11.05 1.45 11.5 2 11.5H10C10.55 11.5 11 11.05 11 10.5V2.5C11 1.95 10.55 1.5 10 1.5ZM10 10.5H2V5H10V10.5ZM10 4H2V2.5H10V4Z" fill="#666666" fill-opacity="0.8"/>
</g>
<defs>
<clipPath id="clip0_1253_14453">
<rect width="12" height="12" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 490 B

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.5 3H2.50002C2.2348 3 1.98045 3.10536 1.79291 3.29289C1.60537 3.48043 1.50002 3.73478 1.50002 4V14C1.49886 14.1907 1.55281 14.3777 1.65537 14.5384C1.75793 14.6992 1.90473 14.8269 2.07814 14.9062C2.21029 14.9678 2.35425 14.9998 2.50002 15C2.73477 14.9994 2.96174 14.9157 3.14064 14.7638L3.14627 14.7594L5.18752 13H13.5C13.7652 13 14.0196 12.8946 14.2071 12.7071C14.3947 12.5196 14.5 12.2652 14.5 12V4C14.5 3.73478 14.3947 3.48043 14.2071 3.29289C14.0196 3.10536 13.7652 3 13.5 3ZM13.5 12H5.00002C4.87996 12.0001 4.76394 12.0433 4.67314 12.1219L2.50002 14V4H13.5V12Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 696 B

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" rx="4" fill="#008836"/>
<path d="M6.69059 11.6351C6.49451 11.8354 6.17216 11.8354 5.97608 11.6351L3.34252 8.94556C3.1522 8.75118 3.1522 8.44031 3.34252 8.24593L3.80941 7.76911C4.00549 7.56886 4.32784 7.56886 4.52392 7.76911L5.97608 9.25217C6.17216 9.45242 6.49451 9.45242 6.69059 9.25217L11.4761 4.36486C11.6722 4.16461 11.9945 4.16461 12.1906 4.36486L12.6575 4.84168C12.8478 5.03605 12.8478 5.34693 12.6575 5.5413L6.69059 11.6351Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 580 B

Some files were not shown because too many files have changed in this diff Show More