-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from farzin-fs/refactor
refactor: ♻️ improvements
- Loading branch information
Showing
62 changed files
with
650 additions
and
383 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,7 +1,7 @@ | ||
module.exports = { | ||
arrowParens: 'avoid', | ||
bracketSameLine: true, | ||
bracketSpacing: false, | ||
bracketSpacing: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}; |
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,4 +1,4 @@ | ||
{ | ||
"name": "animex", | ||
"displayName": "animex" | ||
} | ||
} |
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,6 +1,6 @@ | ||
import {AppRegistry} from 'react-native'; | ||
import { AppRegistry } from 'react-native'; | ||
import App from './src/App'; | ||
import {name as appName} from './app.json'; | ||
import { name as appName } from './app.json'; | ||
import 'react-native-gesture-handler'; | ||
|
||
AppRegistry.registerComponent(appName, () => App); |
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
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 |
---|---|---|
@@ -1,40 +1,55 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components/native'; | ||
import {TAnime} from '../types'; | ||
import { useWindowDimensions, View } from 'react-native'; | ||
import styled from '../themes'; | ||
import { TAnime } from '../types'; | ||
import CoverImage from './CoverImage'; | ||
import Divider from './Divider'; | ||
import Spacer from './Spacer'; | ||
import TextPrimary from './TextPrimary'; | ||
import TextSecondary from './TextSecondary'; | ||
|
||
const Container = styled.View` | ||
const Container = styled(View)<{ dir: string }>` | ||
flex-direction: ${({ dir }) => dir}; | ||
`; | ||
|
||
const DetailsContainer = styled(View)` | ||
flex: 1; | ||
padding: 12px; | ||
`; | ||
|
||
type TProps = { | ||
data: TAnime; | ||
}; | ||
|
||
const AnimeDetails: React.FC<TProps> = ({data}) => ( | ||
<> | ||
<CoverImage uri={data.images.jpg.large_image_url} /> | ||
<Container> | ||
<TextPrimary>{data.title}</TextPrimary> | ||
<TextSecondary>{data.title_japanese}</TextSecondary> | ||
<Spacer /> | ||
<TextSecondary>{data.background}</TextSecondary> | ||
<Spacer /> | ||
<Divider /> | ||
<Spacer /> | ||
<TextSecondary>Year: {data.year}</TextSecondary> | ||
<TextSecondary>Status: {data.status}</TextSecondary> | ||
<TextSecondary>Score: {data.score}</TextSecondary> | ||
<TextSecondary>Rating: {data.rating}</TextSecondary> | ||
<TextSecondary>Type: {data.type}</TextSecondary> | ||
<TextSecondary>Episodes: {data.episodes}</TextSecondary> | ||
<Spacer /> | ||
const AnimeDetails: React.FC<TProps> = ({ data }) => { | ||
const window = useWindowDimensions(); | ||
|
||
return ( | ||
<Container dir={window.width <= 900 ? 'column' : 'row'}> | ||
<CoverImage | ||
uri={data.images.jpg.large_image_url} | ||
initialWidth={window.width <= 900 ? window.width : window.width / 3} | ||
/> | ||
<DetailsContainer> | ||
<TextPrimary>{data.title}</TextPrimary> | ||
<TextSecondary>{data.title_japanese}</TextSecondary> | ||
<Spacer /> | ||
{data.background && <TextSecondary>{data.background}</TextSecondary>} | ||
{data.background && <Spacer />} | ||
<Divider /> | ||
<Spacer /> | ||
{data.year && <TextSecondary>Year: {data.year}</TextSecondary>} | ||
{data.status && <TextSecondary>Status: {data.status}</TextSecondary>} | ||
{data.score && <TextSecondary>Score: {data.score}</TextSecondary>} | ||
{data.rating && <TextSecondary>Rating: {data.rating}</TextSecondary>} | ||
{data.type && <TextSecondary>Type: {data.type}</TextSecondary>} | ||
{data.episodes && ( | ||
<TextSecondary>Episodes: {data.episodes}</TextSecondary> | ||
)} | ||
<Spacer /> | ||
</DetailsContainer> | ||
</Container> | ||
</> | ||
); | ||
); | ||
}; | ||
|
||
export default AnimeDetails; |
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 |
---|---|---|
@@ -1,18 +1,33 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components/native'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { Image } from 'react-native'; | ||
import styled from '../themes'; | ||
|
||
const Cover = styled.Image` | ||
width: 100%; | ||
height: 600px; | ||
background-color: ${({theme}) => theme.colors.textSecondary}; | ||
const Cover = styled(Image)` | ||
background-color: ${({ theme }) => theme.colors.textSecondary}; | ||
`; | ||
|
||
type TProps = { | ||
uri?: string; | ||
initialWidth: number; | ||
}; | ||
|
||
const CoverImage: React.FC<TProps> = ({uri}) => ( | ||
<Cover source={{uri: uri}} resizeMode="cover" /> | ||
); | ||
const CoverImage: React.FC<TProps> = ({ uri, initialWidth = 300 }) => { | ||
const [size, setSize] = useState({ | ||
width: initialWidth, | ||
height: initialWidth * 1.5, | ||
}); | ||
|
||
useEffect(() => { | ||
if (uri) { | ||
Image.getSize(uri, (width, height) => { | ||
const ratio = Math.abs(height / width); | ||
|
||
setSize({ width: size.width, height: size.width * ratio }); | ||
}); | ||
} | ||
}, [uri, size]); | ||
|
||
return <Cover source={{ uri: uri }} resizeMode="cover" style={size} />; | ||
}; | ||
|
||
export default CoverImage; |
Oops, something went wrong.