import React, { useRef } from 'react'; import { View, Text } from 'react-native'; import Swipe from '../swipe'; import Button from '../button'; import InputNumber from '../inputnumber'; import { DemoPage, DemoCard } from '../configprovider/styles/demo.page'; import pt from '../utils/pt'; import { useTranslate } from '../utils'; type TSwipeDemo = { title1: string; title2: string; title3: string; title4: string; title5: string; click: string; sure: string; del: string; huadong: string; choose: string; event: string; goods: string; collect: string; open: string; close: string; tips: string; cart: string; leftDel: string; disabled: string; chooseTips: string; deleteTips: string; }; const SwipeDemo = () => { const [translated] = useTranslate({ 'zh-CN': { title1: '基础用法', title2: '禁用滑动', title3: '事件监听', title4: '非同步控制', title5: '自定义內容', click: '点击', sure: '确定', del: '删除', huadong: '滑动', choose: '选择', event: '事件', goods: '商品', collect: '收藏', open: '打开', close: '关闭', tips: '提示', cart: '加入购物车', leftDel: '左滑删除', disabled: '禁用滑动', chooseTips: '确定选择吗?', deleteTips: '确定删除吗?' }, 'zh-TW': { title1: '基礎用法', title2: '禁用滑動', title3: '事件監聽', title4: '非同步控制', title5: '自定義內容', click: '點擊', sure: '確定', del: '刪除', huadong: '滑動', choose: '選擇', event: '事件', goods: '商品', collect: '收藏', open: '打開', close: '關閉', tips: '提示', cart: '加入購物車', leftDel: '左滑刪除', disabled: '禁用滑動', chooseTips: '確定選擇嗎? ', deleteTips: '確定刪除嗎? ' }, 'en-US': { title1: 'Basic usage', title2: 'Disable sliding', title3: 'Event monitoring', title4: 'Asynchronous control', title5: 'Custom content', click: 'click', sure: 'ok', del: 'delete', choose: 'select', event: 'event', goods: 'goods', collect: 'collect', open: 'open', close: 'close', tips: 'tips', cart: 'add to shopping cart', leftDel: 'left slide delete', disabled: 'Disable sliding', chooseTips: 'are you sure to choose?', deleteTips: 'are you sure to delete?' }, 'id-ID': { title1: 'penggunaan dasar', title2: 'Lumpuhkan sliding', title3: 'Monitor waktu', title4: 'kontrol asinkron', title5: 'isi suai', click: 'klik', sure: 'OK', del: 'Hapus', huadong: 'sliding', choose: 'pilih', event: 'peristiwa', goods: 'barang', collect: 'kumpulkan', open: 'buka', close: 'tutup', tips: 'tip', cart: 'tambah ke kereta belanja', leftDel: 'padam slide kiri', disabled: 'Lumpuhkan sliding', chooseTips: 'Apakah kamu benar-benar memilih?', deleteTips: 'Apakah Anda yakin untuk menghapus?' } }); const refDom = useRef(null); const beforeClose = () => { setTimeout(() => { refDom.current && refDom.current.close(); }, 2000); }; return ( {/* 选择 */} {translated.choose} } rightAction={ } > {translated.huadong} {/* 删除 */} {translated.del} } disabled > {/* 禁用滑动 */} {translated.disabled} {/* 选择 */} {translated.choose} } rightAction={ } onActionClick={(e, position) => { alert(e + ' ' + position); }} onOpen={({ name, position }) => { alert(name + ' open ' + position); }} onClose={({ name, position }) => { alert(name + ' close ' + position); }} > {/* 事件 */} {translated.event} {/* 选择 */} {translated.choose} } rightAction={ <> } > {/* 事件 */} {translated.event} } > {/* 商品 */} {translated.goods} ); }; export default SwipeDemo;