application-amicale/native-base-theme/components/ListItem.js

447 lines
12 KiB
JavaScript
Raw Normal View History

2019-06-25 22:20:24 +02:00
// @flow
2020-01-28 20:07:21 +01:00
import { Platform, PixelRatio } from 'react-native';
2019-06-25 22:20:24 +02:00
2020-01-28 20:07:21 +01:00
import pickerTheme from './Picker';
import variable from './../variables/platform';
import { PLATFORM } from './../variables/commonColor';
2019-06-25 22:20:24 +02:00
2020-01-28 20:07:21 +01:00
export default (variables /* : * */ = variable) => {
2019-06-25 22:20:24 +02:00
const platform = variables.platform;
const selectedStyle = {
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.listItemSelected
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.listItemSelected
}
};
const listItemTheme = {
2020-01-28 20:07:21 +01:00
'NativeBase.InputGroup': {
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
paddingRight: 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
paddingRight: 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Input': {
2019-06-25 22:20:24 +02:00
paddingHorizontal: 5
},
flex: 1,
borderWidth: null,
margin: -10,
2020-01-28 20:07:21 +01:00
borderBottomColor: 'transparent'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'.searchBar': {
'NativeBase.Item': {
'NativeBase.Icon': {
backgroundColor: 'transparent',
2019-06-25 22:20:24 +02:00
color: variables.dropdownLinkColor,
fontSize:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS
2019-06-25 22:20:24 +02:00
? variables.iconFontSize - 10
: variables.iconFontSize - 5,
2020-01-28 20:07:21 +01:00
alignItems: 'center',
2019-06-25 22:20:24 +02:00
marginTop: 2,
paddingRight: 8
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
backgroundColor: 'transparent',
2019-06-25 22:20:24 +02:00
color: null,
2020-01-28 20:07:21 +01:00
alignSelf: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Input': {
alignSelf: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'flex-start',
2019-06-25 22:20:24 +02:00
flex: 1,
2020-01-28 20:07:21 +01:00
height: platform === PLATFORM.IOS ? 30 : 40,
borderColor: 'transparent',
backgroundColor: '#fff',
2019-06-25 22:20:24 +02:00
borderRadius: 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
'.transparent': {
'NativeBase.Text': {
fontWeight: '500'
2019-06-25 22:20:24 +02:00
},
paddingHorizontal: null,
2020-01-28 20:07:21 +01:00
paddingLeft: platform === PLATFORM.IOS ? 10 : null
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
paddingHorizontal: platform === PLATFORM.IOS ? undefined : null,
width: platform === PLATFORM.IOS ? undefined : 0,
height: platform === PLATFORM.IOS ? undefined : 0
2019-06-25 22:20:24 +02:00
},
backgroundColor: variables.toolbarInputColor,
padding: 10,
marginLeft: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.CheckBox': {
2019-06-25 22:20:24 +02:00
marginLeft: -10,
marginRight: 10
},
2020-01-28 20:07:21 +01:00
'.first': {
'.itemHeader': {
2019-06-25 22:20:24 +02:00
paddingTop: variables.listItemPadding + 3
}
},
2020-01-28 20:07:21 +01:00
'.itemHeader': {
'.first': {
2019-06-25 22:20:24 +02:00
paddingTop: variables.listItemPadding + 3
},
2020-01-28 20:07:21 +01:00
borderBottomWidth:
platform === PLATFORM.IOS ? variables.borderWidth : null,
2019-06-25 22:20:24 +02:00
marginLeft: null,
padding: variables.listItemPadding,
paddingLeft: variables.listItemPadding + 5,
paddingTop:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS ? variables.listItemPadding + 25 : undefined,
2019-06-25 22:20:24 +02:00
paddingBottom:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.ANDROID ? variables.listItemPadding + 20 : undefined,
flexDirection: 'row',
2019-06-25 22:20:24 +02:00
borderColor: variables.listBorderColor,
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
fontSize: 14,
2020-01-28 20:07:21 +01:00
color: platform === PLATFORM.IOS ? undefined : variables.listNoteColor
2019-06-25 22:20:24 +02:00
}
},
2020-01-28 20:07:21 +01:00
'.itemDivider': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null,
marginLeft: null,
padding: variables.listItemPadding,
paddingLeft: variables.listItemPadding + 5,
backgroundColor: variables.listDividerBg,
2020-01-28 20:07:21 +01:00
flexDirection: 'row',
2019-06-25 22:20:24 +02:00
borderColor: variables.listBorderColor
},
2020-01-28 20:07:21 +01:00
'.selected': {
'NativeBase.Left': {
2019-06-25 22:20:24 +02:00
...selectedStyle
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
...selectedStyle
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
...selectedStyle
},
...selectedStyle
},
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
'NativeBase.Body': {
'NativeBase.Text': {
'.note': {
2019-06-25 22:20:24 +02:00
color: variables.listNoteColor,
2020-01-28 20:07:21 +01:00
fontWeight: '200'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
fontWeight: '600'
2019-06-25 22:20:24 +02:00
},
marginLeft: 10,
alignItems: null,
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
width: variables.iconFontSize - 10,
fontSize: variables.iconFontSize - 10
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
width: variables.iconFontSize - 10,
fontSize: variables.iconFontSize - 10
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
alignSelf: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
flexDirection: 'row'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
marginHorizontal: variables.listItemPadding,
2020-01-28 20:07:21 +01:00
'.note': {
2019-06-25 22:20:24 +02:00
color: variables.listNoteColor,
2020-01-28 20:07:21 +01:00
fontWeight: '200'
2019-06-25 22:20:24 +02:00
}
},
alignSelf: null,
alignItems: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
'NativeBase.Badge': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.PickerNB': {
'NativeBase.Button': {
2019-06-25 22:20:24 +02:00
marginRight: -15,
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.topTabBarActiveTextColor
}
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
2019-06-25 22:20:24 +02:00
alignSelf: null,
2020-01-28 20:07:21 +01:00
'.transparent': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.topTabBarActiveTextColor
}
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
alignSelf: null,
fontSize: variables.iconFontSize - 8,
2020-01-28 20:07:21 +01:00
color: '#c9c8cd'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
alignSelf: null,
fontSize: variables.iconFontSize - 8,
2020-01-28 20:07:21 +01:00
color: '#c9c8cd'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
'.note': {
2019-06-25 22:20:24 +02:00
color: variables.listNoteColor,
2020-01-28 20:07:21 +01:00
fontWeight: '200'
2019-06-25 22:20:24 +02:00
},
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Thumbnail': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Image': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Radio': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Checkbox': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Switch': {
2019-06-25 22:20:24 +02:00
alignSelf: null
},
padding: null,
flex: 0.28
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
'.note': {
2019-06-25 22:20:24 +02:00
color: variables.listNoteColor,
2020-01-28 20:07:21 +01:00
fontWeight: '200'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
alignSelf: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'.last': {
2019-06-25 22:20:24 +02:00
marginLeft: -(variables.listItemPadding + 5),
paddingLeft: (variables.listItemPadding + 5) * 2,
top: 1
},
2020-01-28 20:07:21 +01:00
'.avatar': {
'NativeBase.Left': {
2019-06-25 22:20:24 +02:00
flex: 0,
2020-01-28 20:07:21 +01:00
alignSelf: 'flex-start',
2019-06-25 22:20:24 +02:00
paddingTop: 14
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
marginLeft: null
},
flex: 1,
paddingVertical: variables.listItemPadding,
borderBottomWidth: variables.borderWidth,
borderColor: variables.listBorderColor,
marginLeft: variables.listItemPadding + 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
'NativeBase.Text': {
'.note': {
2019-06-25 22:20:24 +02:00
fontSize: variables.noteFontSize - 2
}
},
flex: 0,
paddingRight: variables.listItemPadding + 5,
2020-01-28 20:07:21 +01:00
alignSelf: 'stretch',
2019-06-25 22:20:24 +02:00
paddingVertical: variables.listItemPadding,
borderBottomWidth: variables.borderWidth,
borderColor: variables.listBorderColor
},
2020-01-28 20:07:21 +01:00
'.noBorder': {
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
}
},
borderBottomWidth: null,
paddingVertical: null,
paddingRight: null
},
2020-01-28 20:07:21 +01:00
'.thumbnail': {
'NativeBase.Left': {
2019-06-25 22:20:24 +02:00
flex: 0
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
marginLeft: null
},
flex: 1,
paddingVertical: variables.listItemPadding + 8,
borderBottomWidth: variables.borderWidth,
borderColor: variables.listBorderColor,
marginLeft: variables.listItemPadding + 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
'NativeBase.Button': {
'.transparent': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
fontSize: variables.listNoteSize,
color: variables.sTabBarActiveTextColor
}
},
height: null
},
flex: 0,
2020-01-28 20:07:21 +01:00
justifyContent: 'center',
alignSelf: 'stretch',
2019-06-25 22:20:24 +02:00
paddingRight: variables.listItemPadding + 5,
paddingVertical: variables.listItemPadding + 5,
borderBottomWidth: variables.borderWidth,
borderColor: variables.listBorderColor
},
2020-01-28 20:07:21 +01:00
'.noBorder': {
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
}
},
borderBottomWidth: null,
paddingVertical: null,
paddingRight: null
},
2020-01-28 20:07:21 +01:00
'.icon': {
'.last': {
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
borderBottomWidth: variables.borderWidth,
borderColor: variables.listBorderColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
'NativeBase.Button': {
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
marginHorizontal: null,
fontSize: variables.iconFontSize - 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
marginHorizontal: null,
fontSize: variables.iconFontSize - 8
},
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
2019-06-25 22:20:24 +02:00
height: 29,
width: 29,
borderRadius: 6,
paddingVertical: null,
paddingHorizontal: null,
2020-01-28 20:07:21 +01:00
alignItems: 'center',
justifyContent: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
width: variables.iconFontSize - 5,
fontSize: variables.iconFontSize - 2
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
width: variables.iconFontSize - 5,
fontSize: variables.iconFontSize - 2
},
paddingRight: variables.listItemPadding + 5,
flex: 0,
height: 44,
2020-01-28 20:07:21 +01:00
justifyContent: 'center',
alignItems: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
marginLeft: null,
fontSize: 17
},
flex: 1,
height: 44,
2020-01-28 20:07:21 +01:00
justifyContent: 'center',
2019-06-25 22:20:24 +02:00
borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
borderColor: variables.listBorderColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
'NativeBase.Text': {
textAlign: 'center',
color: '#8F8E95',
2019-06-25 22:20:24 +02:00
fontSize: 17
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
color: '#C8C7CC',
2019-06-25 22:20:24 +02:00
fontSize: variables.iconFontSize - 10,
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
2019-06-25 22:20:24 +02:00
paddingLeft: 10,
paddingTop: 3
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
color: '#C8C7CC',
2019-06-25 22:20:24 +02:00
fontSize: variables.iconFontSize - 10,
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
2019-06-25 22:20:24 +02:00
paddingLeft: 10,
paddingTop: 3
},
2020-01-28 20:07:21 +01:00
'NativeBase.Switch': {
marginRight: Platform.OS === PLATFORM.IOS ? undefined : -5,
2019-06-25 22:20:24 +02:00
alignSelf: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.PickerNB': {
2019-06-25 22:20:24 +02:00
...pickerTheme()
},
2020-01-28 20:07:21 +01:00
flexDirection: 'row',
alignItems: 'center',
2019-06-25 22:20:24 +02:00
flex: 0,
2020-01-28 20:07:21 +01:00
alignSelf: 'stretch',
2019-06-25 22:20:24 +02:00
height: 44,
2020-01-28 20:07:21 +01:00
justifyContent: 'flex-end',
2019-06-25 22:20:24 +02:00
borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
borderColor: variables.listBorderColor,
paddingRight: variables.listItemPadding + 5
},
2020-01-28 20:07:21 +01:00
'.noBorder': {
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
}
},
borderBottomWidth: null,
paddingVertical: null,
paddingRight: null,
height: 44,
2020-01-28 20:07:21 +01:00
justifyContent: 'center'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'.noBorder': {
2019-06-25 22:20:24 +02:00
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'.noIndent': {
2019-06-25 22:20:24 +02:00
marginLeft: null,
padding: variables.listItemPadding,
paddingLeft: variables.listItemPadding + 6
},
2020-01-28 20:07:21 +01:00
alignItems: 'center',
flexDirection: 'row',
2019-06-25 22:20:24 +02:00
paddingRight: variables.listItemPadding + 6,
paddingVertical: variables.listItemPadding + 3,
marginLeft: variables.listItemPadding + 6,
borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
backgroundColor: variables.listBg,
borderColor: variables.listBorderColor
};
return listItemTheme;
};