Skip to content

Commit

Permalink
Merge pull request #90 from pct-org/feature/improvements
Browse files Browse the repository at this point in the history
Feature/improvements
  • Loading branch information
TriPSs authored Oct 14, 2020
2 parents ce51d13 + d4b9298 commit e062eac
Show file tree
Hide file tree
Showing 26 changed files with 291 additions and 337 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js",
enableHermes: false
enableHermes: true
]

apply from: "../../node_modules/react-native/react.gradle"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.google.gms:google-services:4.3.2'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion app/mobile/components/ItemOptions/ItemOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const ItemOptions = ({
disabled
icon={'content-copy'}
label={i18n.t('Copy to phone')}
subLabel={'Item needs to be downloaded for this to become available'} />
labelLine2={'Item needs to be downloaded for this to become available'} />
</OptionsGroup>
</>
)}
Expand Down
54 changes: 35 additions & 19 deletions app/mobile/components/OptionsItem/OptionsItemInner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ export const styles = StyleSheet.create({
marginRight: dimensions.UNIT,
},

labels: {
labelsContainer: {
flex: 1,
},

label: {},

subLabels: {
labels: {
flexDirection: 'row',
},

})

export const SettingsItem = ({ label, subLabel, subLabelLine2, icon, disabled, loading, downloading }) => {
export const SettingsItem = ({ label, labelLine2, subLabel, subLabelLine2, icon, disabled, loading, downloading }) => {
return (
<>
{loading && (
Expand Down Expand Up @@ -73,21 +71,39 @@ export const SettingsItem = ({ label, subLabel, subLabelLine2, icon, disabled, l
} />
)}

<View style={styles.labels}>
<Typography
emphasis={
disabled
? 'low'
: 'high'
}
style={styles.label}
variant={'overline'}>
{label}
</Typography>
<View style={styles.labelsContainer}>
{(label || subLabel) && (
<View style={styles.labels}>
<Typography
style={{
flex: 1,
}}
emphasis={
disabled
? 'low'
: 'high'
}
variant={'overline'}>
{label}
</Typography>

{(subLabel || subLabelLine2) && (
<View style={styles.subLabels}>
{subLabel && (
<Typography
emphasis={
disabled
? 'low'
: 'medium'
}
variant={'captionSmall'}>
{subLabel}
</Typography>
)}
</View>
)}

{(labelLine2 || subLabelLine2) && (
<View style={styles.labels}>
{labelLine2 && (
<Typography
style={{
flex: 1,
Expand All @@ -98,7 +114,7 @@ export const SettingsItem = ({ label, subLabel, subLabelLine2, icon, disabled, l
: 'medium'
}
variant={'captionSmall'}>
{subLabel}
{labelLine2}
</Typography>
)}

Expand Down
14 changes: 12 additions & 2 deletions app/mobile/components/OptionsItemTorrent/OptionsItemTorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,23 @@ export const OptionsItemTorrent = ({
return !(download.torrentType === torrent.type && download.quality === torrent.quality)
}, [download, disabled])

const itemSubLabel = React.useMemo(() => {
const labelLine2 = React.useMemo(() => {
if (!isItemDisabled && download?.status === constants.STATUS_DOWNLOADING) {
return download.timeRemaining
}

return `${torrent.provider} - ${torrent.sizeString}`
}, [download, isItemDisabled])

const subLabel = React.useMemo(() => {
if (!isItemDisabled && download?.status === constants.STATUS_DOWNLOADING) {
return `${download.numPeers} peer${download.numPeers > 1 ? 's' : ''}`
}

return null

}, [download, isItemDisabled])

const subLabelLine2 = React.useMemo(() => {
if (!isItemDisabled && download?.status === constants.STATUS_DOWNLOADING) {
return `${download.progress}% / ${download.speed}`
Expand Down Expand Up @@ -96,7 +105,8 @@ export const OptionsItemTorrent = ({
].includes(download.status)
}
label={torrent.quality}
subLabel={itemSubLabel}
labelLine2={labelLine2}
subLabel={subLabel}
subLabelLine2={subLabelLine2}
onPress={handleOnTorrentClick()}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/mobile/screens/Home/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const styles = StyleSheet.create({
})

export const Home = ({ navigation }) => {
const { data: moviesData, fetchMore: moviesFetchMore } = useQuery(
const { data: moviesData, fetchMore: moviesFetchMore} = useQuery(
MoviesQuery,
{
variables: {
Expand Down
45 changes: 31 additions & 14 deletions app/mobile/screens/Mode/ModeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { getDefaultHeaderHeight } from 'react-navigation-collapsible/lib/src/uti
import i18n from 'modules/i18n'
import colors from 'modules/colors'
import dimensions from 'modules/dimensions'
import constants from 'modules/constants'
import useBackButton from 'modules/hooks/useBackButton'
import { MoviesModeQuery } from 'modules/GraphQL/MoviesGraphQL'
import ShowsQuery from 'modules/GraphQL/ShowsGraphQL'
import BookmarksQuery from 'modules/GraphQL/BookmarksGraphQL'
import { ShowsModeQuery } from 'modules/GraphQL/ShowsGraphQL'
import { BookmarksModeQuery } from 'modules/GraphQL/BookmarksGraphQL'
import fetchMoreUpdateQuery from 'modules/GraphQL/helpers/fetchMoreUpdateQuery'

import Card from 'components/Card'
Expand Down Expand Up @@ -39,33 +40,45 @@ const styles = StyleSheet.create({
},
})

export const getQuery = (mode) => {
export const useMode = (mode) => React.useMemo(() => {
switch (mode) {
case 'movies':
case constants.MODE_MOVIES:
return MoviesModeQuery
case 'shows':
return ShowsQuery
case 'bookmarks':
return BookmarksQuery

case constants.MODE_SHOWS:
return ShowsModeQuery

case constants.MODE_BOOKMARKS:
return BookmarksModeQuery

default:
return null
}
}
}, [mode])

export const Mode = ({ mode, navigation }) => {
const flatListRef = useRef(null)
const [query, setQuery] = useState(null)
const modeQuery = useMode(mode)
const [sort, setSorting] = useState(undefined)
const [filter, setFilter] = useState(undefined)
const [query, setQuery] = useState(undefined)

const [executeQuery, { loading, data, fetchMore }] = useLazyQuery(
getQuery(mode),
modeQuery,
{
variables: {
offset: 0,
query,
sort,
filter,
},
},
)

useBackButton(() => {
if (query?.trim()?.length > 0 && navigation.isFocused()) {
if ((query?.trim()?.length > 0 || filter) && navigation.isFocused()) {
setQuery(null)
setFilter(undefined)

return true
}
Expand Down Expand Up @@ -134,7 +147,7 @@ export const Mode = ({ mode, navigation }) => {
ListEmptyComponent={renderNothingFound}
ListHeaderComponent={() => (
<View style={{
marginTop: 50 + dimensions.STATUSBAR_HEIGHT + dimensions.UNIT,
marginTop: dimensions.STATUSBAR_HEIGHT + +dimensions.SEARCH_BAR_HEIGHT + dimensions.UNIT,
}} />
)}
ListFooterComponent={() => <View style={{ width: dimensions.UNIT * 2 }} />}
Expand All @@ -157,7 +170,11 @@ export const Mode = ({ mode, navigation }) => {
<SearchBar
flatListRef={flatListRef}
searchedQuery={query}
search={setQuery} />
search={setQuery}
mode={mode}
setSorting={setSorting}
setFilter={setFilter}
/>

</View>
)
Expand Down
Loading

0 comments on commit e062eac

Please sign in to comment.