Browse Source

Singleton themes

pull/1/head
Tim Glasgow 2 years ago
parent
commit
a67d5d62b1
  1. 32
      squarenotsquare/src/screens/styles/AppStyles.js
  2. 59
      squarenotsquare/src/themes/Colors.js
  3. 96
      squarenotsquare/src/themes/Fonts.js
  4. 15
      squarenotsquare/src/themes/Icons.js
  5. 44
      squarenotsquare/src/themes/Metrics.js

32
squarenotsquare/src/screens/styles/AppStyles.js

@ -1,7 +1,7 @@
import { StyleSheet } from "react-native"; import { StyleSheet } from "react-native";
import * as colors from '../../themes/Colors'; import Colors from '../../themes/Colors';
import * as fonts from '../../themes/Fonts'; import Fonts from '../../themes/Fonts';
import * as metrics from '../../themes/Metrics'; import Metrics from '../../themes/Metrics';
export const styles = StyleSheet.create({ export const styles = StyleSheet.create({
flex: {flex: 1}, flex: {flex: 1},
@ -28,7 +28,7 @@ export const styles = StyleSheet.create({
stretch: {alignSelf: 'stretch'}, stretch: {alignSelf: 'stretch'},
absolute: { absolute: {
position: 'absolute', position: 'absolute',
top: metrics.screenSections.headerHeight, top: Metrics.screenSections.headerHeight,
bottom: 0, bottom: 0,
left: 0, left: 0,
right: 0, right: 0,
@ -42,24 +42,20 @@ export const styles = StyleSheet.create({
rightText: {textAlign: 'right'}, rightText: {textAlign: 'right'},
leftText: {textAlign: 'left'}, leftText: {textAlign: 'left'},
headerTitleFont: {fontSize: fonts.headerTitle.size}, headerTitleFont: {fontSize: Fonts.headerTitle.size},
largeFont: {fontSize: fonts.large.size}, largeFont: {fontSize: Fonts.large.size},
mediumFont: {fontSize: fonts.medium.size}, mediumFont: {fontSize: Fonts.medium.size},
smallFont: {fontSize: fonts.small.size}, smallFont: {fontSize: Fonts.small.size},
tinyFont: {fontSize: fonts.tiny.size}, tinyFont: {fontSize: Fonts.tiny.size},
subFont: {fontSize: fonts.subFont.size}, subFont: {fontSize: Fonts.subFont.size},
tickFont: {fontSize: fonts.tickFont.size},
italic: {fontStyle: 'italic'}, italic: {fontStyle: 'italic'},
greyText: {color: colors.material.grey600}, greyText: {color: Colors.material.grey600},
redText: {color: colors.material.red800}, redText: {color: Colors.material.red800},
blueText: {color: colors.material.blue400}, blueText: {color: Colors.material.blue400},
boldText: {fontWeight: 'bold'}, boldText: {fontWeight: 'bold'},
lightText: {color: colors.impulseColors.lightText},
darkText: {color: colors.impulseColors.black},
body: { body: {
backgroundColor: colors.material.light, backgroundColor: Colors.material.light,
} }
}) })

59
squarenotsquare/src/themes/Colors.js

@ -1,31 +1,36 @@
export const material = { class AppColors {
dark: '#212121', material = {
light: '#ffffff', dark: '#212121',
light: '#ffffff',
//200
blue200: '#90caf9',
//400
blue400: '#5c6bc0',
grey400: '#bdbdbd',
//600
grey600: '#757575',
//700 //200
grey700: '#616161', blue200: '#90caf9',
//400
blue400: '#5c6bc0',
grey400: '#bdbdbd',
//600
grey600: '#757575',
//700
grey700: '#616161',
//800
amber800: '#ff8f00',
blue800: '#1565c0',
red800: '#c62828',
red800dark: '#7f0000',
grey800: '#424242',
grey800dark: '#1b1b1b',
green800: '#2e7d32',
}
//800 fonts = {
amber800: '#ff8f00', dark: '#000000',
blue800: '#1565c0', light: '#ffffff'
red800: '#c62828', };
red800dark: '#7f0000',
grey800: '#424242',
grey800dark: '#1b1b1b',
green800: '#2e7d32',
} }
export const fonts = { const Colors = new AppColors();
dark: '#000000', export default Colors;
light: '#ffffff'
};

96
squarenotsquare/src/themes/Fonts.js

@ -1,49 +1,55 @@
import {PixelRatio} from 'react-native'; import {PixelRatio} from 'react-native';
const scalar = PixelRatio.getFontScale(); class AppFonts {
constructor() {
this.scalar = PixelRatio.getFontScale();
this.headerTitle = {
fam: 'arial',
size: this.normalizeFont(30),
}
this.sectionHeader = {
fam: 'arial',
size: this.normalizeFont(26),
}
this.large = {
fam: 'arial',
size: this.normalizeFont(22),
}
this.medium = {
fam: 'arial',
size: this.normalizeFont(20),
}
this.small = {
fam: 'arial',
size: this.normalizeFont(16),
}
this.tiny = {
fam: 'arial',
size: this.normalizeFont(14),
}
this.mini = {
fam: 'arial',
size: this.normalizeFont(10),
}
this.subFont = {
fam: 'arial',
size: this.normalizeFont(8),
}
}
function normalizeFont(size) { normalizeFont(size) {
return size * scalar let newSize = size * this.scalar;
}; return newSize;
};
}
export const fonts = { const Fonts = new AppFonts();
headerTitle: { export default Fonts;
fam: 'arial',
size: normalizeFont(30),
},
sectionHeader: {
fam: 'arial',
size: normalizeFont(26),
},
large: {
fam: 'arial',
size: normalizeFont(22),
},
medium: {
fam: 'arial',
size: normalizeFont(20),
},
small: {
fam: 'arial',
size: normalizeFont(16),
},
tiny: {
fam: 'arial',
size: normalizeFont(14),
},
mini: {
fam: 'arial',
size: normalizeFont(10),
},
subFont: {
fam: 'arial',
size: normalizeFont(8),
},
}

15
squarenotsquare/src/themes/Icons.js

@ -1,5 +1,10 @@
export const squareIcons = { class AppIcons {
settings: 'cog-outline', squareIcons = {
toggleOn: 'toggle-switch-on', settings: 'cog-outline',
toggleOfff: 'toggle-switch-off' toggleOn: 'toggle-switch-on',
}; toggleOfff: 'toggle-switch-off'
};
}
const Icons = new AppIcons();
export default Icons;

44
squarenotsquare/src/themes/Metrics.js

@ -1,25 +1,35 @@
import { PixelRatio, Dimensions } from "react-native"; import { PixelRatio, Dimensions } from "react-native";
let scalar = PixelRatio.get(); class AppMetrics {
constructor(dimensions = Dimensions.get('window')) {
this.scalar = PixelRatio.get();
function normalize(size){ let height = dimensions.height;
return (size * scalar); let width = dimensions.width;
}
if (width > height) {
let dimensions = Dimensions.get('window'); this.screenHeight = width;
this.screenWidth = height;
} else {
this.screenWidth = width;
this.screenHeight = height;
}
}
let height = dimensions.height; normalize(size){
let width = dimensions.width; return (size * this.scalar);
}
let screenWidth = width; screenSections = {
let screenHeight = height; headerHeight: this.normalize(20),
sectionWidth: this.screenWidth
if (width > height) { }
screenHeight = width;
screenWidth = height;
} }
export const screenSections = { const Metrics = new AppMetrics();
headerHeight: normalize(20), export default Metrics;
sectionWidth: screenWidth
export function buildTestMetrics(dimensions){
const Metrics = new AppMetrics(dimensions);
return Metrics;
} }
Loading…
Cancel
Save