import React, { useState } from 'react'; // import { useTranslate } from '@/sites/assets/locale/taro' // import { ActionSheet, Cell } from '@/packages/nutui.react.rn' import { useTranslate } from '../utils'; import { View, Text } from 'react-native'; import ActionSheet from '.'; import Cell from '../cell'; import { DemoPage, DemoCard } from '../configprovider/styles/demo.page'; export type ItemType = { [key: string]: T }; interface Item { name: string; subname?: string; disable?: boolean; } interface T { '0f87770f': string; 'e23e5e80': string; 'b6102b61': string; 'acc5939e': string; '85dae65b': string; '314631ed': string; '74fc5d8a': string; '84aa6bce': string; '595d7bb3': string; '0a1a6656': string; 'c3a08064': string; 'a4a58638': string; '2cd0f3be': string; 'e1699442': string; 'c3a08065': string; } const ActionSheetDemo = () => { const [translated] = useTranslate({ 'zh-CN': { '0f87770f': '选项一', 'e23e5e80': '选项二', 'b6102b61': '选项三', 'acc5939e': '描述信息', '85dae65b': '着色选项', '314631ed': '禁用选项', '74fc5d8a': '基本用法', '84aa6bce': '基础用法', '595d7bb3': '展示取消按钮', '0a1a6656': '展示描述信息', 'c3a08064': '选项状态', 'a4a58638': '带取消按钮)', '2cd0f3be': '取消', 'e1699442': '这是一段描述信息', 'c3a08065': '自定义内容', }, 'zh-TW': { '0f87770f': '選項一', 'e23e5e80': '選項二', 'b6102b61': '選項三', 'acc5939e': '描述資訊', '85dae65b': '著色選項', '314631ed': '禁用選項', '74fc5d8a': '基本用法', '84aa6bce': '基礎用法', '595d7bb3': '展示取消按鈕', '0a1a6656': '展示描述資訊', 'c3a08064': '選項狀態', 'a4a58638': '帶取消按鈕)', '2cd0f3be': '取消', 'e1699442': '這是一段描述資訊', 'c3a08065': '自定義內容', }, 'en-US': { '0f87770f': 'Option One', 'e23e5e80': 'Option Two', 'b6102b61': 'Option Three', 'acc5939e': 'Description Information', '85dae65b': 'Shading Options', '314631ed': 'Disable Option', '74fc5d8a': 'Basic Usage', '84aa6bce': 'Basic Usage', '595d7bb3': 'Show Cancel Button', '0a1a6656': 'Display Description Information', 'c3a08064': 'Option Status', 'a4a58638': 'with cancel button)', '2cd0f3be': 'Cancel', 'e1699442': 'This is a descriptive message', 'c3a08065': 'Custom content', }, }); const [isVisible1, setIsVisible1] = useState(false); const [isVisible2, setIsVisible2] = useState(false); const [isVisible3, setIsVisible3] = useState(false); const [isVisible4, setIsVisible4] = useState(false); const [isVisible5, setIsVisible5] = useState(false); const [val1, setVal1] = useState(''); const [val2, setVal2] = useState(''); const [val3, setVal3] = useState(''); const menuItemsOne: ItemType[] = [ { name: translated['0f87770f'], }, { name: translated.e23e5e80, }, { name: translated.b6102b61, }, ]; const menuItemsTwo: ItemType[] = [ { name: translated['0f87770f'], }, { name: translated.e23e5e80, }, { name: translated.b6102b61, subname: translated.acc5939e, }, ]; const menuItemsThree: ItemType[] = [ { name: translated['85dae65b'], }, { name: translated['314631ed'], disable: true, }, ]; const chooseItem = (itemParams: any) => { console.log(itemParams.name, 'itemParams'); setVal1(itemParams.name); setIsVisible1(false); }; const chooseItemTwo = (itemParams: Item) => { setVal2(itemParams.name); setIsVisible2(false); }; const chooseItemThree = (itemParams: Item) => { setVal3(itemParams.name); setIsVisible3(false); }; return ( { setIsVisible1(!isVisible1); }} /> setIsVisible2(!isVisible2)} /> setIsVisible3(!isVisible3)} /> setIsVisible4(!isVisible4)} /> setIsVisible5(!isVisible4)} /> {/* demo 基础用法 */} setIsVisible1(false)} /> {/* demo(带取消按钮) */} setIsVisible2(false)} /> {/* 展示描述信息 */} setIsVisible3(false)} /> {/* demo 选项状态 */} { setIsVisible4(false); }} onCancel={() => setIsVisible4(false)} /> { setIsVisible5(false); }} onCancel={() => setIsVisible5(false)} > { 1223 } ); }; export default ActionSheetDemo;