Skip to content

Commit dfc5f32

Browse files
committed
feat: major rewrite for better maintanability and clarity
1 parent 7b8dbaf commit dfc5f32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2455
-2043
lines changed

__tests__/App-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'react-native';
66
import React from 'react';
7-
import App from '@/screens/Search';
7+
import App from '@/screens/Search/Search';
88

99
// Note: test renderer must be required after react-native.
1010
import renderer from 'react-test-renderer';

src/containers/Home/SectionContainer/index.tsx

-40
This file was deleted.

src/containers/Home/TrendingTodayContainer/index.tsx

-159
This file was deleted.

src/containers/Home/index.tsx

-4
This file was deleted.

src/navigation/main.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55
import {
66
Search,
7-
MangaDetails,
8-
MangaReader,
7+
Manga,
8+
Reader,
99
Home,
10-
SelectSources,
10+
Sources,
1111
Login,
12-
SignUp,
12+
Signup,
1313
Profile,
1414
} from '@/screens';
1515
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -102,11 +102,11 @@ export default function App() {
102102
}}
103103
>
104104
<Stack.Screen name="Login" component={Login} />
105-
<Stack.Screen name="SignUp" component={SignUp} />
105+
<Stack.Screen name="Signup" component={Signup} />
106106
<Stack.Screen name="Main" component={TabNavigator} />
107-
<Stack.Screen name="MangaDetails" component={MangaDetails} />
108-
<Stack.Screen name="MangaReader" component={MangaReader} />
109-
<Stack.Screen name="SelectSources" component={SelectSources} />
107+
<Stack.Screen name="Manga" component={Manga} />
108+
<Stack.Screen name="Reader" component={Reader} />
109+
<Stack.Screen name="Sources" component={Sources} />
110110
</Stack.Navigator>
111111
);
112112
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import responsive from '@/global/utils/responsive';
2-
import { useAppDispatch, useAppSelector } from '@/hooks/redux';
3-
import { setSelectedManga } from '@/redux/features/mangaSlice';
1+
import { useAppSelector, useAppDispatch } from '@/hooks/redux';
2+
import {
3+
setCurrentlyReading,
4+
setSelectedManga,
5+
} from '@/redux/features/mangaSlice';
46
import { useNavigation } from '@react-navigation/native';
57
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
6-
import React, { useEffect, useState } from 'react';
7-
import styled from 'styled-components/native';
8-
import { setCurrentlyReading } from '@/redux/features/mangaSlice';
9-
import { ActivityIndicator } from 'react-native';
108
import CURRENTLY_READING_REQUESTS from '@/services/requests/currently-reading';
9+
import { useState, useEffect } from 'react';
10+
import { CurrentlyReadingMangaProps } from './ContinueReading.type';
1111

12-
interface CurrentlyReadingMangaProps {
13-
id: string;
14-
currentChapter: string;
15-
finishedChapters: string[];
16-
image: string;
17-
source: string;
18-
referer: string;
19-
}
20-
21-
export default function ContinueReadingContainer() {
12+
export const useContinueReadingService = () => {
2213
const { currentlyReading } = useAppSelector(state => state.manga);
2314
const user = useAppSelector(state => state.auth.user);
2415
const [loading, setLoading] = useState(false);
@@ -49,7 +40,7 @@ export default function ContinueReadingContainer() {
4940
referer: manga.referer,
5041
}),
5142
);
52-
navigation.navigate('MangaDetails');
43+
navigation.navigate('Manga');
5344
}
5445

5546
function handleRemoveFromReading() {
@@ -72,62 +63,11 @@ export default function ContinueReadingContainer() {
7263
return texts[Math.floor(Math.random() * texts.length)];
7364
}
7465

75-
if (loading) {
76-
return (
77-
<LoadingContainer>
78-
<ActivityIndicator size="large" color="#fff" />
79-
</LoadingContainer>
80-
);
81-
}
82-
83-
console.log(currentlyReading);
84-
85-
if (currentlyReading.length === 0) {
86-
return <NotReadingAnythingText>{getRandomText()}</NotReadingAnythingText>;
87-
}
88-
89-
return (
90-
<>
91-
<MangaList
92-
data={currentlyReading}
93-
renderItem={({ item: manga }: any) => (
94-
<MangaPressable
95-
onLongPress={() => handleRemoveFromReading()}
96-
onPress={() => handleContinueReading(manga)}
97-
>
98-
<MangaImage source={{ uri: manga.image || '' }} />
99-
</MangaPressable>
100-
)}
101-
horizontal
102-
/>
103-
</>
104-
);
105-
}
106-
107-
const MangaImage = styled.Image`
108-
width: ${responsive(150)}px;
109-
height: ${responsive(220)}px;
110-
margin-right: ${responsive(15)}px;
111-
`;
112-
113-
const NotReadingAnythingText = styled.Text`
114-
font-size: ${responsive(15)}px;
115-
font-family: ${({ theme }) => theme.fonts.lightItalic};
116-
color: ${({ theme }) => theme.colors.white};
117-
padding-left: ${responsive(10)}px;
118-
padding-right: ${responsive(20)}px;
119-
margin-top: ${responsive(10)}px;
120-
margin-bottom: ${responsive(20)}px;
121-
text-align: justify;
122-
`;
123-
124-
const MangaPressable = styled.TouchableOpacity``;
125-
126-
const MangaList = styled.FlatList``;
127-
128-
const LoadingContainer = styled.View`
129-
width: ${responsive(150)}px;
130-
height: ${responsive(220)}px;
131-
align-items: center;
132-
justify-content: center;
133-
`;
66+
return {
67+
loading,
68+
currentlyReading,
69+
handleRemoveFromReading,
70+
handleContinueReading,
71+
getRandomText,
72+
};
73+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import responsive from '@/global/utils/responsive';
2+
import styled from 'styled-components/native';
3+
4+
export const MangaImage = styled.Image`
5+
width: ${responsive(150)}px;
6+
height: ${responsive(220)}px;
7+
margin-right: ${responsive(15)}px;
8+
`;
9+
10+
export const NotReadingAnythingText = styled.Text`
11+
font-size: ${responsive(15)}px;
12+
font-family: ${({ theme }) => theme.fonts.lightItalic};
13+
color: ${({ theme }) => theme.colors.white};
14+
padding-left: ${responsive(10)}px;
15+
padding-right: ${responsive(20)}px;
16+
margin-top: ${responsive(10)}px;
17+
margin-bottom: ${responsive(20)}px;
18+
text-align: justify;
19+
`;
20+
21+
export const MangaPressable = styled.TouchableOpacity``;
22+
23+
export const MangaList = styled.FlatList``;
24+
25+
export const LoadingContainer = styled.View`
26+
width: ${responsive(150)}px;
27+
height: ${responsive(220)}px;
28+
align-items: center;
29+
justify-content: center;
30+
`;

0 commit comments

Comments
 (0)