Skip to content

Commit e3ca6fc

Browse files
committed
WIP Account related
1 parent e169e69 commit e3ca6fc

Some content is hidden

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

48 files changed

+872
-341
lines changed

App.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const store = configureStore();
1212

1313
const App: FC = () => {
1414
return (
15-
<Provider store={store}>
15+
<Provider store={ store }>
1616
<Themed>
17-
<StatusBar barStyle={'light-content'} />
18-
<AppNavigator />
17+
<StatusBar barStyle={ 'light-content' }/>
18+
<AppNavigator/>
1919
</Themed>
2020
</Provider>
2121
);

android/app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ android {
138138
}
139139

140140
dependencies {
141+
implementation project(':react-native-webview')
141142
implementation project(':react-native-spinkit')
142143
implementation project(':react-native-linear-gradient')
143144
implementation project(':@react-native-community_async-storage')

android/app/src/main/java/com/moviesrevamped/MainApplication.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.reactnativecommunity.webview.RNCWebViewPackage;
67
import com.react.rnspinkit.RNSpinkitPackage;
78
import com.BV.LinearGradient.LinearGradientPackage;
89
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
@@ -29,6 +30,7 @@ public boolean getUseDeveloperSupport() {
2930
protected List<ReactPackage> getPackages() {
3031
return Arrays.<ReactPackage>asList(
3132
new MainReactPackage(),
33+
new RNCWebViewPackage(),
3234
new RNSpinkitPackage(),
3335
new LinearGradientPackage(),
3436
new AsyncStoragePackage(),

android/settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'MoviesRevamped'
2+
include ':react-native-webview'
3+
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
24
include ':react-native-spinkit'
35
project(':react-native-spinkit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spinkit/android')
46
include ':react-native-linear-gradient'

ios/MoviesRevamped.xcodeproj/project.pbxproj

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1110
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -47,6 +46,7 @@
4746
ED200521426141278155DEC0 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 844C02EB72FD4CF68C888230 /* libRNVectorIcons.a */; };
4847
ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
4948
FDB03A9DBC5D49228E8DB2DC /* AntDesign.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7D1D4513C9EF44C189655CAF /* AntDesign.ttf */; };
49+
0CEDE9EC97C14677A9543812 /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45DD52A2F69D4E79A56C15AE /* libRNCWebView.a */; };
5050
/* End PBXBuildFile section */
5151

5252
/* Begin PBXContainerItemProxy section */
@@ -444,6 +444,8 @@
444444
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
445445
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
446446
FDA6887DFA214861BC2E41FA /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
447+
C2DD50AC00DC46FA94AE70A4 /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; name = "RNCWebView.xcodeproj"; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
448+
45DD52A2F69D4E79A56C15AE /* libRNCWebView.a */ = {isa = PBXFileReference; name = "libRNCWebView.a"; path = "libRNCWebView.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
447449
/* End PBXFileReference section */
448450

449451
/* Begin PBXFrameworksBuildPhase section */
@@ -478,6 +480,7 @@
478480
BF1CD381BAC94F9690DB88FE /* libRNCAsyncStorage.a in Frameworks */,
479481
0DAFCA47BCAA441B9A299D1A /* libBVLinearGradient.a in Frameworks */,
480482
188D03BE530846CD94DB515D /* libRNSpinkit.a in Frameworks */,
483+
0CEDE9EC97C14677A9543812 /* libRNCWebView.a in Frameworks */,
481484
);
482485
runOnlyForDeploymentPostprocessing = 0;
483486
};
@@ -716,6 +719,7 @@
716719
8B07DED0DAEB4D16B0EF42DB /* RNCAsyncStorage.xcodeproj */,
717720
A22F48750B9B40DBAC9E954F /* BVLinearGradient.xcodeproj */,
718721
C5FB75E28F3E46B1AE625D81 /* RNSpinkit.xcodeproj */,
722+
C2DD50AC00DC46FA94AE70A4 /* RNCWebView.xcodeproj */,
719723
);
720724
name = Libraries;
721725
sourceTree = "<group>";
@@ -1379,11 +1383,15 @@
13791383
"$(SRCROOT)/../node_modules/@react-native-community/async-storage/ios",
13801384
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
13811385
"$(SRCROOT)/../node_modules/react-native-spinkit/ios/**",
1386+
"$(SRCROOT)/../node_modules/react-native-webview/ios",
13821387
);
13831388
INFOPLIST_FILE = MoviesRevampedTests/Info.plist;
13841389
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
13851390
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1386-
LIBRARY_SEARCH_PATHS = "$(inherited)";
1391+
LIBRARY_SEARCH_PATHS = (
1392+
"$(inherited)",
1393+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1394+
);
13871395
OTHER_LDFLAGS = (
13881396
"-ObjC",
13891397
"-lc++",
@@ -1408,11 +1416,15 @@
14081416
"$(SRCROOT)/../node_modules/@react-native-community/async-storage/ios",
14091417
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
14101418
"$(SRCROOT)/../node_modules/react-native-spinkit/ios/**",
1419+
"$(SRCROOT)/../node_modules/react-native-webview/ios",
14111420
);
14121421
INFOPLIST_FILE = MoviesRevampedTests/Info.plist;
14131422
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
14141423
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1415-
LIBRARY_SEARCH_PATHS = "$(inherited)";
1424+
LIBRARY_SEARCH_PATHS = (
1425+
"$(inherited)",
1426+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1427+
);
14161428
OTHER_LDFLAGS = (
14171429
"-ObjC",
14181430
"-lc++",
@@ -1440,6 +1452,7 @@
14401452
"$(SRCROOT)/../node_modules/@react-native-community/async-storage/ios",
14411453
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
14421454
"$(SRCROOT)/../node_modules/react-native-spinkit/ios/**",
1455+
"$(SRCROOT)/../node_modules/react-native-webview/ios",
14431456
);
14441457
INFOPLIST_FILE = MoviesRevamped/Info.plist;
14451458
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -1471,6 +1484,7 @@
14711484
"$(SRCROOT)/../node_modules/@react-native-community/async-storage/ios",
14721485
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
14731486
"$(SRCROOT)/../node_modules/react-native-spinkit/ios/**",
1487+
"$(SRCROOT)/../node_modules/react-native-webview/ios",
14741488
);
14751489
INFOPLIST_FILE = MoviesRevamped/Info.plist;
14761490
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-native-spinkit": "^1.3.0",
2222
"react-native-star-rating": "^1.1.0",
2323
"react-native-vector-icons": "^6.4.2",
24+
"react-native-webview": "^5.12.0",
2425
"react-navigation": "^3.11.0",
2526
"react-redux": "^7.0.3",
2627
"redux": "^4.0.1",

