Skip to content

Commit

Permalink
The second release(custom labels) (#9)
Browse files Browse the repository at this point in the history
* Feat/custom labels (#8)

* feat(notes): handle displaying the separator correctly

* feat(notes): implement scroll to top on logo press

* feat: implement the type selector modal

* feat(labels): integrate with labels endpoints, implement the logic

* fix(label): handle displaying input over the keyboard

* refactor(notes): structure files by folders

* feat(labels): implement the categories selector

* chore: add a build command
  • Loading branch information
Shysh-Oleksandr authored Oct 19, 2023
1 parent 1ad6bf3 commit 3688b8b
Show file tree
Hide file tree
Showing 38 changed files with 1,769 additions and 506 deletions.
5 changes: 2 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"userInterfaceStyle": "light",
"androidStatusBar": {
"backgroundColor": "#0891b2",
"barStyle": "light-content",
"translucent": true
"barStyle": "light-content"
},
"splash": {
"image": "./assets/images/splash.png",
Expand All @@ -32,7 +31,7 @@
"backgroundImage": "./assets/images/iconBg.png",
"backgroundColor": "#354352"
},
"versionCode": 3,
"versionCode": 4,
"package": "com.frankmelward.bulletjournal"
},
"plugins": [
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"build": "eas build --platform android",
"prepare": "husky install",
"lint": "yarn lint:js && yarn lint:types-cli",
"lint:js": "eslint --ext .ts --ext .tsx .",
Expand Down Expand Up @@ -35,7 +36,6 @@
"@react-navigation/stack": "^6.3.11",
"@reduxjs/toolkit": "^1.9.6",
"@shopify/flash-list": "1.4.3",
"@types/redux-logger": "^3.0.10",
"axios": "^1.5.0",
"expo": "~49.0.12",
"expo-application": "~5.3.0",
Expand All @@ -59,6 +59,7 @@
"react-native": "0.72.5",
"react-native-dotenv": "^3.4.9",
"react-native-gesture-handler": "~2.12.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-modal-datetime-picker": "^17.1.0",
"react-native-pell-rich-editor": "^1.9.0",
"react-native-render-html": "^6.3.4",
Expand Down Expand Up @@ -88,6 +89,7 @@
"@types/tinycolor2": "^1.4.4",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@types/redux-logger": "^3.0.10",
"babel-plugin-module-resolver": "^5.0.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
6 changes: 1 addition & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export default function App() {
<ThemeProvider theme={theme}>
<Provider store={store}>
<SafeAreaProvider>
<StatusBar
translucent
barStyle="light-content"
backgroundColor="transparent"
/>
<StatusBar barStyle="light-content" backgroundColor="transparent" />
<Container onLayout={onLayoutRootView}>
<Nav />
</Container>
Expand Down
149 changes: 149 additions & 0 deletions src/components/BottomModal/AnimatedModalContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import React, {
PropsWithChildren,
useCallback,
useEffect,
useMemo,
useRef,
} from "react";
import { Animated, Modal, useWindowDimensions } from "react-native";
import style from "styled-components";

import styled from "styled-components/native";

type Props = {
isVisible: boolean;
modalAnimationTime?: number;
statusBarTranslucent?: boolean;
bgOpacity: number;
closeTriggered?: boolean;
setIsVisible: (arg: boolean) => void;
setCloseTriggered?: (value: boolean) => void;
onClose?: () => void;
};

const AnimatedModalContainer = ({
modalAnimationTime,
isVisible,
bgOpacity,
closeTriggered,
children,
setIsVisible,
setCloseTriggered,
onClose,
}: PropsWithChildren<Props>): JSX.Element => {
const { height: screenHeight } = useWindowDimensions();

const modalTransition = useRef(new Animated.Value(0)).current;

const modalContainerStyle = useMemo(
() => ({
transform: [
{
translateY: modalTransition.interpolate({
outputRange: [screenHeight, 0],
inputRange: [0, 1],
}),
},
],
}),
[modalTransition, screenHeight],
);

const modalTransitionDownAnimation = useMemo(
() =>
Animated.timing(modalTransition, {
duration: modalAnimationTime,
useNativeDriver: true,
toValue: 0,
}),
[modalTransition, modalAnimationTime],
);

const modalTransitionUpAnimation = useMemo(
() =>
Animated.timing(modalTransition, {
duration: modalAnimationTime,
useNativeDriver: true,
toValue: 1,
}),
[modalAnimationTime, modalTransition],
);

// Close modal animation
const closeModal = useCallback(() => {
modalTransitionDownAnimation.start(({ finished }) => {
if (finished) {
setIsVisible(false);

onClose?.();
}
});
}, [modalTransitionDownAnimation, setIsVisible, onClose]);

const onRequestClose = useCallback(() => {
setIsVisible(false);
}, [setIsVisible]);

// Modal background Animation
useEffect(() => {
requestAnimationFrame(() => {
isVisible && modalTransitionUpAnimation.start();
});

return () => {
modalTransitionUpAnimation.stop();
};
}, [isVisible, modalTransitionUpAnimation]);

// closing modal outside the component
useEffect(() => {
if (closeTriggered && setCloseTriggered) {
closeModal();
setCloseTriggered(false);
}
}, [closeModal, closeTriggered, setCloseTriggered]);

return (
<Modal
onRequestClose={onRequestClose}
presentationStyle="overFullScreen"
statusBarTranslucent
animationType="fade"
visible={isVisible}
transparent
>
<SBackground bgOpacity={bgOpacity} />

<SModalContainer style={modalContainerStyle}>
<STopSpace onTouchEnd={closeModal} />

{children}
</SModalContainer>
</Modal>
);
};

const SModalContainer = style(Animated.View)`
height: 100%;
width: 100%;
justify-content: flex-end;
`;

const SBackground = styled.View<{ bgOpacity: number }>`
position: absolute;
top: 0;
bottom: -100px;
z-index: -100;
flex: 1;
width: 100%;
background-color: ${({ theme }) => theme.colors.black};
opacity: ${({ bgOpacity }) => bgOpacity};
`;

const STopSpace = styled.View`
flex: 1;
width: 100%;
background-color: transparent;
`;

export default AnimatedModalContainer;
Loading

0 comments on commit 3688b8b

Please sign in to comment.