-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
657 additions
and
882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,136 @@ | ||
import React from "react"; | ||
|
||
import { Appbar } from "react-native-paper"; | ||
import React, { useRef } from "react"; | ||
import { View, TextInput, StyleSheet } from "react-native"; | ||
import { | ||
TouchableRipple, | ||
IconButton, | ||
Appbar as MaterialAppbar, | ||
} from "react-native-paper"; | ||
import Constants from "expo-constants"; | ||
|
||
import { useNavigation } from "@react-navigation/native"; | ||
import { useSelector } from "react-redux"; | ||
|
||
export const CustomAppbar = ({ title, onBackAction }) => { | ||
export const Appbar = ({ title, onBackAction }) => { | ||
const theme = useSelector((state) => state.themeReducer.theme); | ||
|
||
return ( | ||
<Appbar.Header style={{ backgroundColor: theme.colorDarkPrimary }}> | ||
{onBackAction && <Appbar.BackAction onPress={onBackAction} />} | ||
<Appbar.Content | ||
<MaterialAppbar.Header style={{ backgroundColor: theme.colorPrimary }}> | ||
{onBackAction && ( | ||
<MaterialAppbar.BackAction onPress={onBackAction} /> | ||
)} | ||
<MaterialAppbar.Content | ||
title={title} | ||
titleStyle={{ color: theme.textColorPrimaryDark }} | ||
titleStyle={{ color: theme.textColorPrimary }} | ||
/> | ||
</Appbar.Header> | ||
</MaterialAppbar.Header> | ||
); | ||
}; | ||
|
||
export const SearchAppbar = ({ | ||
placeholder, | ||
getSearchResults, | ||
setSearchText, | ||
searchText, | ||
getNovels, | ||
setLoading, | ||
screen, | ||
onFilter, | ||
}) => { | ||
const searchRef = useRef(null); | ||
|
||
const navigation = useNavigation(); | ||
|
||
const theme = useSelector((state) => state.themeReducer.theme); | ||
|
||
return ( | ||
<TouchableRipple | ||
borderless | ||
onPress={() => searchRef.current.focus()} | ||
style={[ | ||
styles.searchAppbarContainer, | ||
{ backgroundColor: theme.searchBarColor }, | ||
]} | ||
> | ||
<View | ||
style={{ | ||
flex: 1, | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
}} | ||
> | ||
<View style={{ flex: 1, flexDirection: "row" }}> | ||
<IconButton | ||
icon={screen === "Library" ? "magnify" : "arrow-left"} | ||
color={theme.textColorSecondary} | ||
style={{ marginLeft: 0 }} | ||
size={23} | ||
onPress={() => { | ||
if (screen === "Extension") { | ||
navigation.goBack(); | ||
} | ||
}} | ||
/> | ||
<TextInput | ||
ref={searchRef} | ||
style={{ | ||
fontSize: 16, | ||
color: theme.textColorSecondary, | ||
}} | ||
placeholder={placeholder} | ||
placeholderTextColor={theme.textColorSecondary} | ||
onChangeText={(text) => { | ||
setSearchText(text); | ||
if (screen === "Library") { | ||
getSearchResults(text); | ||
} | ||
}} | ||
onSubmitEditing={() => { | ||
if (screen === "Extension") { | ||
getSearchResults(searchText); | ||
} | ||
}} | ||
defaultValue={searchText} | ||
/> | ||
</View> | ||
{searchText !== "" && ( | ||
<IconButton | ||
icon="close" | ||
color={theme.textColorSecondary} | ||
style={{ marginRight: 0 }} | ||
size={23} | ||
onPress={() => { | ||
setLoading?.(true); | ||
getNovels(); | ||
setSearchText(""); | ||
}} | ||
/> | ||
)} | ||
<IconButton | ||
icon="filter-variant" | ||
color={theme.textColorSecondary} | ||
style={{ marginRight: 0 }} | ||
size={23} | ||
disabled={typeof onFilter === "function" ? false : true} | ||
/** | ||
* TODO | ||
*/ | ||
onPress={() => onFilter?.()} | ||
/> | ||
</View> | ||
</TouchableRipple> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
searchAppbarContainer: { | ||
marginTop: Constants.statusBarHeight + 4, | ||
height: 48, | ||
flexDirection: "row", | ||
alignItems: "center", | ||
paddingHorizontal: 16, | ||
marginBottom: 8, | ||
borderRadius: 8, | ||
marginHorizontal: 12, | ||
elevation: 2, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { GET_EXTENSIONS } from "./types"; | ||
import { fetchExtensionList } from "../../services/api"; | ||
|
||
export const getExtensions = () => async (dispatch) => { | ||
const res = await fetchExtensionList(); | ||
|
||
dispatch({ | ||
type: GET_EXTENSIONS, | ||
payload: res, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { GET_EXTENSIONS } from "../actions/types"; | ||
|
||
const initialState = { | ||
extensions: [], | ||
loading: true, | ||
}; | ||
|
||
const libraryReducer = (state = initialState, action) => { | ||
const { type, payload } = action; | ||
|
||
switch (type) { | ||
case GET_EXTENSIONS: | ||
return { extensions: payload, loading: false }; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default libraryReducer; |
Oops, something went wrong.