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>
<key>aps-environment</key>
<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>
<array>
<string>group.com.ecency.eshare</string>
</array>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:ecency.com</string>
<string>applinks:ecency.page.link</string>
</array>
</dict>
</plist>

View File

@ -170,6 +170,7 @@ class ProfileView extends PureComponent {
const { currencyRate, currencySymbol, selectedUser } = this.props;
const { isSummaryOpen, estimatedWalletValue } = this.state;
return (
<View
key="profile.wallet"
@ -200,6 +201,7 @@ class ProfileView extends PureComponent {
isOwnProfile,
profileTabs,
ownProfileTabs,
deepLinkFilter,
} = this.props;
const { isSummaryOpen } = this.state;
@ -207,6 +209,17 @@ class ProfileView extends PureComponent {
const pageType = isOwnProfile ? 'ownProfile' : 'profile';
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]);
//compile content overrides
@ -222,7 +235,7 @@ class ProfileView extends PureComponent {
key={username + JSON.stringify(filterOptions)}
filterOptions={filterOptions}
filterOptionsValue={tabs}
selectedOptionIndex={0}
selectedOptionIndex={selectedIndex}
pageType={pageType}
getFor="blog"
feedUsername={username}

View File

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

View File

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

View File

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

View File

@ -272,29 +272,47 @@ class ApplicationContainer extends Component {
try {
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);
routeName = ROUTES.SCREENS.POST;
params = {
content,
};
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) {
routeName = ROUTES.SCREENS.SEARCH_RESULT;
keey = 'search';
}
if (feedType && tag) {
if (/hive-[1-3]\d{4,6}$/.test(tag)) {
if (!tag) {
routeName = ROUTES.SCREENS.TAG_RESULT;
} else if (/hive-[1-3]\d{4,6}$/.test(tag)) {
routeName = ROUTES.SCREENS.COMMUNITY;
} else {
routeName = ROUTES.SCREENS.TAG_RESULT;
@ -303,7 +321,7 @@ class ApplicationContainer extends Component {
tag,
filter: feedType,
};
keey = `${feedType}/${tag}`;
keey = `${feedType}/${tag || ''}`;
}
} catch (error) {
this._handleAlert('deep_link.no_existing_user');

View File

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

View File

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