Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Share action on mobile, and fixes some styles (#548)
* Adds Share action on mobile, and fixes some styles * Update styles
- Loading branch information
1 parent
9864e82
commit 62d063d
Showing
8 changed files
with
133 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @flow | ||
import React from 'react' | ||
import { isMobile } from 'mobile-device-detect' | ||
import { useErrorDialog } from '../../../lib/undux/utils/dialog' | ||
import CustomButton from './CustomButton' | ||
import CopyButton from './CopyButton' | ||
|
||
type ShareButtonProps = { | ||
share: any, | ||
onPressDone?: Function, | ||
actionText: string, | ||
buttonProps: any, | ||
} | ||
|
||
const ShareButton = ({ share, onPressDone, actionText, ...buttonProps }: ShareButtonProps) => { | ||
const [showErrorDialog] = useErrorDialog() | ||
|
||
console.info('getPaymentLink', { share }) | ||
const shareAction = async () => { | ||
try { | ||
await navigator.share(share) | ||
} catch (e) { | ||
if (e.name !== 'AbortError') { | ||
showErrorDialog(e) | ||
} | ||
} | ||
} | ||
|
||
if (isMobile && navigator.share) { | ||
return ( | ||
<CustomButton onPress={shareAction} {...buttonProps}> | ||
{actionText} | ||
</CustomButton> | ||
) | ||
} | ||
return ( | ||
<CopyButton toCopy={share.url} onPressDone={onPressDone} {...buttonProps}> | ||
{actionText} | ||
</CopyButton> | ||
) | ||
} | ||
|
||
ShareButton.defaultProps = { | ||
buttonProps: {}, | ||
} | ||
|
||
export default ShareButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters