Skip to content

Commit 316ab3c

Browse files
author
vacom
committed
chore: improve ux and pages
1 parent af40b40 commit 316ab3c

File tree

10 files changed

+653
-74
lines changed

10 files changed

+653
-74
lines changed

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Diary",
66
"description": "Reflect on your daily events and save beautiful moments with Diary by Storytics.",
77
"slug": "diary-by-storytics",
8-
"version": "1.0.0",
8+
"version": "1.0.6",
99
"orientation": "portrait",
1010
"icon": "./assets/icon.png",
1111
"backgroundColor": "#ffffff",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"expo-local-authentication": "~9.5.0",
3434
"expo-localization": "~9.1.0",
3535
"expo-network": "~2.4.0",
36-
"expo-splash-screen": "~0.8.1",
3736
"expo-sqlite": "~8.5.0",
3837
"expo-status-bar": "~1.0.3",
38+
"expo-updates": "~0.4.1",
3939
"i18n-js": "^3.8.0",
4040
"react": "16.13.1",
4141
"react-dom": "16.13.1",

src/components/NoteBook/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Header,
1010
HeaderWrapper,
1111
Content,
12-
Line,
1312
Footer,
1413
LoadingContainer,
1514
LoadingBox,
@@ -57,7 +56,6 @@ const NoteBook: React.FC<ActivityCardProps> = ({
5756
}) => {
5857
const linesAnimation = useRef(new Animated.Value(0)).current;
5958
const theme = useTheme();
60-
const lineHeight = 40;
6159

6260
useEffect(() => {
6361
Animated.loop(
@@ -114,10 +112,6 @@ const NoteBook: React.FC<ActivityCardProps> = ({
114112
<LoadingContainer isSimpleLayout={isSimpleLayout}>
115113
<AnimatedLoadingBox style={animationStyles} top={16} />
116114
<AnimatedLoadingBox style={animationStyles} top={56} width={50} />
117-
{!isSimpleLayout &&
118-
[...Array(20)].map((e, i) => (
119-
<Line key={i.toString()} height={lineHeight} />
120-
))}
121115
</LoadingContainer>
122116
)}
123117
<LinearGradient

src/components/NoteBook/styles.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ export const ContentWrapper = styled.View`
5858
flex: 1;
5959
`;
6060

61-
export const Line = styled.View<{ height?: number }>`
62-
height: ${({ height }) => (height ? `${height}px` : "40px")};
63-
flex-shrink: 0;
64-
${borderStyle};
65-
`;
66-
6761
export const Footer = styled.View`
6862
display: flex;
6963
align-items: center;

src/index.tsx

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import React, {
2-
useEffect,
3-
useMemo,
4-
useRef,
5-
useState,
6-
useCallback,
7-
} from "react";
8-
import { AppState, AppStateStatus, StatusBar, View } from "react-native";
1+
import React, { useEffect, useMemo, useRef, useState } from "react";
2+
import { Alert, AppState, AppStateStatus, StatusBar, View } from "react-native";
93
import AppLoading from "expo-app-loading";
10-
import * as SplashScreen from "expo-splash-screen";
4+
import * as Updates from "expo-updates";
115
// Components
126
import Notification from "components/Notification";
137
import { getLastCloudSync, uploadDataToCloud } from "components/NetworkStatus";
@@ -32,6 +26,10 @@ import useStore from "hooks/useStore";
3226
import useInterval from "hooks/useInterval";
3327
// Types
3428
import { NetworkStatus, SubscriptionStatus } from "types/store";
29+
// Utils
30+
import Constants from "expo-constants";
31+
// Locales
32+
import i18n from "locales/index";
3533

3634
/** URL polyfill. Required for Supabase queries to work in React Native. */
3735
import "react-native-url-polyfill/auto";
@@ -105,6 +103,40 @@ const Register: React.FC<Props> = ({ isFontsLoading, isDatabaseLoading }) => {
105103
// eslint-disable-next-line react-hooks/exhaustive-deps
106104
}, [isHomeScreenLoading, hasPasswordPin, appStateVisible]);
107105

106+
useEffect(() => {
107+
// Over the air updates
108+
const checkForOTA = async () => {
109+
try {
110+
const { isAvailable } = await Updates.checkForUpdateAsync();
111+
112+
if (isAvailable) {
113+
const { isNew } = await Updates.fetchUpdateAsync();
114+
if (isNew) {
115+
Alert.alert(
116+
`${i18n.t("alerts.ota.title")} (v${Constants.manifest.version})`,
117+
i18n.t("alerts.ota.message"),
118+
[
119+
{
120+
text: i18n.t("alerts.ota.buttons.ok"),
121+
onPress: async () => {
122+
await Updates.reloadAsync();
123+
},
124+
},
125+
],
126+
{ cancelable: false }
127+
);
128+
}
129+
}
130+
} catch (e) {
131+
console.log("Error getting the OTA = ", e);
132+
}
133+
};
134+
135+
if (!isHomeScreenLoading) {
136+
checkForOTA();
137+
}
138+
}, [isHomeScreenLoading]);
139+
108140
const handleAppStateChange = (nextAppState: AppStateStatus) => {
109141
appState.current = nextAppState;
110142
setAppStateVisible(appState.current);
@@ -117,12 +149,8 @@ const Register: React.FC<Props> = ({ isFontsLoading, isDatabaseLoading }) => {
117149
};
118150
}, []);
119151

120-
const onRemoveSplashScreen = useCallback(async () => {
121-
await SplashScreen.hideAsync();
122-
}, []);
123-
124152
if ((isFontsLoading && isDatabaseLoading) || isHomeScreenLoading) {
125-
return <AppLoading onFinish={onRemoveSplashScreen} autoHideSplash />;
153+
return <AppLoading autoHideSplash />;
126154
}
127155

128156
return (

src/locales/lang/en.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,13 @@ export default {
236236
ok: "Load Draft",
237237
},
238238
},
239+
ota: {
240+
title: "New update available",
241+
message:
242+
"A new version of the app is available, which brings improvements and corrections.",
243+
buttons: {
244+
ok: "Download",
245+
},
246+
},
239247
},
240248
};

src/locales/lang/pt.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,13 @@ export default {
237237
ok: "Carregar",
238238
},
239239
},
240+
ota: {
241+
title: "Nova atualização disponível",
242+
message:
243+
"Está disponível uma nova versão do aplicativo, que traz melhorias e correções.",
244+
buttons: {
245+
ok: "Descarregar",
246+
},
247+
},
240248
},
241249
};

src/screens/Diary/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ const DiaryScreen: React.FC<DiaryNavigationProps> = ({
7878
(page: PageProps) => page.id === params.activityPageId
7979
);
8080

81+
console.log("activityIndex = ", activityIndex);
82+
8183
setBookPages([...pages, defaultPage]);
8284
setPageNumber(activityIndex === -1 ? pages.length : activityIndex);
8385

@@ -103,12 +105,13 @@ const DiaryScreen: React.FC<DiaryNavigationProps> = ({
103105
);
104106

105107
useEffect(() => {
106-
RichTextViewRef.current?.setContentHTML(unescapeHtml(currentPage.content));
107108
if (!isEditorLoading) {
109+
RichTextViewRef.current?.setContentHTML(
110+
unescapeHtml(currentPage.content)
111+
);
108112
setEditorLoading(false);
109113
}
110-
// eslint-disable-next-line react-hooks/exhaustive-deps
111-
}, [currentPage, isEditorLoading]);
114+
}, [currentPage, isEditorLoading, RichTextViewRef, params.activityPageId]);
112115

113116
const onPrevPage = () => {
114117
const prevPage = pageNumber - 1;

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export const SUPABASE_URL = "https://svysmlxhputrpnaoigve.supabase.co";
44
export const SUPABASE_KEY =
55
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjgxNDQ4NCwiZXhwIjoxOTI4MzkwNDg0fQ.z-MICAaM9GVzKHcGpN8jY0KSXOngZWz72uwyfEDMCKk";
66

7+
export const isDev = __DEV__;
8+
79
export const billing = {
810
checkout: `https://billing.storytics.pt/diary/plans/checkout`,
911
plans: `https://billing.storytics.pt/diary/plans/select`,

0 commit comments

Comments
 (0)