2018-03-09 22:59:12 +02:00
|
|
|
const Setting = require('lib/models/Setting.js');
|
2018-03-26 19:52:49 +02:00
|
|
|
const { Platform } = require('react-native');
|
2017-08-01 19:59:01 +02:00
|
|
|
|
2017-07-21 23:40:02 +02:00
|
|
|
const globalStyle = {
|
2017-07-30 23:04:26 +02:00
|
|
|
fontSize: 16,
|
2017-07-21 23:40:02 +02:00
|
|
|
margin: 15, // No text and no interactive component should be within this margin
|
2017-07-30 23:04:26 +02:00
|
|
|
itemMarginTop: 10,
|
|
|
|
itemMarginBottom: 10,
|
2017-07-21 23:40:02 +02:00
|
|
|
backgroundColor: "#ffffff",
|
2017-07-22 17:55:09 +02:00
|
|
|
color: "#555555", // For regular text
|
2017-08-01 19:59:01 +02:00
|
|
|
colorError: "red",
|
|
|
|
colorWarn: "#9A5B00",
|
2017-07-22 17:55:09 +02:00
|
|
|
colorFaded: "#777777", // For less important text
|
2017-07-30 23:04:26 +02:00
|
|
|
fontSizeSmaller: 14,
|
2017-07-21 23:40:02 +02:00
|
|
|
dividerColor: "#dddddd",
|
2018-03-09 22:59:12 +02:00
|
|
|
selectedColor: '#e5e5e5',
|
2018-01-25 21:01:14 +02:00
|
|
|
disabledOpacity: 0.2,
|
2018-03-27 19:41:19 +02:00
|
|
|
colorUrl: '#000CFF',
|
2017-07-21 23:40:02 +02:00
|
|
|
|
2017-07-27 19:34:43 +02:00
|
|
|
raisedBackgroundColor: "#0080EF",
|
2017-07-27 19:25:42 +02:00
|
|
|
raisedColor: "#003363",
|
|
|
|
raisedHighlightedColor: "#ffffff",
|
|
|
|
|
2017-12-30 21:57:34 +02:00
|
|
|
warningBackgroundColor: "#FFD08D",
|
|
|
|
|
2017-07-21 23:40:02 +02:00
|
|
|
// For WebView - must correspond to the properties above
|
2018-03-09 22:59:12 +02:00
|
|
|
htmlFontSize: '16px',
|
|
|
|
htmlColor: 'black', // Note: CSS in WebView component only supports named colors or rgb() notation
|
|
|
|
htmlBackgroundColor: 'white',
|
|
|
|
htmlDividerColor: 'Gainsboro',
|
|
|
|
htmlLinkColor: 'blue',
|
|
|
|
htmlLineHeight: '20px',
|
2017-07-21 23:40:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
globalStyle.marginRight = globalStyle.margin;
|
|
|
|
globalStyle.marginLeft = globalStyle.margin;
|
2017-07-22 17:55:09 +02:00
|
|
|
globalStyle.marginTop = globalStyle.margin;
|
|
|
|
globalStyle.marginBottom = globalStyle.margin;
|
2018-03-09 22:59:12 +02:00
|
|
|
globalStyle.htmlMarginLeft = ((globalStyle.marginLeft / 10) * 0.6).toFixed(2) + 'em';
|
2017-07-21 23:40:02 +02:00
|
|
|
|
2018-03-26 19:52:49 +02:00
|
|
|
// globalStyle.icon = {
|
|
|
|
// color: globalStyle.color,
|
|
|
|
// fontSize: 30,
|
|
|
|
// };
|
2017-07-22 18:36:55 +02:00
|
|
|
|
2018-03-26 19:52:49 +02:00
|
|
|
// globalStyle.lineInput = {
|
|
|
|
// color: globalStyle.color,
|
|
|
|
// backgroundColor: globalStyle.backgroundColor,
|
|
|
|
// };
|
2017-07-23 00:52:24 +02:00
|
|
|
|
2018-03-26 19:52:49 +02:00
|
|
|
// globalStyle.buttonRow = {
|
|
|
|
// flexDirection: 'row',
|
|
|
|
// borderTopWidth: 1,
|
|
|
|
// borderTopColor: globalStyle.dividerColor,
|
|
|
|
// paddingTop: 10,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// globalStyle.normalText = {
|
|
|
|
// color: globalStyle.color,
|
|
|
|
// fontSize: globalStyle.fontSize,
|
|
|
|
// };
|
2018-03-16 22:17:52 +02:00
|
|
|
|
2017-08-01 19:59:01 +02:00
|
|
|
let themeCache_ = {};
|
|
|
|
|
2018-03-26 19:52:49 +02:00
|
|
|
function addExtraStyles(style) {
|
|
|
|
style.icon = {
|
|
|
|
color: style.color,
|
|
|
|
fontSize: 30,
|
|
|
|
};
|
|
|
|
|
|
|
|
style.lineInput = {
|
|
|
|
color: style.color,
|
|
|
|
backgroundColor: style.backgroundColor,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
style.lineInput.borderBottomWidth = 1;
|
|
|
|
style.lineInput.borderBottomColor = style.dividerColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
style.buttonRow = {
|
|
|
|
flexDirection: 'row',
|
|
|
|
borderTopWidth: 1,
|
|
|
|
borderTopColor: style.dividerColor,
|
|
|
|
paddingTop: 10,
|
|
|
|
};
|
|
|
|
|
|
|
|
style.normalText = {
|
|
|
|
color: style.color,
|
|
|
|
fontSize: style.fontSize,
|
|
|
|
};
|
|
|
|
|
2018-03-27 19:41:19 +02:00
|
|
|
style.urlText = {
|
|
|
|
color: style.colorUrl,
|
|
|
|
fontSize: style.fontSize,
|
|
|
|
};
|
|
|
|
|
2018-03-26 19:52:49 +02:00
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2017-08-01 19:59:01 +02:00
|
|
|
function themeStyle(theme) {
|
2018-03-27 19:41:19 +02:00
|
|
|
if (!theme) throw new Error('Theme not set');
|
|
|
|
|
2017-08-01 19:59:01 +02:00
|
|
|
if (themeCache_[theme]) return themeCache_[theme];
|
|
|
|
|
|
|
|
let output = Object.assign({}, globalStyle);
|
2018-03-26 19:52:49 +02:00
|
|
|
if (theme == Setting.THEME_LIGHT) return addExtraStyles(output);
|
2017-08-01 19:59:01 +02:00
|
|
|
|
2018-03-09 22:59:12 +02:00
|
|
|
output.backgroundColor = '#1D2024';
|
|
|
|
output.color = '#dddddd';
|
|
|
|
output.colorFaded = '#777777';
|
|
|
|
output.dividerColor = '#555555';
|
|
|
|
output.selectedColor = '#333333';
|
2017-08-01 19:59:01 +02:00
|
|
|
|
|
|
|
output.raisedBackgroundColor = "#0F2051";
|
2017-08-01 20:29:01 +02:00
|
|
|
output.raisedColor = "#788BC3";
|
2017-08-01 19:59:01 +02:00
|
|
|
output.raisedHighlightedColor = "#ffffff";
|
|
|
|
|
2018-03-09 22:59:12 +02:00
|
|
|
output.htmlColor = 'rgb(220,220,220)';
|
|
|
|
output.htmlBackgroundColor = 'rgb(29,32,36)';
|
|
|
|
output.htmlLinkColor = 'rgb(166,166,255)';
|
2017-08-01 20:53:50 +02:00
|
|
|
|
2017-08-01 19:59:01 +02:00
|
|
|
themeCache_[theme] = output;
|
2018-03-26 19:52:49 +02:00
|
|
|
return addExtraStyles(themeCache_[theme]);
|
2017-08-01 19:59:01 +02:00
|
|
|
}
|
|
|
|
|
2018-03-09 22:59:12 +02:00
|
|
|
module.exports = { globalStyle, themeStyle };
|