Merge pull request #1969 from ecency/nt/deep-link

Nt/deep link
This commit is contained in:
Feruz M 2021-06-11 16:29:11 +03:00 committed by GitHub
commit b8be0310fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 112 additions and 21 deletions

View File

@ -4,14 +4,15 @@
<dict> <dict>
<key>aps-environment</key> <key>aps-environment</key>
<string>development</string> <string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:ecency.com</string>
<string>applinks:ecency.page.link</string>
<string>applinks:alpha.ecency.com</string>
</array>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>
<string>group.com.ecency.eshare</string> <string>group.com.ecency.eshare</string>
</array> </array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:ecency.com</string>
<string>applinks:ecency.page.link</string>
</array>
</dict> </dict>
</plist> </plist>

View File

@ -170,6 +170,7 @@ class ProfileView extends PureComponent {
const { currencyRate, currencySymbol, selectedUser } = this.props; const { currencyRate, currencySymbol, selectedUser } = this.props;
const { isSummaryOpen, estimatedWalletValue } = this.state; const { isSummaryOpen, estimatedWalletValue } = this.state;
return ( return (
<View <View
key="profile.wallet" key="profile.wallet"
@ -200,6 +201,7 @@ class ProfileView extends PureComponent {
isOwnProfile, isOwnProfile,
profileTabs, profileTabs,
ownProfileTabs, ownProfileTabs,
deepLinkFilter,
} = this.props; } = this.props;
const { isSummaryOpen } = this.state; const { isSummaryOpen } = this.state;
@ -207,6 +209,17 @@ class ProfileView extends PureComponent {
const pageType = isOwnProfile ? 'ownProfile' : 'profile'; const pageType = isOwnProfile ? 'ownProfile' : 'profile';
const tabs = (isOwnProfile ? ownProfileTabs : profileTabs) || getDefaultFilters(pageType); const tabs = (isOwnProfile ? ownProfileTabs : profileTabs) || getDefaultFilters(pageType);
//set initial tab based on deep link filter if available
let selectedIndex = 0;
if (deepLinkFilter) {
selectedIndex = tabs.indexOf((val) => val === deepLinkFilter);
if (selectedIndex < 0) {
tabs.pop();
tabs.push(deepLinkFilter);
selectedIndex = 2;
}
}
const filterOptions = tabs.map((key) => getFilterMap(pageType)[key]); const filterOptions = tabs.map((key) => getFilterMap(pageType)[key]);
//compile content overrides //compile content overrides
@ -222,7 +235,7 @@ class ProfileView extends PureComponent {
key={username + JSON.stringify(filterOptions)} key={username + JSON.stringify(filterOptions)}
filterOptions={filterOptions} filterOptions={filterOptions}
filterOptionsValue={tabs} filterOptionsValue={tabs}
selectedOptionIndex={0} selectedOptionIndex={selectedIndex}
pageType={pageType} pageType={pageType}
getFor="blog" getFor="blog"
feedUsername={username} feedUsername={username}

View File

@ -31,6 +31,7 @@ export default {
COMMUNITY: `Community${SCREEN_SUFFIX}`, COMMUNITY: `Community${SCREEN_SUFFIX}`,
COMMUNITIES: `Communities${SCREEN_SUFFIX}`, COMMUNITIES: `Communities${SCREEN_SUFFIX}`,
YOUTUBE: `YouTube${SCREEN_SUFFIX}`, YOUTUBE: `YouTube${SCREEN_SUFFIX}`,
WEB_BROWSER: `WebBrowser${SCREEN_SUFFIX}`,
}, },
DRAWER: { DRAWER: {
MAIN: `Main${DRAWER_SUFFIX}`, MAIN: `Main${DRAWER_SUFFIX}`,

View File

@ -56,6 +56,7 @@ class ProfileContainer extends Component {
name: get(props, 'navigation.state.params.username', ''), name: get(props, 'navigation.state.params.username', ''),
}, },
reverseHeader: !!username, reverseHeader: !!username,
deepLinkFilter: get(props, 'navigation.state.params.deepLinkFilter'),
}; };
} }
@ -68,6 +69,7 @@ class ProfileContainer extends Component {
currentAccount: { name: currentAccountUsername }, currentAccount: { name: currentAccountUsername },
} = this.props; } = this.props;
const username = get(navigation, 'state.params.username'); const username = get(navigation, 'state.params.username');
const { isOwnProfile } = this.state; const { isOwnProfile } = this.state;
let targetUsername = currentAccountUsername; let targetUsername = currentAccountUsername;
@ -436,6 +438,7 @@ class ProfileContainer extends Component {
user, user,
username, username,
reverseHeader, reverseHeader,
deepLinkFilter,
} = this.state; } = this.state;
const { currency, isDarkTheme, isLoggedIn, navigation, children, isHideImage } = this.props; const { currency, isDarkTheme, isLoggedIn, navigation, children, isHideImage } = this.props;
const activePage = get(navigation.state.params, 'state', 0); const activePage = get(navigation.state.params, 'state', 0);
@ -486,6 +489,7 @@ class ProfileContainer extends Component {
selectedUser: user, selectedUser: user,
username, username,
reverseHeader, reverseHeader,
deepLinkFilter,
}) })
); );
} }

View File

