Skip to content

Commit

Permalink
mobile: LibraryCarouselTabs: refactor to one function
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Feb 26, 2024
1 parent 5858bab commit 09b8d00
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions mobile/Components/LibraryCarousel/LibraryCarouselTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import * as React from "react";
import {
Button,
FlatList,
StyleSheet,
Text,
View,
ScrollView,
Pressable,
} from "react-native";
import { Text, View, ScrollView, Pressable } from "react-native";
import { createMaterialTopTabNavigator } from "@react-navigation/material-top-tabs";
import Carousel from "../Carousel/Carousel";
import Colors from "../../Constants/Colors";
import { client } from "../../appwrite";
import { Databases, Account } from "appwrite";
import { useEffect, useState } from "react";
import ID from "../../Constants/ID";
import { BACKEND_API_BOOK_SEARCH_URL } from "../../Constants/URLs";
import { Query } from "appwrite";

const Tab = createMaterialTopTabNavigator();
Expand Down Expand Up @@ -111,11 +102,13 @@ function MyTabBar({ state, descriptors, navigation, position }) {
);
}

function CurrentlyReadingCarousel() {
function ReadingStatusCarousel({ status }) {
const [books, setBooks] = useState([]);

useEffect(() => {
(async () => {setBooks(await getBooksOfStatus("CURRENTLY_READING"))})();
(async () => {
setBooks(await getBooksOfStatus(status));
})();
}, []);

return (
Expand All @@ -125,24 +118,6 @@ function CurrentlyReadingCarousel() {
);
}

function WantToReadCarousel() {
return <View style={{ flex: 1 }}>{/* <Carousel books={books} /> */}</View>;
}

function ReadCarousel() {
return (
<View style={{ flex: 1 }}>{/* <Carousel currentShelf={"Read"} /> */}</View>
);
}

function DNFCarousel() {
return (
<View style={{ flex: 1 }}>
{/* <Carousel currentShelf={"Did Not Finish"} /> */}
</View>
);
}

function LibraryCarouselTabs({ navigation }) {
return (
<Tab.Navigator
Expand All @@ -151,7 +126,7 @@ function LibraryCarouselTabs({ navigation }) {
>
<Tab.Screen
name="Currently Reading"
component={CurrentlyReadingCarousel}
children={() => <ReadingStatusCarousel status="CURRENTLY_READING" />}
listeners={{
tabPress: (e) => {
shelf = "Currently Reading";
Expand All @@ -160,7 +135,7 @@ function LibraryCarouselTabs({ navigation }) {
/>
<Tab.Screen
name="Want To Read"
component={WantToReadCarousel}
children={() => <ReadingStatusCarousel status="WANT_TO_READ" />}
listeners={{
tabPress: (e) => {
shelf = "Want To Read";
Expand All @@ -169,7 +144,7 @@ function LibraryCarouselTabs({ navigation }) {
/>
<Tab.Screen
name="Read"
component={ReadCarousel}
children={() => <ReadingStatusCarousel status="READ" />}
listeners={{
tabPress: (e) => {
shelf = "Read";
Expand All @@ -178,7 +153,7 @@ function LibraryCarouselTabs({ navigation }) {
/>
<Tab.Screen
name="Did Not Finish"
component={DNFCarousel}
children={() => <ReadingStatusCarousel status="DID_NOT_FINISH" />}
listeners={{
tabPress: (e) => {
shelf = "Did Not Finish";
Expand Down

0 comments on commit 09b8d00

Please sign in to comment.