1 | var __rest = (this && this.__rest) || function (s, e) {
|
2 | var t = {};
|
3 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4 | t[p] = s[p];
|
5 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8 | t[p[i]] = s[p[i]];
|
9 | }
|
10 | return t;
|
11 | };
|
12 | import React from 'react';
|
13 | import { TouchableHighlight, View, Platform, StyleSheet, } from 'react-native';
|
14 | import { withTheme } from '../config';
|
15 | import Image from '../image/Image';
|
16 | import Icon from '../icons/Icon';
|
17 | const Accessory = (_a) => {
|
18 | var { size = 10, style, underlayColor = '#000', onPress, onLongPress, source } = _a, props = __rest(_a, ["size", "style", "underlayColor", "onPress", "onLongPress", "source"]);
|
19 | return (<TouchableHighlight style={[
|
20 | styles.accessory,
|
21 | {
|
22 | width: size,
|
23 | height: size,
|
24 | borderRadius: size / 2,
|
25 | },
|
26 | style,
|
27 | ]} underlayColor={underlayColor} onPress={onPress} onLongPress={onLongPress}>
|
28 | <View>
|
29 | {source ? (<Image source={source} style={{
|
30 | width: size,
|
31 | height: size,
|
32 | borderRadius: size / 2,
|
33 | }} {...props}/>) : (<Icon name="mode-edit" type="material" color="#fff" size={size * 0.8} {...props}/>)}
|
34 | </View>
|
35 | </TouchableHighlight>);
|
36 | };
|
37 | const styles = StyleSheet.create({
|
38 | accessory: Object.assign({ position: 'absolute', bottom: 0, right: 0, alignItems: 'center', justifyContent: 'center', backgroundColor: '#aaa' }, Platform.select({
|
39 | android: {
|
40 | elevation: 1,
|
41 | },
|
42 | default: {
|
43 | shadowColor: '#000',
|
44 | shadowOffset: { width: 1, height: 1 },
|
45 | shadowRadius: 2,
|
46 | shadowOpacity: 0.5,
|
47 | },
|
48 | })),
|
49 | });
|
50 | export default withTheme(Accessory, 'AvatarAccessory');
|