@ -38,6 +38,7 @@ import {
TagResult, TagResult,
Community, Community,
Communities, Communities,
WebBrowser,
} from '../screens'; } from '../screens';
import YoutubePlayer from '../screens/youtube/youtubePlayer'; import YoutubePlayer from '../screens/youtube/youtubePlayer';
@ -152,6 +153,7 @@ const stackNavigator = createStackNavigator(
[ROUTES.SCREENS.COMMUNITY]: { screen: Community }, [ROUTES.SCREENS.COMMUNITY]: { screen: Community },
[ROUTES.SCREENS.COMMUNITIES]: { screen: Communities }, [ROUTES.SCREENS.COMMUNITIES]: { screen: Communities },
[ROUTES.SCREENS.YOUTUBE]: { screen: YoutubePlayer }, [ROUTES.SCREENS.YOUTUBE]: { screen: YoutubePlayer },
[ROUTES.SCREENS.WEB_BROWSER]: { screen: WebBrowser },
}, },
{ {
headerMode: 'none', headerMode: 'none',

View File

@ -272,29 +272,47 @@ class ApplicationContainer extends Component {
try { try {
if (author) { if (author) {
if (permlink) { if (
!permlink ||
permlink === 'wallet' ||
permlink === 'points' ||
permlink === 'comments' ||
permlink === 'replies' ||
permlink === 'posts'
) {
let deepLinkFilter;
if (permlink) {
deepLinkFilter = permlink === 'points' ? 'wallet' : permlink;
}
profile = await getUser(author);
routeName = ROUTES.SCREENS.PROFILE;
params = {
username: get(profile, 'name'),
reputation: get(profile, 'reputation'),
deepLinkFilter, //TODO: process this in profile screen
};
keey = get(profile, 'name');
} else if (permlink === 'communities') {
routeName = ROUTES.SCREENS.WEB_BROWSER;
params = {
url: url,
};
keey = 'WebBrowser';
} else if (permlink) {
content = await getPost(author, permlink, currentAccount.name); content = await getPost(author, permlink, currentAccount.name);
routeName = ROUTES.SCREENS.POST; routeName = ROUTES.SCREENS.POST;
params = { params = {
content, content,
}; };
keey = `${author}/${permlink}`; keey = `${author}/${permlink}`;
} else {
profile = await getUser(author);
routeName = ROUTES.SCREENS.PROFILE;
params = {
username: get(profile, 'name'),
reputation: get(profile, 'reputation'),
};
keey = get(profile, 'name');
} }
} }
if (feedType) { if (feedType) {
routeName = ROUTES.SCREENS.SEARCH_RESULT; if (!tag) {
keey = 'search'; routeName = ROUTES.SCREENS.TAG_RESULT;
} } else if (/hive-[1-3]\d{4,6}$/.test(tag)) {
if (feedType && tag) {
if (/hive-[1-3]\d{4,6}$/.test(tag)) {
routeName = ROUTES.SCREENS.COMMUNITY; routeName = ROUTES.SCREENS.COMMUNITY;
} else { } else {
routeName = ROUTES.SCREENS.TAG_RESULT; routeName = ROUTES.SCREENS.TAG_RESULT;
@ -303,7 +321,7 @@ class ApplicationContainer extends Component {
tag, tag,
filter: feedType, filter: feedType,
}; };
keey = `${feedType}/${tag}`; keey = `${feedType}/${tag || ''}`;
} }
} catch (error) { } catch (error) {
this._handleAlert('deep_link.no_existing_user'); this._handleAlert('deep_link.no_existing_user');

View File

@ -18,6 +18,7 @@ import ProfileEdit from './profileEdit/screen/profileEditScreen';
import Reblogs from './reblogs'; import Reblogs from './reblogs';
import Redeem from './redeem/screen/redeemScreen'; import Redeem from './redeem/screen/redeemScreen';
import HiveSigner from './steem-connect/hiveSigner'; import HiveSigner from './steem-connect/hiveSigner';
import { WebBrowser } from './webBrowser';
import Transfer from './transfer'; import Transfer from './transfer';
import Voters from './voters'; import Voters from './voters';
import AccountBoost from './accountBoost/screen/accountBoostScreen'; import AccountBoost from './accountBoost/screen/accountBoostScreen';
@ -54,4 +55,5 @@ export {
TagResult, TagResult,
Community, Community,
Communities, Communities,
WebBrowser,
}; };

View File

@ -40,6 +40,7 @@ const ProfileScreen = () => (
username, username,
votingPower, votingPower,
reverseHeader, reverseHeader,
deepLinkFilter,
}) => ( }) => (
<Profile <Profile
about={about} about={about}
@ -76,6 +77,7 @@ const ProfileScreen = () => (
votingPower={votingPower} votingPower={votingPower}
isHideImage={isHideImage} isHideImage={isHideImage}
reverseHeader={reverseHeader} reverseHeader={reverseHeader}
deepLinkFilter={deepLinkFilter}
/> />
)} )}
</ProfileContainer> </ProfileContainer>

View File

@ -0,0 +1 @@
export {default as WebBrowser} from './webBrowser';

View File

@ -0,0 +1,47 @@
import React, { PureComponent } from 'react';
import { View, StatusBar } from 'react-native';
import { WebView } from 'react-native-webview';
import { injectIntl } from 'react-intl';
import { withNavigation } from 'react-navigation';
import { SafeAreaView } from 'react-native-safe-area-context';
import { BasicHeader } from '../../components';
class WebBrowser extends PureComponent {
constructor(props) {
super(props);
this.state = {
isLoading: false,
};
}
_onNavigationStateChange = (event) => {
};
render() {
const url = this.props.navigation.getParam('url');
return (
<SafeAreaView style={{ flex: 1 }}>
<StatusBar />
<BasicHeader
title="Ecency"
/>
<WebView
source={{
uri: url,
}}
onNavigationStateChange={this._onNavigationStateChange}
ref={(ref) => {
this.webview = ref;
}}
/>
</SafeAreaView>
);
}
}
export default injectIntl(withNavigation(WebBrowser));