-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useclipboard & useroute): add useClipboardData and useRouter, ad…
…d tabbar about
- Loading branch information
Showing
26 changed files
with
662 additions
and
2 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
export default { | ||
navigationBarTitleText: 'Taro-hooks', | ||
enableShareAppMessage: true, | ||
}; |
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,6 @@ | ||
.start-button { | ||
position: fixed; | ||
right: 32px; | ||
bottom: 32px; | ||
z-index: 1100; | ||
} |
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,54 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { AtIcon, AtToast, AtFab } from 'taro-ui'; | ||
import { Image, View } from '@tarojs/components'; | ||
|
||
import { useClipboardData } from 'taro-hooks'; | ||
|
||
import 'taro-ui/dist/style/components/article.scss'; | ||
import './index.less'; | ||
import '../index/index.less'; | ||
|
||
import logoImg from '../../../../../public/image/hook.png'; | ||
|
||
const git = 'https://github.com/innocces/taro-hooks'; | ||
|
||
const Index = () => { | ||
const [visible, changeVisible] = useState(false); | ||
const [clipboardData, { set }] = useClipboardData(); | ||
|
||
const handleStart = useCallback(() => { | ||
set(git).then(() => { | ||
changeVisible(true); | ||
}); | ||
}, [set]); | ||
|
||
return ( | ||
<View className="page page-index"> | ||
<AtToast | ||
isOpened={visible} | ||
text="复制成功, 请打开浏览器进行访问" | ||
hasMask | ||
icon="heart" | ||
onClose={() => changeVisible(false)} | ||
/> | ||
<View className="logo"> | ||
<Image src={logoImg} className="img" mode="widthFix" /> | ||
</View> | ||
<View className="at-article"> | ||
<View className="at-article__h2" style={{ marginBottom: '20rpx' }}> | ||
简介 | ||
</View> | ||
<View className="at-article__info">作者: 阿酱</View> | ||
<View className="at-article__p">为Taro而设计的Hooks Library</View> | ||
<View className="at-article__p"> | ||
请点击下方按钮前往github给予一枚星星✨ | ||
</View> | ||
</View> | ||
<AtFab className="start-button" onClick={handleStart}> | ||
<AtIcon value="star-2" /> | ||
</AtFab> | ||
</View> | ||
); | ||
}; | ||
|
||
export default Index; |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
align-items: center; | ||
padding: 60px; | ||
height: 180px; | ||
box-sizing: border-box; | ||
|
||
&__icon { | ||
display: flex; | ||
|
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,3 @@ | ||
export default { | ||
navigationBarTitleText: 'useClipboardData', | ||
}; |
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,32 @@ | ||
import React, { useCallback } from 'react'; | ||
import { View } from '@tarojs/components'; | ||
import { AtButton } from 'taro-ui'; | ||
import DocPage from '@components/DocPage'; | ||
|
||
import { useClipboardData } from 'taro-hooks'; | ||
import { showModal } from '@tarojs/taro'; | ||
|
||
export default () => { | ||
const [clipboardData, { set, get }] = useClipboardData(); | ||
|
||
const getClipboardData = useCallback(() => { | ||
get().then((data: any) => { | ||
showModal({ content: data, title: '当前剪贴板内容' }); | ||
}); | ||
}, [get]); | ||
|
||
return ( | ||
<> | ||
<DocPage title="useClipboardData 剪贴板" panelTitle="useClipboardData"> | ||
<View>当前剪贴板内容: {clipboardData}</View> | ||
<AtButton | ||
customStyle={{ margin: '10px 0' }} | ||
onClick={() => set('taro hooks nice!')} | ||
> | ||
设置剪贴板 | ||
</AtButton> | ||
<AtButton onClick={getClipboardData}>获取剪贴板</AtButton> | ||
</DocPage> | ||
</> | ||
); | ||
}; |
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,3 @@ | ||
export default { | ||
navigationBarTitleText: 'usePromise', | ||
}; |
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,38 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { View } from '@tarojs/components'; | ||
import DocPage from '@components/DocPage'; | ||
|
||
import { usePromise } from 'taro-hooks'; | ||
import Taro, { General } from '@tarojs/taro'; | ||
|
||
export default () => { | ||
const makePhoneCallPromise = usePromise( | ||
{ phoneNumber: '132111' }, | ||
'makePhoneCall', | ||
); | ||
|
||
useEffect(() => { | ||
makePhoneCallPromise | ||
.then((res: General.CallbackResult) => { | ||
Taro.showModal({ | ||
content: '拨号成功', | ||
}); | ||
}) | ||
.catch((e: any) => { | ||
Taro.showModal({ | ||
content: e.errMsg, | ||
}); | ||
}) | ||
.finally((res: General.CallbackResult) => { | ||
console.log(res); | ||
}); | ||
}, [makePhoneCallPromise]); | ||
|
||
return ( | ||
<> | ||
<DocPage title="usePromise 异步" panelTitle="usePromise"> | ||
<View>请观察是否吊起通话</View> | ||
</DocPage> | ||
</> | ||
); | ||
}; |
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,3 @@ | ||
export default { | ||
navigationBarTitleText: 'useRouter', | ||
}; |
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,65 @@ | ||
import React from 'react'; | ||
import { AtButton, AtNoticebar, AtCard } from 'taro-ui'; | ||
import DocPage from '@components/DocPage'; | ||
import { View } from '@tarojs/components'; | ||
|
||
import { useRouter, useEnv } from 'taro-hooks'; | ||
import { getSystemInfoSync, ENV_TYPE } from '@tarojs/taro'; | ||
|
||
export default () => { | ||
const env = useEnv(); | ||
const [ | ||
routeInfo, | ||
{ switchTab, relaunch, redirectTo, navigateTo, navigateBack }, | ||
] = useRouter(); | ||
|
||
return ( | ||
<> | ||
<AtNoticebar marquee> | ||
由于文档无路由输出。故移步小程序体验或下载包进行体验。 | ||
</AtNoticebar> | ||
<DocPage title="useRouter 路由" panelTitle="useRouter"> | ||
<AtButton | ||
disabled={env === ENV_TYPE.WEB} | ||
onClick={() => switchTab('/pages/about/index')} | ||
> | ||
跳转TabBar | ||
</AtButton> | ||
<AtButton | ||
disabled={env === ENV_TYPE.WEB} | ||
onClick={() => relaunch('/pages/useRequest/index')} | ||
> | ||
重新打开一个页面 | ||
</AtButton> | ||
<AtButton | ||
disabled={env === ENV_TYPE.WEB} | ||
onClick={() => redirectTo('/pages/useOnline/index')} | ||
> | ||
重定向页面 | ||
</AtButton> | ||
<AtButton | ||
disabled={env === ENV_TYPE.WEB} | ||
onClick={() => | ||
navigateTo('/pages/useLaunchOptions/index', { from: 'useRoute' }) | ||
} | ||
> | ||
跳转页面 | ||
</AtButton> | ||
<AtButton | ||
disabled={env === ENV_TYPE.WEB} | ||
onClick={() => navigateBack()} | ||
> | ||
返回上一页 | ||
</AtButton> | ||
{env !== ENV_TYPE.WEB && ( | ||
<View> | ||
routeInfo: | ||
<View style={{ wordBreak: 'break-all' }}> | ||
{JSON.stringify(routeInfo)} | ||
</View> | ||
</View> | ||
)} | ||
</DocPage> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.