Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | import { ComponentProps } from 'react';
import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
import { SymbolViewProps, SymbolWeight } from 'expo-symbols';
import Ionicons from '@expo/vector-icons/Ionicons';
type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof Ionicons>['name']>;
/** 可用的图标名称类型 */
export type SymbolName = keyof typeof MAPPING;
/**
* Add your SF Symbols to Material Icons mappings here.
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
*
* Android兼容性优化说明:
* - 所有映射都使用Ionicons标准图标名称
* - 确保在Android平台上能正常显示
*/
const MAPPING = {
// ==================== 底部Tabs ====================
'doc.text.fill': 'document-text',
'bubble.left.and.bubble.right.fill': 'chatbubbles',
'viewfinder.circle.fill': 'scan-circle',
'cart.fill': 'cart',
'person.fill': 'person',
'heart.fill': 'heart',
// ==================== 相机相关 ====================
'camera.fill': 'camera',
'camera.rotate': 'camera-reverse',
'camera.metering.center.weighted': 'camera-outline',
'arrow.triangle.2.circlepath.camera': 'camera-reverse-outline',
// ==================== 基础操作图标 ====================
xmark: 'close',
'xmark.circle.fill': 'close-circle',
'checkmark.circle.fill': 'checkmark-circle',
'checkmark.shield.fill': 'shield-checkmark',
'checkmark.seal.fill': 'medal',
'plus.circle.fill': 'add-circle',
// ==================== 文档相关 ====================
'doc.text.viewfinder': 'reader',
'doc.text.magnifyingglass': 'search',
'doc.on.doc': 'copy',
'photo.fill.on.rectangle.fill': 'images',
photo: 'image',
'photo.badge.plus': 'image-outline',
// ==================== 图表相关 ====================
'chart.bar.fill': 'bar-chart',
'chart.pie.fill': 'pie-chart',
'chart.bar.xaxis': 'stats-chart',
'chart.line.uptrend.xyaxis': 'trending-up',
'chart.bar.doc.horizontal.fill': 'stats-chart',
'list.bullet.rectangle': 'list',
// ==================== 状态和提示图标 ====================
'exclamationmark.circle': 'alert-circle',
'exclamationmark.triangle': 'warning',
'questionmark.circle.fill': 'help-circle',
'info.circle.fill': 'information-circle',
'lightbulb.fill': 'bulb',
sparkles: 'sparkles-outline',
'crown.fill': 'ribbon', // 添加 crown.fill 映射
// ==================== 导航和箭头 ====================
'chevron.right': 'chevron-forward',
'arrow.left': 'arrow-back',
'arrow.counterclockwise': 'refresh',
'arrow.clockwise': 'reload',
// ==================== 搜索和过滤 ====================
magnifyingglass: 'search',
'barcode.viewfinder': 'barcode',
// ==================== 社交和互动 ====================
'star.fill': 'star',
'heart.slash': 'heart-dislike',
'trophy.fill': 'trophy',
// ==================== 宠物相关 ====================
'pawprint.fill': 'paw',
// ==================== 列表和组织 ====================
'list.bullet': 'list',
'tray.fill': 'file-tray-full',
// ==================== 建筑/品牌 ====================
'building.2.fill': 'business',
'building.2': 'business-outline',
// ==================== 编辑工具 ====================
pencil: 'pencil',
trash: 'trash',
// ==================== 安全相关 ====================
'lock.fill': 'lock-closed',
'key.fill': 'key',
// ==================== 通讯相关 ====================
'bubble.left': 'chatbubble',
'paperplane.fill': 'send',
'bell.fill': 'notifications',
'bell.badge.fill': 'notifications',
bell: 'notifications-outline',
// ==================== 系统操作 ====================
'rectangle.portrait.and.arrow.right': 'exit',
clock: 'time',
} as IconMapping;
/**
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
* This ensures a consistent look across platforms, and optimal resource usage.
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
*/
export function IconSymbol({
name,
size = 24,
color,
style,
}: {
name: SymbolName;
size?: number;
color: string | OpaqueColorValue;
style?: StyleProp<TextStyle>;
weight?: SymbolWeight;
}) {
return <Ionicons color={color} size={size} name={MAPPING[name]} style={style} />;
}
|