stylesheet.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {
  2. type TextStyle,
  3. type ViewStyle,
  4. StyleSheet
  5. } from "react-native";
  6. import type {
  7. SeperatorDynamicStyle
  8. } from "./type";
  9. import type {
  10. Mutable
  11. } from "../../types";
  12. const stylesheet = StyleSheet.create({
  13. container: {
  14. justifyContent: "center",
  15. alignItems: "center",
  16. display: "flex"
  17. },
  18. indicator: {
  19. flex: 1
  20. },
  21. title: {
  22. }
  23. });
  24. export const useStyles = ({
  25. customColor,
  26. direction,
  27. borders,
  28. length,
  29. colors,
  30. spaces,
  31. color
  32. }: SeperatorDynamicStyle) => {
  33. const styles = {
  34. container: {
  35. } as Mutable<ViewStyle>,
  36. indicator: {
  37. backgroundColor: customColor ? customColor : color ? colors.content.border[color] : colors.content.border.subtle
  38. } as Mutable<ViewStyle>,
  39. title: {
  40. marginHorizontal: spaces.spacingSm
  41. } as Mutable<TextStyle>
  42. };
  43. if(length !== undefined) {
  44. if(direction === "horizontal") {
  45. styles.container.width = length;
  46. } else {
  47. styles.container.height = length;
  48. }
  49. }
  50. if(direction === "horizontal") {
  51. styles.container.flexDirection = "row";
  52. styles.container.width = "90%";
  53. styles.indicator.height = borders.line;
  54. styles.indicator.width = "100%";
  55. } else {
  56. styles.container.flexDirection = "column";
  57. styles.container.height = "90%";
  58. styles.indicator.width = borders.line;
  59. styles.indicator.height = "100%";
  60. }
  61. return styles;
  62. };
  63. export default stylesheet;