From 4e01fa5dd4fa1a9a1f85055cf8796252315d8a70 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 14 Apr 2020 21:30:53 +0530 Subject: [PATCH] Add bottom sheet for Subjects. --- components/timetable/HomeScreen.js | 57 ++++++++++++++++++++++++++++-- package.json | 1 + yarn.lock | 5 +++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/components/timetable/HomeScreen.js b/components/timetable/HomeScreen.js index 23a435a..a556090 100644 --- a/components/timetable/HomeScreen.js +++ b/components/timetable/HomeScreen.js @@ -8,6 +8,7 @@ import { Dialog, FAB, Portal, + Modal, } from "react-native-paper"; import { @@ -16,6 +17,8 @@ import { } from "react-native"; import { format } from "date-fns"; +import BottomSheet from "reanimated-bottom-sheet"; + function sortTimes(t1, t2) { if (t1.getHours() > t2.getHours()) return 1; @@ -30,6 +33,32 @@ function sortTimes(t1, t2) { function HomeScreen({ days, navigation, removeTimetableEntry, subjects, timetable }) { const [ dialog, setDialog ] = useState({ show: false, id: null }); + const [ currentBottomSheet, setCurrentBottomSheet ] = useState(null); + + this.bs = React.createRef(); + const openBottomSheet = () => {this.bs.current.snapTo(0);this.bs.current.snapTo(0);}; + const closeBottomSheet = () => {this.bs.current.snapTo(2);this.bs.current.snapTo(2);}; + + function CardContents() { + if (!currentBottomSheet) { + return <>; + } + const subject = subjects.find(i => i.id === currentBottomSheet.sub_id); + return ( + + + + + + + + + + ); + } return ( {timetable.map((day, dayIdx) => ( setDialog({ show: true, id: cls.id })} + onPress={() => { + setCurrentBottomSheet(cls); + openBottomSheet(); + }} > navigation.navigate("New Entry")} style={{ @@ -128,6 +161,21 @@ function HomeScreen({ days, navigation, removeTimetableEntry, subjects, timetabl bottom: 0, }} /> + + + setCurrentBottomSheet(null)} + onCloseEnd={() => {}} + /> ); } @@ -154,6 +202,11 @@ const style = StyleSheet.create({ flexDirection: "row", justifyContent: "space-between" }, + bottomNavigation: { + height: 250, + flexDirection: "column", + justifyContent: "space-evenly", + }, }); export default HomeScreen; diff --git a/package.json b/package.json index e6ef472..fc77134 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "react-native-uuid": "^1.4.9", "react-native-vector-icons": "^6.6.0", "react-redux": "^7.2.0", + "reanimated-bottom-sheet": "^1.0.0-alpha.19", "redux": "^4.0.5", "redux-devtools-extension": "^2.13.8", "redux-persist": "^6.0.0" diff --git a/yarn.lock b/yarn.lock index 8d842c0..c04c5c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5420,6 +5420,11 @@ realpath-native@^1.1.0: dependencies: util.promisify "^1.0.0" +reanimated-bottom-sheet@^1.0.0-alpha.19: + version "1.0.0-alpha.19" + resolved "https://registry.npmjs.org/reanimated-bottom-sheet/-/reanimated-bottom-sheet-1.0.0-alpha.19.tgz#94ea79e7b2896b8f489547415d15d15c99ac44ba" + integrity sha512-Q0sGUHYdr5h2n/AY7pKQty35zcUAxxYM1nCl+luSQAyqiY6a5Kf8IBQRsOVvs60sDzqXxtbwxHgM5mkwaiQC4Q== + redux-devtools-extension@^2.13.8: version "2.13.8" resolved "https://registry.npmjs.org/redux-devtools-extension/-/redux-devtools-extension-2.13.8.tgz#37b982688626e5e4993ff87220c9bbb7cd2d96e1"