src/api/Account.ts

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
import { getUrl, client } from './Axios';
2-
import { Account, Movie, WatchlistParams, FavoriteParams } from './Models';
2+
import { Account, WatchlistParams, FavoriteParams, AccountMediaType } from './Models';
33

44
type AccountActionResponse = { status_code: number; status_message: string };
55

6-
const getSessionIdParams = (sessionId: string) => `session_id=${sessionId}`;
6+
const getSessionIdParams = (sessionId: string) => `session_id=${ sessionId }`;
77

88
export const getAccountDetail = async (sessionId: string) => {
99
const url = getUrl('account', getSessionIdParams(sessionId));
1010
const response = await client.get<Account>(url);
1111
return response.data;
1212
};
1313

14-
export const getAccountMovies = async (
14+
// TODO: Strongly type
15+
export const getCreatedList = async (accountId: number, sessionId: string, page: number = 1) => {
16+
const url = getUrl(`account/${ accountId }/lists`, getSessionIdParams(sessionId), `page=${ page }`);
17+
const response = await client.get(url);
18+
return response.data;
19+
};
20+
21+
export const getAccountMedias = async <T>(
1522
accountId: number,
1623
sessionId: string,
17-
type: 'favorite' | 'watchlist',
24+
mediaType: 'movies' | 'tv',
25+
type: AccountMediaType,
1826
page: number = 1
1927
) => {
20-
const url = getUrl(`account/${accountId}/${type}/movies`, getSessionIdParams(sessionId), `page=${page}`);
21-
const response = await client.get<{ results: Movie[] }>(url);
28+
const url = getUrl(`account/${ accountId }/${ type }/${ mediaType }`,
29+
getSessionIdParams(sessionId),
30+
`page=${ page }`);
31+
const response = await client.get<{ results: T[] }>(url);
2232
return response.data.results;
2333
};
2434

2535
export const addToWatchList = async (accountId: number, sessionId: string, params: WatchlistParams) => {
26-
const url = getUrl(`account/${accountId}/watchlist`, getSessionIdParams(sessionId));
36+
const url = getUrl(`account/${ accountId }/watchlist`, getSessionIdParams(sessionId));
2737
const response = await client.post<AccountActionResponse>(url, params);
2838
return response.data;
2939
};
3040

3141
export const markFavorite = async (accountId: number, sessionId: string, params: FavoriteParams) => {
32-
const url = getUrl(`account/${accountId}/favorite`, getSessionIdParams(sessionId));
42+
const url = getUrl(`account/${ accountId }/favorite`, getSessionIdParams(sessionId));
3343
const response = await client.post<AccountActionResponse>(url, params);
3444
return response.data;
3545
};

src/api/Models.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ export type ShowEndpointsPath =
33
| Exclude<MovieEndpointsPath, 'now_playing' | 'upcoming'>
44
| 'on_the_air'
55
| 'airing_today';
6+
export type AccountMediaType = 'favorite' | 'watchlist' | 'rated';
67

7-
export enum MovieVideoType {
8+
export enum VideoType {
89
Trailer = 'Trailer',
910
Clip = 'Clip',
1011
BHS = 'Behind the Scenes',
1112
Teaser = 'Teaser'
1213
}
1314

14-
export enum MovieVideoSite {
15+
export enum VideoSite {
1516
Youtube = 'YouTube'
1617
}
1718

@@ -100,6 +101,13 @@ export interface Credits {
100101
crew: Crew[];
101102
}
102103

104+
export interface AccountState {
105+
id: number;
106+
rated: boolean | { value: number };
107+
watchlist: boolean;
108+
favorite: boolean;
109+
}
110+
103111
export interface Movie {
104112
adult: false;
105113
backdrop_path: string;
@@ -294,6 +302,7 @@ export interface Account {
294302
name: string;
295303
include_adult: boolean;
296304
username: string;
305+
avatar_url: string;
297306
}
298307

299308
export class WatchlistParams {

src/api/Movies.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
import { MovieEndpointsPath, Movie, MovieDetail } from './Models';
1+
import { MovieEndpointsPath, Movie, MovieDetail, AccountState } from './Models';
22
import { getUrl, client } from './Axios';
33

44
export const getMovies = async (path: MovieEndpointsPath, page: number = 1) => {
5-
const url = getUrl(`movie/${path}`, `page=${page}`);
5+
const url = getUrl(`movie/${ path }`, `page=${ page }`);
66
const response = await client.get<{ results: Movie[] }>(url);
77
return response.data.results;
88
};
99

1010
export const getMovieById = async (id: number) => {
1111
const url = getUrl(
12-
`movie/${id}`,
12+
`movie/${ id }`,
1313
'append_to_response=videos,images,credits,recommendations',
1414
'include_image_language=en,null'
1515
);
1616
const response = await client.get<MovieDetail>(url);
1717
return response.data;
1818
};
19+
20+
export const getMovieAccountState = async (id: number, sessionId: string) => {
21+
const url = getUrl(`movie/${ id }/account_states`, `session_id=${ sessionId }`);
22+
const response = await client.get<AccountState>(url);
23+
return response.data;
24+
};

src/api/Shows.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ShowEndpointsPath, TvShow, TvShowDetail } from './Models';
1+
import { AccountState, ShowEndpointsPath, TvShow, TvShowDetail } from './Models';
22
import { getUrl, client } from './Axios';
33

44
export const getShows = async (path: ShowEndpointsPath, page: number = 1) => {
@@ -16,3 +16,9 @@ export const getShowByid = async (id: number) => {
1616
const response = await client.get<TvShowDetail>(url);
1717
return response.data;
1818
};
19+
20+
export const getShowAccountStates = async (id: number, sessionId: string) => {
21+
const url = getUrl(`tv/${ id }/account_states`, `session_id=${ sessionId }`);
22+
const response = await client.get<AccountState>(url);
23+
return response.data;
24+
};

src/api/Storage.ts

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export const setSessionid = async (sessionId: string) => {
99
export const getSessionId = async () => {
1010
return AsyncStorage.getItem(sessionStorageKey);
1111
};
12+
13+
export const clearStorage = async () => {
14+
await AsyncStorage.clear();
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { AccountLandingScreenProps } from '@screens/AccountLanding/AccountLandingScreen';
2+
import { colors } from '@styles/Colors';
3+
import CenterView from '@ui/CenterView';
4+
import { StackScreenComponent } from '@utils/types';
5+
import React, { useEffect } from 'react';
6+
import { Text } from 'react-native-elements';
7+
import Spinner from 'react-native-spinkit';
8+
9+
const AccountLanding: StackScreenComponent<AccountLandingScreenProps> = (
10+
{
11+
isLoading,
12+
isLoadingSession,
13+
isAccountFetched,
14+
getAccountDetail,
15+
navigation
16+
}) => {
17+
18+
useEffect(() => {
19+
if (!isLoadingSession && !isAccountFetched) {
20+
getAccountDetail();
21+
} else if (isAccountFetched) {
22+
navigation.navigate('MainTab');
23+
}
24+
}, [isLoadingSession, isAccountFetched]);
25+
26+
return (
27+
<CenterView>
28+
<Spinner isVisible={ true } color={ colors.primary }/>
29+
<Text style={ { fontSize: 12, color: colors.secondary } }>
30+
{ isLoadingSession ? 'Loading session...' : 'Loading account...' }
31+
</Text>
32+
</CenterView>
33+
);
34+
};
35+
36+
export default AccountLanding;

0 commit comments

Comments
 (0)