From e541dcc381df0d93836d85061113029777e1c63d Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 31 Jan 2020 20:22:02 +0100 Subject: [PATCH] update lite file page --- src/page/liteFile/index.js | 14 ++++------ src/page/liteFile/view.js | 56 ++++++++++++++++++++++++++++++++++++-- src/page/splash/view.js | 9 +++--- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/page/liteFile/index.js b/src/page/liteFile/index.js index dbe2b56..a489bbc 100644 --- a/src/page/liteFile/index.js +++ b/src/page/liteFile/index.js @@ -1,14 +1,10 @@ import { connect } from 'react-redux'; -import { - makeSelectContentPositionForUri, - selectBalance, - from 'lbry-redux'; -import { - doClaimEligiblePurchaseRewards, - makeSelectViewCountForUri, -} from 'lbryinc'; +import { makeSelectContentPositionForUri, selectBalance } from 'lbry-redux'; +import { doClaimEligiblePurchaseRewards, makeSelectViewCountForUri } from 'lbryinc'; +import { doSetPlayerVisible } from 'redux/actions/drawer'; +import { makeSelectPlayerVisible } from 'redux/selectors/drawer'; import { doToggleFullscreenMode } from 'redux/actions/settings'; -import FilePage from './view'; +import LiteFilePage from './view'; const select = (state, props) => { const { uri, fullUri } = props.navigation.state.params; diff --git a/src/page/liteFile/view.js b/src/page/liteFile/view.js index f385981..ede530d 100644 --- a/src/page/liteFile/view.js +++ b/src/page/liteFile/view.js @@ -19,6 +19,7 @@ import { TouchableWithoutFeedback, View, } from 'react-native'; +import UriBar from 'component/uriBar'; import MediaPlayer from 'component/mediaPlayer'; import filePageStyle from 'styles/filePage'; import uriBarStyle from 'styles/uriBar'; @@ -34,12 +35,63 @@ class LiteFilePage extends React.PureComponent { state = { fullscreenMode: false, playerHeight: null, + isLandscape: false, }; - getStreamUrl = uri => {}; + checkOrientation = () => { + if (this.state.fullscreenMode) { + return; + } + + const screenDimension = Dimensions.get('window'); + const screenWidth = screenDimension.width; + const screenHeight = screenDimension.height; + const isLandscape = screenWidth > screenHeight; + this.setState({ isLandscape }); + + if (!this.playerBackground) { + return; + } + + if (isLandscape) { + this.playerBackground.setNativeProps({ + height: screenHeight - StyleSheet.flatten(uriBarStyle.uriContainer).height, + }); + } else if (this.state.playerBgHeight > 0) { + this.playerBackground.setNativeProps({ height: this.state.playerBgHeight }); + } + }; + + handleFullscreenToggle = isFullscreen => { + const { toggleFullscreenMode } = this.props; + toggleFullscreenMode(isFullscreen); + + if (isFullscreen) { + // fullscreen, so change orientation to landscape mode + NativeModules.ScreenOrientation.lockOrientationLandscape(); + + // hide the navigation bar (on devices that have the soft navigation bar) + NativeModules.UtilityModule.hideNavigationBar(); + } else { + // Switch back to portrait mode when the media is not fullscreen + NativeModules.ScreenOrientation.lockOrientationPortrait(); + + // show the navigation bar (on devices that have the soft navigation bar) + NativeModules.UtilityModule.showNavigationBar(); + } + + this.setState({ fullscreenMode: isFullscreen }); + StatusBar.setHidden(isFullscreen); + }; + + getStreamUrl = uri => { + const { claimName, claimId } = parseURI(uri); + return `https://player.lbry.tv/content/claims/${claimName}/${claimId}/stream`; + }; render() { - const { contentUri } = this.props; + const { navigation } = this.props; + const { uri } = navigation.state.params; const playerStyle = [ filePageStyle.player, diff --git a/src/page/splash/view.js b/src/page/splash/view.js index c8ae4be..b9850d2 100644 --- a/src/page/splash/view.js +++ b/src/page/splash/view.js @@ -46,7 +46,6 @@ class SplashScreen extends React.PureComponent { this.setState({ shouldAuthenticate: true }); NativeModules.Firebase.getMessagingToken() .then(firebaseToken => { - console.log(firebaseToken); authenticate(appVersion, Platform.OS, firebaseToken); }) .catch(() => authenticate(appVersion, Platform.OS)); @@ -111,9 +110,10 @@ class SplashScreen extends React.PureComponent { } navigateToLiteMode = () => { + const { navigation } = this.props; const resetAction = StackActions.reset({ index: 0, - actions: [NavigationActions.navigate({ routeName: 'LiteFile', params: { url: this.state.launchUrl } })], + actions: [NavigationActions.navigate({ routeName: 'LiteFile', params: { uri: this.state.launchUrl } })], }); navigation.dispatch(resetAction); }; @@ -168,7 +168,6 @@ class SplashScreen extends React.PureComponent { this.setState({ shouldAuthenticate: true }); NativeModules.Firebase.getMessagingToken() .then(firebaseToken => { - console.log(firebaseToken); authenticate(appVersion, Platform.OS, firebaseToken); }) .catch(() => authenticate(appVersion, Platform.OS)); @@ -287,13 +286,13 @@ class SplashScreen extends React.PureComponent { this.props.fetchRewardedContent(); Linking.getInitialURL().then(url => { if (url) { - this.setState({ launchUrl: url }); + const liteMode = url.indexOf('liteMode=1') > -1; + this.setState({ launchUrl: url, liteMode }); } NativeModules.UtilityModule.getNotificationLaunchTarget().then(target => { if (target) { const liteMode = target.indexOf('liteMode=1') > -1; - android.util.Log.d('setting liteMode=' + liteModoe); this.setState({ launchUrl: target, liteMode }); }