Skip to content

Commit

Permalink
custom text component
Browse files Browse the repository at this point in the history
  • Loading branch information
“T3sultan” committed Apr 15, 2022
1 parent 0c02abf commit 9eaf80f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 4 deletions.
83 changes: 80 additions & 3 deletions src/common/CustomText.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,88 @@
import { StyleSheet, Text as RNText } from "react-native";
import React from "react";
import { moderateScale } from "react-native-size-matters";
import { Colors, Fonts } from "../theme";

const CustomText = props => {
const { children } = props;
return <RNText>{children}</RNText>;
const {
children,
small,
body,
caption,
title,
header,
headLine,
display,
jumbo,
mega,
nunitoBlack,
nunitoBold,
primaryColor,
antiquewhite,
aqua,
deeppink,
black,
underLine,
centered,
alginRight,
alginLeft,
fwNormal,
fw500,
fw600,
fwBold,
style,
lh,
} = props;
return (
<RNText
style={[
styles.textStyle,
//fonts size
small && { fontSize: moderateScale(Fonts.size.small) },
body && { fontSize: moderateScale(Fonts.size.body) },
caption && { fontSize: moderateScale(Fonts.size.caption) },
header && { fontSize: moderateScale(Fonts.size.header) },
title && { fontSize: moderateScale(Fonts.size.title) },
headLine && { fontSize: moderateScale(Fonts.size.headLine) },
display && { fontSize: moderateScale(Fonts.size.display) },
jumbo && { fontSize: moderateScale(Fonts.size.jumbo) },
mega && { fontSize: moderateScale(Fonts.size.mega) },
//fonts
nunitoBlack && { fontFamily: Fonts.type.nunitoBlack },
nunitoBold && { fontFamily: Fonts.type.nunitoBold },

//color
black && { color: Colors.black },
deeppink && { color: Colors.deeppink },
primaryColor && { color: Colors.primaryColor },
antiquewhite && { color: Colors.antiquewhite },
aqua && { color: Colors.aqua },

//position
underLine && { textDecorationLine: "underline" },
centered && { textAlign: "center" },
alginRight && { textAlign: "right" },
alginLeft && { textAlign: "left" },
fwNormal && { fontWeight: "normal" },
fw500 && { fontWeight: "500" },
fw600 && { fontWeight: "600" },
fwBold && { fontWeight: "bold" },
lh && { lineHeight: 2 },
style,
]}
numberOfLines={numberOfLines}
>
{children}
</RNText>
);
};

export default CustomText;

const styles = StyleSheet.create({});
const styles = StyleSheet.create({
textStyle: {
fontSize: Fonts.size.body,
fontFamily: Fonts.type.nunitoBlack,
color: Colors.black,
},
});
2 changes: 2 additions & 0 deletions src/theme/images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const images = {};
export default images;
3 changes: 2 additions & 1 deletion src/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Colors from "./colors";
import Metrics from "./metrics";
import Fonts from "./fonts";
import Images from "./images";

export { Colors, Metrics, Fonts };
export { Colors, Metrics, Fonts, Images };

0 comments on commit 9eaf80f

Please sign in to comment.