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-12-15 02:42:19 +02:00
|
|
|
strongDividerColor: "#aaaaaa",
|
2018-03-09 22:59:12 +02:00
|
|
|
selectedColor: '#e5e5e5',
|
2018-01-25 21:01:14 +02:00
|
|
|
disabledOpacity: 0.2,
|
2018-12-15 02:42:19 +02:00
|
|
|
colorUrl: '#7B81FF',
|
2018-04-11 19:25:07 +02:00
|
|
|
textSelectionColor: "#0096FF",
|
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',
|
2019-02-07 01:52:29 +02:00
|
|
|
htmlColor: '#222222',
|
2018-03-09 22:59:12 +02:00
|
|
|
htmlBackgroundColor: 'white',
|
2019-02-07 01:52:29 +02:00
|
|
|
htmlDividerColor: 'rgb(230,230,230)',
|
|
|
|
htmlLinkColor: 'rgb(80,130,190)',
|
|
|
|
htmlLineHeight: '1.6em',
|
|
|
|
|
|
|
|
htmlCodeBackgroundColor: 'rgb(243, 243, 243)',
|
|
|
|
htmlCodeBorderColor: 'rgb(220, 220, 220)',
|
|
|
|
htmlCodeColor: 'rgb(0,0,0)',
|
2019-03-08 19:14:17 +02:00
|
|
|
|
|
|
|
codeThemeCss: 'hljs-atom-one-light.css',
|
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
|
|
|
|
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,
|
2018-12-15 02:42:19 +02:00
|
|
|
borderBottomWidth: 1,
|
|
|
|
borderColor: style.strongDividerColor,
|
|
|
|
paddingBottom: 0,
|
2018-03-26 19:52:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
2019-02-03 18:57:29 +02:00
|
|
|
delete style.lineInput.borderBottomWidth;
|
|
|
|
delete style.lineInput.borderColor;
|
2018-03-26 19:52:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-04-16 15:15:29 +02:00
|
|
|
if (!theme) {
|
|
|
|
console.warn('Theme not set!! Defaulting to Light theme');
|
|
|
|
theme = Setting.THEME_LIGHT;
|
|
|
|
}
|
2018-03-27 19:41:19 +02:00
|
|
|
|
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';
|
2018-12-15 02:42:19 +02:00
|
|
|
output.strongDividerColor = '#888888';
|
2018-03-09 22:59:12 +02:00
|
|
|
output.selectedColor = '#333333';
|
2018-04-11 19:25:07 +02:00
|
|
|
output.textSelectionColor = '#00AEFF';
|
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
|
|
|
|
2019-02-07 01:52:29 +02:00
|
|
|
output.htmlDividerColor = '#3D444E';
|
|
|
|
output.htmlLinkColor = 'rgb(166,166,255)';
|
|
|
|
output.htmlCodeColor = '#ffffff';
|
|
|
|
output.htmlCodeBackgroundColor = 'rgb(47, 48, 49)';
|
|
|
|
output.htmlCodeBorderColor = 'rgb(70, 70, 70)';
|
|
|
|
|
2019-03-08 19:14:17 +02:00
|
|
|
output.codeThemeCss = 'hljs-atom-one-dark-reasonable.css';
|
|
|
|
|
2018-12-15 02:42:19 +02:00
|
|
|
output.colorUrl = '#7B81FF';
|
|
|
|
|
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 };
|