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

420 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 { PixelRatio, StatusBar } from 'react-native';
2019-06-25 22:20:24 +02:00
2020-01-28 20:07:21 +01:00
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 platformStyle = variables.platformStyle;
const platform = variables.platform;
const headerTheme = {
2020-01-28 20:07:21 +01:00
'.span': {
2019-06-25 22:20:24 +02:00
height: 128,
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
alignSelf: 'flex-start'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
alignSelf: 'flex-end',
alignItems: 'flex-start',
justifyContent: 'center',
2019-06-25 22:20:24 +02:00
paddingBottom: 26
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
alignSelf: 'flex-start'
2019-06-25 22:20:24 +02:00
}
},
2020-01-28 20:07:21 +01:00
'.hasSubtitle': {
'NativeBase.Body': {
'NativeBase.Title': {
2019-06-25 22:20:24 +02:00
fontSize: variables.titleFontSize - 2,
fontFamily: variables.titleFontfamily,
2020-01-28 20:07:21 +01:00
textAlign: 'center',
fontWeight: '500',
2019-06-25 22:20:24 +02:00
paddingBottom: 3
},
2020-01-28 20:07:21 +01:00
'NativeBase.Subtitle': {
2019-06-25 22:20:24 +02:00
fontSize: variables.subTitleFontSize,
fontFamily: variables.titleFontfamily,
color: variables.subtitleColor,
2020-01-28 20:07:21 +01:00
textAlign: 'center'
2019-06-25 22:20:24 +02:00
}
}
},
2020-01-28 20:07:21 +01:00
'.transparent': {
backgroundColor: 'transparent',
borderBottomColor: 'transparent',
2019-06-25 22:20:24 +02:00
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null,
2020-01-28 20:07:21 +01:00
paddingTop:
platform === PLATFORM.ANDROID ? StatusBar.currentHeight : undefined,
height:
platform === PLATFORM.ANDROID
? variables.toolbarHeight + StatusBar.currentHeight
: variables.toolbarHeight
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'.noShadow': {
2019-06-25 22:20:24 +02:00
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null
},
2020-01-28 20:07:21 +01:00
'.hasTabs': {
2019-06-25 22:20:24 +02:00
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null,
borderBottomWidth: null
},
2020-01-28 20:07:21 +01:00
'.hasSegment': {
2019-06-25 22:20:24 +02:00
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null,
borderBottomWidth: null,
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
2019-06-25 22:20:24 +02:00
flex: 0.3
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
2019-06-25 22:20:24 +02:00
flex: 0.3
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
flex: 1,
2020-01-28 20:07:21 +01:00
'NativeBase.Segment': {
2019-06-25 22:20:24 +02:00
marginRight: 0,
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
'NativeBase.Button': {
2019-06-25 22:20:24 +02:00
paddingLeft: 0,
paddingRight: 0
}
}
}
},
2020-01-28 20:07:21 +01:00
'.noLeft': {
'NativeBase.Left': {
width: platform === PLATFORM.IOS ? undefined : 0,
flex: platform === PLATFORM.IOS ? 1 : 0
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
'NativeBase.Title': {
paddingLeft: platform === PLATFORM.IOS ? undefined : 10
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Subtitle': {
paddingLeft: platform === PLATFORM.IOS ? undefined : 10
2019-06-25 22:20:24 +02:00
}
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
justifyContent: 'center',
alignSelf: 'center',
alignItems: 'center',
'.transparent': {
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnTextColor,
2020-01-28 20:07:21 +01:00
fontWeight: '600'
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
color: variables.toolbarBtnColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
paddingHorizontal: variables.buttonPadding
},
paddingHorizontal: 15
},
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: variables.toolbarSearchIconSize,
2020-01-28 20:07:21 +01:00
alignItems: 'center',
2019-06-25 22:20:24 +02:00
marginTop: 2,
paddingRight: 10,
paddingLeft: 10
},
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
lineHeight: null,
height: variables.searchBarInputHeight
},
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,
height: variables.searchBarHeight,
2020-01-28 20:07:21 +01:00
borderColor: 'transparent',
2019-06-25 22:20:24 +02:00
backgroundColor: variables.toolbarInputColor
},
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
}
},
2020-01-28 20:07:21 +01:00
'.rounded': {
'NativeBase.Item': {
2019-06-25 22:20:24 +02:00
borderRadius:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? 25
: 3
2019-06-25 22:20:24 +02:00
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Left': {
'NativeBase.Button': {
'.hasText': {
2019-06-25 22:20:24 +02:00
marginLeft: -10,
height: 30,
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize,
marginTop: 2,
marginRight: 5,
marginLeft: 2
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnTextColor,
2020-01-28 20:07:21 +01:00
fontSize: platform === PLATFORM.IOS ? 17 : 0,
2019-06-25 22:20:24 +02:00
marginLeft: 7,
lineHeight: 19.5
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize,
marginTop: 2,
marginRight: 5,
marginLeft: 2
}
},
2020-01-28 20:07:21 +01:00
'.transparent': {
2019-06-25 22:20:24 +02:00
marginLeft:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? -3
: 0,
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS &&
variables.platformStyle !== PLATFORM.MATERIAL
2019-06-25 22:20:24 +02:00
? variables.iconHeaderSize + 1
: variables.iconHeaderSize,
marginTop: 0,
marginRight: 2,
marginLeft: 1,
paddingTop: 1
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS &&
variables.platformStyle !== PLATFORM.MATERIAL
2019-06-25 22:20:24 +02:00
? variables.iconHeaderSize + 1
: variables.iconHeaderSize - 2,
marginTop: 0,
marginRight: 2,
marginLeft: 1,
paddingTop: 1
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnTextColor,
2020-01-28 20:07:21 +01:00
fontSize: platform === PLATFORM.IOS ? 17 : 0,
top: platform === PLATFORM.IOS ? 1 : -1.5,
2019-06-25 22:20:24 +02:00
paddingLeft:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? 2
: 5,
2019-06-25 22:20:24 +02:00
paddingRight:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
2019-06-25 22:20:24 +02:00
? undefined
: 10
},
2020-01-28 20:07:21 +01:00
backgroundColor: 'transparent',
2019-06-25 22:20:24 +02:00
borderColor: null,
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
alignSelf: null,
paddingRight: variables.buttonPadding,
2020-01-28 20:07:21 +01:00
paddingLeft:
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? 4
: 8
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
flex:
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? 1
: 0.4,
alignSelf: 'center',
alignItems: 'flex-start'
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Body': {
2019-06-25 22:20:24 +02:00
flex: 1,
alignItems:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && platformStyle !== PLATFORM.MATERIAL
? 'center'
: 'flex-start',
alignSelf: 'center',
'NativeBase.Segment': {
2019-06-25 22:20:24 +02:00
borderWidth: 0,
2020-01-28 20:07:21 +01:00
alignSelf: 'flex-end',
marginRight: platform === PLATFORM.IOS ? -40 : -55
2019-06-25 22:20:24 +02:00
},
2020-01-28 20:07:21 +01:00
'NativeBase.Button': {
alignSelf: 'center',
'.transparent': {
backgroundColor: 'transparent'
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
color: variables.toolbarBtnColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.inverseTextColor,
2020-01-28 20:07:21 +01:00
backgroundColor: 'transparent'
2019-06-25 22:20:24 +02:00
}
}
},
2020-01-28 20:07:21 +01:00
'NativeBase.Right': {
'NativeBase.Button': {
'.hasText': {
2019-06-25 22:20:24 +02:00
height: 30,
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize - 2,
marginTop: 2,
marginRight: 2,
marginLeft: 5
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnTextColor,
2020-01-28 20:07:21 +01:00
fontSize: platform === PLATFORM.IOS ? 17 : 14,
2019-06-25 22:20:24 +02:00
lineHeight: 19.5
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize - 2,
marginTop: 2,
marginRight: 2,
marginLeft: 5
}
},
2020-01-28 20:07:21 +01:00
'.transparent': {
marginRight: platform === PLATFORM.IOS ? -9 : -5,
2019-06-25 22:20:24 +02:00
paddingLeft: 15,
paddingRight: 12,
paddingHorizontal: 15,
borderRadius: 50,
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize - 2,
marginTop: 0,
marginLeft: 2,
marginRight: 0
// paddingTop: 0
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor,
fontSize: variables.iconHeaderSize - 2,
marginTop: 0,
marginLeft: 2,
marginRight: 0
// paddingTop: 0
},
2020-01-28 20:07:21 +01:00
'NativeBase.Text': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnTextColor,
2020-01-28 20:07:21 +01:00
fontSize: platform === PLATFORM.IOS ? 17 : 14,
top: platform === PLATFORM.IOS ? 1 : -1.5,
2019-06-25 22:20:24 +02:00
paddingRight:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS &&
variables.platformStyle !== PLATFORM.MATERIAL
2019-06-25 22:20:24 +02:00
? 0
: undefined
},
2020-01-28 20:07:21 +01:00
backgroundColor: 'transparent',
2019-06-25 22:20:24 +02:00
borderColor: null,
elevation: 0,
shadowColor: null,
shadowOffset: null,
shadowRadius: null,
shadowOpacity: null
},
2020-01-28 20:07:21 +01:00
'NativeBase.Icon': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
2020-01-28 20:07:21 +01:00
'NativeBase.IconNB': {
2019-06-25 22:20:24 +02:00
color: variables.toolbarBtnColor
},
alignSelf: null,
paddingHorizontal: variables.buttonPadding
},
flex: 1,
2020-01-28 20:07:21 +01:00
alignSelf: 'center',
alignItems: 'flex-end',
flexDirection: 'row',
justifyContent: 'flex-end'
2019-06-25 22:20:24 +02:00
},
backgroundColor: variables.toolbarDefaultBg,
2020-01-28 20:07:21 +01:00
flexDirection: 'row',
2019-06-25 22:20:24 +02:00
// paddingHorizontal: 10,
paddingLeft:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS && variables.platformStyle !== PLATFORM.MATERIAL
? 6
: 10,
2019-06-25 22:20:24 +02:00
paddingRight: 10,
2020-01-28 20:07:21 +01:00
justifyContent: 'center',
paddingTop: platform === PLATFORM.IOS ? 18 : 0,
2019-06-25 22:20:24 +02:00
borderBottomWidth:
2020-01-28 20:07:21 +01:00
platform === PLATFORM.IOS
? 1 / PixelRatio.getPixelSizeForLayoutSize(1)
: 0,
2019-06-25 22:20:24 +02:00
borderBottomColor: variables.toolbarDefaultBorder,
height:
2020-01-28 20:07:21 +01:00
variables.platform === PLATFORM.IOS &&
variables.platformStyle === PLATFORM.MATERIAL
2019-06-25 22:20:24 +02:00
? variables.toolbarHeight + 10
: variables.toolbarHeight,
elevation: 3,
2020-01-28 20:07:21 +01:00
shadowColor: platformStyle === PLATFORM.MATERIAL ? '#000' : undefined,
2019-06-25 22:20:24 +02:00
shadowOffset:
2020-01-28 20:07:21 +01:00
platformStyle === PLATFORM.MATERIAL ? { width: 0, height: 2 } : undefined,
shadowOpacity: platformStyle === PLATFORM.MATERIAL ? 0.2 : undefined,
shadowRadius: platformStyle === PLATFORM.MATERIAL ? 1.2 : undefined,
2019-06-25 22:20:24 +02:00
top: 0,
left: 0,
right: 0
};
return headerTheme;
};