Skip to content

Commit

Permalink
Redo previous changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarsheechatterjee committed Mar 16, 2021
1 parent fa4d810 commit 781e8df
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 190 deletions.
6 changes: 3 additions & 3 deletions src/navigation/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityI

import Library from "../screens/Library/Library";
import History from "../screens/History/History";
import Browse from "../screens/Browse";
import Browse from "../screens/Browse/Browse";

import More from "../screens/More/More";
import About from "../screens/More/About";
import Settings from "../screens/More/Settings";

import NovelItem from "../screens/NovelItem";
import ChapterItem from "../screens/ChapterItem";
import NovelItem from "../screens/Novel/Novel";
import ChapterItem from "../screens/Chapter/Chapter";

// Extensions
import BoxNovel from "../screens/extensions/boxnovel/BoxNovel";
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Browse.js → src/screens/Browse/Browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ActivityIndicator,
} from "react-native";
import { TouchableRipple, Button } from "react-native-paper";
import { CustomAppbar } from "../components/common/Appbar";
import { CustomAppbar } from "../../components/common/Appbar";

import { useSelector } from "react-redux";

Expand Down
8 changes: 4 additions & 4 deletions src/screens/ChapterItem.js → src/screens/Chapter/Chapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React, { useState, useEffect } from "react";
import { StyleSheet, View, Text, ActivityIndicator } from "react-native";

import { Appbar, Provider, Portal } from "react-native-paper";
import { theme } from "../theme/theme";
import { theme } from "../../theme/theme";
import { CollapsibleHeaderScrollView } from "react-native-collapsible-header-views";

import BottomSheet from "../components/chapter/BottomSheet";
import BottomSheet from "./components/BottomSheet";

import * as SQLite from "expo-sqlite";
const db = SQLite.openDatabase("lnreader.db");

import { fetchChapterFromSource } from "../services/api";
import { fetchChapterFromSource } from "../../services/api";

import { getReaderTheme } from "../services/asyncStorage";
import { getReaderTheme } from "../../services/asyncStorage";

const ChapterItem = ({ route, navigation }) => {
const { extensionId, chapterUrl, novelUrl, chapterName } = route.params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Bottomsheet from "rn-sliding-up-panel";

import { useSelector } from "react-redux";

import { saveReaderTheme } from "../../services/asyncStorage";
import { saveReaderTheme } from "../../../services/asyncStorage";

const ChapterBottomSheet = ({
bottomSheetRef,
Expand Down
60 changes: 13 additions & 47 deletions src/screens/History/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import {
} from "react-native";

import { CustomAppbar } from "../../components/common/Appbar";
import HistoryCard from "../../components/history/HistoryCard";
import HistoryCard from "./components/HistoryCard";

import { getHistoryFromDb, deleteChapterHistory } from "../../services/db";

import { useSelector } from "react-redux";
import EmptyView from "./components/EmptyView";

const History = ({ navigation }) => {
const [loading, setLoading] = useState(true);
const [history, setHistory] = useState();
const [history, setHistory] = useState([]);

const theme = useSelector((state) => state.themeReducer.theme);

Expand All @@ -38,6 +39,14 @@ const History = ({ navigation }) => {
}, [])
);

const renderHistoryCard = ({ item }) => (
<HistoryCard
item={item}
deleteHistory={deleteHistory}
navigation={navigation}
/>
);

return (
<>
<CustomAppbar title="History" />
Expand All @@ -51,13 +60,7 @@ const History = ({ navigation }) => {
contentContainerStyle={{ flex: 1 }}
data={history}
keyExtractor={(item) => item.historyId.toString()}
renderItem={({ item }) => (
<HistoryCard
item={item}
deleteHistory={deleteHistory}
navigation={navigation}
/>
)}
renderItem={renderHistoryCard}
ListFooterComponent={
loading && (
<ActivityIndicator
Expand All @@ -66,38 +69,7 @@ const History = ({ navigation }) => {
/>
)
}
ListEmptyComponent={
!loading && (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text
style={{
color: theme.textColorSecondaryDark,
fontSize: 45,
fontWeight: "bold",
}}
>
(˘・_・˘)
</Text>
<Text
style={{
color: theme.textColorSecondaryDark,
fontWeight: "bold",
marginTop: 10,
textAlign: "center",
paddingHorizontal: 30,
}}
>
Nothing read recently.
</Text>
</View>
)
}
ListEmptyComponent={!loading && <EmptyView />}
/>
</View>
</>
Expand All @@ -111,10 +83,4 @@ const styles = StyleSheet.create({
flex: 1,
padding: 10,
},
historyCard: {
marginTop: 10,
borderRadius: 4,
flexDirection: "row",
alignItems: "center",
},
});
52 changes: 52 additions & 0 deletions src/screens/History/components/EmptyView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { useSelector } from "react-redux";

const EmptyView = () => {
const theme = useSelector((state) => state.themeReducer.theme);

return (
<View style={styles.emptyViewContainer}>
<Text
style={[
styles.emptyViewIcon,
{
color: theme.textColorSecondaryDark,
},
]}
>
(˘・_・˘)
</Text>
<Text
style={[
styles.emptyViewText,
{
color: theme.textColorSecondaryDark,
},
]}
>
Nothing read recently.
</Text>
</View>
);
};

export default EmptyView;

const styles = StyleSheet.create({
emptyViewContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
emptyViewIcon: {
fontSize: 45,
fontWeight: "bold",
},
emptyViewText: {
fontWeight: "bold",
marginTop: 10,
textAlign: "center",
paddingHorizontal: 30,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const HistoryCard = ({ item, deleteHistory, navigation }) => {

return (
<TouchableRipple
style={[
styles.historyCard,
// { backgroundColor: theme.colorDarkPrimary },
]}
style={styles.historyCard}
rippleColor={theme.rippleColorDark}
borderless
onPress={() =>
Expand All @@ -31,20 +28,9 @@ const HistoryCard = ({ item, deleteHistory, navigation }) => {
<>
<Image
source={{ uri: item.novelCover }}
style={{
height: 80,
width: 57,
borderRadius: 4,
}}
style={styles.historyCover}
/>
<View
style={{
marginLeft: 15,
flex: 1,
flexDirection: "row",
justifyContent: "space-between",
}}
>
<View style={styles.historyText}>
<View style={{ flex: 0.9 }}>
<Text
style={{
Expand Down Expand Up @@ -110,13 +96,20 @@ export default HistoryCard;

const styles = StyleSheet.create({
historyCard: {
// backgroundColor: theme.colorDarkPrimary,
// paddingVertical: 10,
// marginVertical: 5,
// paddingHorizontal: 20,
marginBottom: 15,
borderRadius: 4,
flexDirection: "row",
alignItems: "center",
},
historyCover: {
height: 80,
width: 57,
borderRadius: 4,
},
historyText: {
marginLeft: 15,
flex: 1,
flexDirection: "row",
justifyContent: "space-between",
},
});
Loading

0 comments on commit 781e8df

Please sign in to comment.