本文整理汇总了TypeScript中react-native.ActionSheetIOS类的典型用法代码示例。如果您正苦于以下问题:TypeScript ActionSheetIOS类的具体用法?TypeScript ActionSheetIOS怎么用?TypeScript ActionSheetIOS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionSheetIOS类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: _actions
_actions(event: any) {
var todoMVC: TodoMVC = this.navigator.activeComponent;
ActionSheetIOS.showActionSheetWithOptions({
title: 'Actions',
options: ['Reset list', 'Empty list', 'Fill list with 100 items', 'Save', 'Load', 'Cancel'],
cancelButtonIndex: 5},
(actionIndex) => {
if (actionIndex == 0 && todoMVC) {
todoMVC.reset();
} else if (actionIndex == 1 && todoMVC) {
todoMVC.empty();
} else if (actionIndex == 2 && todoMVC) {
todoMVC.full();
} else if (actionIndex == 3 && todoMVC) {
todoMVC.save();
} else if (actionIndex == 4 && todoMVC) {
todoMVC.load();
}
}
);
}
开发者ID:darocha,项目名称:react-native-renderer,代码行数:21,代码来源:kitchensink.ts
示例2: openActionSheet
export function openActionSheet(config: IOpenActionSheetConfig) {
if (Platform.OS === 'ios') {
const opts = {} as ActionSheetIOSOptions;
// Map values
opts.options = config.options.map(getOptionValue);
if (config.cancel === true) {
opts.cancelButtonIndex = opts.options.length;
opts.options.push('Cancel');
}
opts.title = config.title;
opts.message = config.message;
opts.tintColor = config.tintColor;
opts.destructiveButtonIndex = config.destructiveButtonIndex;
ActionSheetIOS.showActionSheetWithOptions(
opts,
(index: number) => {
if (config.options.length === index) {
if (typeof config.onCancel === 'function') {
config.onCancel();
}
return;
}
if (typeof config.onSelect === 'function' && config.options.length > index) {
return config.onSelect(config.options[index], index);
}
},
);
}
if (Platform.OS === 'android') {
// Convert options to { id, label }
const items = config.options.map((option: any, index) => ({
id: getOptionKey(option, index),
label: getOptionValue(option),
}));
let type = DialogAndroid.listPlain;
if (config.type === 'radio') {
type = DialogAndroid.listRadio;
}
if (config.type === 'checkbox') {
type = DialogAndroid.listCheckbox;
}
DialogAndroid.showPicker(config.title, config.message, {
type,
items,
neutralIsClear: config.clear ? true : false,
neutralText: config.clear ? 'Clear' : undefined,
negativeText: config.cancel ? 'Cancel' : undefined,
selectedId: config.selectedId,
selectedIds: config.selectedIds,
})
.then(({ selectedItem, selectedItems }: any) => {
if (selectedItem) {
const index = items.findIndex(option => option.id === selectedItem.id);
if (typeof config.onSelect === 'function') {
return config.onSelect(config.options[index], index);
}
} else if (selectedItems) {
if (typeof config.onMultiSelect === 'function') {
return config.onMultiSelect(selectedItems);
}
} else if (typeof config.onCancel === 'function') {
return config.onCancel();
}
});
}
}
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:75,代码来源:openActionSheet.ts
注:本文中的react-native.ActionSheetIOS类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论