Skip to content

Instantly share code, notes, and snippets.

@minhajul-islam
Created November 18, 2019 07:49
Show Gist options
  • Select an option

  • Save minhajul-islam/1eb9c92a7378202b3d64c036c3dd9e43 to your computer and use it in GitHub Desktop.

Select an option

Save minhajul-islam/1eb9c92a7378202b3d64c036c3dd9e43 to your computer and use it in GitHub Desktop.
import {Alert, Share} from 'react-native';
import {NavigationActions, StackActions} from 'react-navigation';
import {ALL_SCREEN} from './Constants';
let moment = require('moment');
const date1 = (text) => {
return moment(text).format('D MMMM YYYY');
};
let shareAp = () => {
Share.share({
message: ' https://play.google.com/store/apps/details?id=com.xxxxxx.bd or https://itunes.apple.com/us/app/xxxxxx-app/id144443088',
url: 'https://play.google.com/store/apps/details?id=com.xxxxxx.bd',
title: 'xxxxxx App',
// }, {
// // Android only:
// dialogTitle: 'Share BAM goodness',
// // iOS only:
// excludedActivityTypes: [
// 'com.apple.UIKit.activity.PostToTwitter'
// ]
});
};
let nextPageClearPrevious = (props, screen) => {
const {navigation} = props;
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({routeName: screen})], // back_to="A"
});
navigation.dispatch(resetAction);
};
let nextPageWithDataClearPrevious = (props, screen, data) => {
const {navigation} = props;
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({routeName: screen, params: data})], // back_to="A"
});
navigation.dispatch(resetAction);
};
let nextPageWithDataWithStack1 = (props, data) => {
const {navigation} = props;
const resetAction = StackActions.reset({
index: 2,
actions: [
NavigationActions.navigate({routeName: ALL_SCREEN.DASHBOARD, params: data}),
NavigationActions.navigate({routeName: ALL_SCREEN.SEND_MONEY, params: data}),
NavigationActions.navigate({routeName: ALL_SCREEN.PREVIEW_TRANSFER, params: data}),
], // back_to="A"
});
navigation.dispatch(resetAction);
};
let nextDocId = (docState, docList) => {
let i;
for (i = docState; i < docList.length; i++) {
if (docList[i].docs == null) {
return i;
}
}
return docList.length;
};
let sycTimeCheck = (dateTime) => {
if(dateTime==='')
return true;
var now = moment(new Date()); //todays date
var end = moment(dateTime); // another date
var duration = moment.duration(now.diff(end));
var asSeconds = duration.asSeconds();
return asSeconds>(180);
};
const UtilFunction = {
date1, shareAp, nextPageClearPrevious, nextPageWithDataClearPrevious, nextDocId, nextPageWithDataWithStack1,sycTimeCheck
};
export default UtilFunction;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment