related-ui-components 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/commonjs/components/Button/Button.js +124 -0
  2. package/lib/commonjs/components/Button/Button.js.map +1 -0
  3. package/lib/commonjs/components/Button/index.js +29 -0
  4. package/lib/commonjs/components/Button/index.js.map +1 -0
  5. package/lib/commonjs/components/Card/Card.js +42 -48
  6. package/lib/commonjs/components/Card/Card.js.map +1 -1
  7. package/lib/commonjs/components/Filters/Filters.js +7 -6
  8. package/lib/commonjs/components/Filters/Filters.js.map +1 -1
  9. package/lib/commonjs/components/index.js +11 -0
  10. package/lib/commonjs/components/index.js.map +1 -1
  11. package/lib/commonjs/theme/Colors.js.map +1 -1
  12. package/lib/module/components/Button/Button.js +119 -0
  13. package/lib/module/components/Button/Button.js.map +1 -0
  14. package/lib/module/components/Button/index.js +5 -0
  15. package/lib/module/components/Button/index.js.map +1 -0
  16. package/lib/module/components/Card/Card.js +43 -49
  17. package/lib/module/components/Card/Card.js.map +1 -1
  18. package/lib/module/components/Filters/Filters.js +8 -6
  19. package/lib/module/components/Filters/Filters.js.map +1 -1
  20. package/lib/module/components/index.js +1 -0
  21. package/lib/module/components/index.js.map +1 -1
  22. package/lib/module/theme/Colors.js.map +1 -1
  23. package/lib/typescript/commonjs/components/Button/Button.d.ts +21 -0
  24. package/lib/typescript/commonjs/components/Button/Button.d.ts.map +1 -0
  25. package/lib/typescript/commonjs/components/Button/index.d.ts +3 -0
  26. package/lib/typescript/commonjs/components/Button/index.d.ts.map +1 -0
  27. package/lib/typescript/commonjs/components/Card/Card.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/components/Card/types.d.ts +12 -0
  29. package/lib/typescript/commonjs/components/Card/types.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/components/Filters/Filters.d.ts +2 -1
  31. package/lib/typescript/commonjs/components/Filters/Filters.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/components/index.d.ts +1 -0
  33. package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/theme/Colors.d.ts +5 -0
  35. package/lib/typescript/commonjs/theme/Colors.d.ts.map +1 -1
  36. package/lib/typescript/module/components/Button/Button.d.ts +21 -0
  37. package/lib/typescript/module/components/Button/Button.d.ts.map +1 -0
  38. package/lib/typescript/module/components/Button/index.d.ts +3 -0
  39. package/lib/typescript/module/components/Button/index.d.ts.map +1 -0
  40. package/lib/typescript/module/components/Card/Card.d.ts.map +1 -1
  41. package/lib/typescript/module/components/Card/types.d.ts +12 -0
  42. package/lib/typescript/module/components/Card/types.d.ts.map +1 -1
  43. package/lib/typescript/module/components/Filters/Filters.d.ts +2 -1
  44. package/lib/typescript/module/components/Filters/Filters.d.ts.map +1 -1
  45. package/lib/typescript/module/components/index.d.ts +1 -0
  46. package/lib/typescript/module/components/index.d.ts.map +1 -1
  47. package/lib/typescript/module/theme/Colors.d.ts +5 -0
  48. package/lib/typescript/module/theme/Colors.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/components/Button/Button.tsx +157 -0
  51. package/src/components/Button/index.ts +2 -0
  52. package/src/components/Card/Card.tsx +50 -51
  53. package/src/components/Card/types.ts +6 -0
  54. package/src/components/Filters/Filters.tsx +15 -2
  55. package/src/components/index.ts +2 -1
  56. package/src/theme/Colors.ts +6 -0
@@ -0,0 +1,157 @@
1
+ import React from "react";
2
+ import {
3
+ TouchableOpacity,
4
+ Text,
5
+ StyleSheet,
6
+ ViewStyle,
7
+ TextStyle,
8
+ ActivityIndicator,
9
+ StyleProp,
10
+ Platform,
11
+ } from "react-native";
12
+ import { LinearGradient, LinearGradientProps } from "expo-linear-gradient";
13
+
14
+ type GradientProps = Omit<LinearGradientProps, "style" | "children">;
15
+
16
+ export interface AppButtonProps {
17
+ title: string;
18
+ onPress: () => void;
19
+ style?: StyleProp<ViewStyle>;
20
+ textStyle?: StyleProp<TextStyle>;
21
+ disabled?: boolean;
22
+ loading?: boolean;
23
+ activeOpacity?: number;
24
+ backgroundColor?: string;
25
+ gradientProps?: GradientProps;
26
+ loadingIndicatorColor?: string;
27
+ accessibilityLabel?: string;
28
+ testID?: string;
29
+ }
30
+
31
+ const DEFAULT_ACTIVE_OPACITY = 0.7;
32
+ const DEFAULT_BACKGROUND_COLOR = Platform.OS === "ios" ? "#007AFF" : "#2196F3"; // iOS blue / Android blue
33
+
34
+ const AppButton: React.FC<AppButtonProps> = ({
35
+ title,
36
+ onPress,
37
+ style,
38
+ textStyle,
39
+ disabled = false,
40
+ loading = false,
41
+ activeOpacity = DEFAULT_ACTIVE_OPACITY,
42
+ backgroundColor,
43
+ gradientProps,
44
+ loadingIndicatorColor,
45
+ accessibilityLabel,
46
+ testID,
47
+ }) => {
48
+ const isActuallyDisabled = disabled || loading;
49
+
50
+ const getLoadingIndicatorColor = () => {
51
+ if (loadingIndicatorColor) return loadingIndicatorColor;
52
+ if (gradientProps) {
53
+ return "#FFFFFF";
54
+ }
55
+ };
56
+
57
+ const buttonContent = loading ? (
58
+ <ActivityIndicator
59
+ size="small"
60
+ color={getLoadingIndicatorColor()}
61
+ testID={testID ? `${testID}-loading-indicator` : undefined}
62
+ />
63
+ ) : (
64
+ <Text
65
+ style={[styles.text, textStyle]}
66
+ testID={testID ? `${testID}-text` : undefined}
67
+ >
68
+ {title}
69
+ </Text>
70
+ );
71
+
72
+ const baseButtonStyles: ViewStyle[] = [
73
+ styles.button,
74
+ isActuallyDisabled ? styles.disabled : {},
75
+ ];
76
+
77
+ if (gradientProps && gradientProps.colors && gradientProps.colors.length > 0) {
78
+ return (
79
+ <TouchableOpacity
80
+ onPress={onPress}
81
+ disabled={isActuallyDisabled}
82
+ activeOpacity={activeOpacity}
83
+ accessibilityRole="button"
84
+ accessibilityState={{ disabled: isActuallyDisabled }}
85
+ accessibilityLabel={accessibilityLabel || title}
86
+ testID={testID}
87
+ >
88
+ <LinearGradient
89
+ {...gradientProps}
90
+ style={[...baseButtonStyles, styles.gradientContainer, style]}
91
+ >
92
+ {buttonContent}
93
+ </LinearGradient>
94
+ </TouchableOpacity>
95
+ );
96
+ } else {
97
+ const solidBgColor = backgroundColor || DEFAULT_BACKGROUND_COLOR;
98
+ return (
99
+ <TouchableOpacity
100
+ onPress={onPress}
101
+ disabled={isActuallyDisabled}
102
+ activeOpacity={activeOpacity}
103
+ style={[
104
+ ...baseButtonStyles,
105
+ { backgroundColor: solidBgColor },
106
+ style,
107
+ ]}
108
+ accessibilityRole="button"
109
+ accessibilityState={{ disabled: isActuallyDisabled }}
110
+ accessibilityLabel={accessibilityLabel || title}
111
+ testID={testID}
112
+ >
113
+ {buttonContent}
114
+ </TouchableOpacity>
115
+ );
116
+ }
117
+ };
118
+
119
+ const styles = StyleSheet.create({
120
+ button: {
121
+ paddingVertical: 12,
122
+ paddingHorizontal: 24,
123
+ borderRadius: 8,
124
+ alignItems: "center",
125
+ justifyContent: "center",
126
+ minHeight: 48,
127
+ flexDirection: "row",
128
+ ...Platform.select({
129
+ ios: {
130
+ shadowColor: "#000",
131
+ shadowOffset: { width: 0, height: 1 },
132
+ shadowOpacity: 0.2,
133
+ shadowRadius: 1.41,
134
+ },
135
+ android: {
136
+ elevation: 2,
137
+ },
138
+ }),
139
+ },
140
+ gradientContainer: {
141
+ },
142
+ text: {
143
+ color: "#FFFFFF",
144
+ fontSize: 16,
145
+ fontWeight: "600",
146
+ textAlign: "center",
147
+ },
148
+ disabled: {
149
+ opacity: 0.6,
150
+ ...(Platform.OS === "android" && { elevation: 0 }),
151
+ ...(Platform.OS === "ios" && {
152
+ shadowOpacity: 0,
153
+ }),
154
+ },
155
+ });
156
+
157
+ export default AppButton;
@@ -0,0 +1,2 @@
1
+ export { default as Button } from "./Button";
2
+ export * from "./Button";
@@ -8,6 +8,7 @@ import {
8
8
  } from "react-native";
9
9
  import { CardProps } from "./types";
10
10
  import { useTheme } from "../../theme/ThemeContext";
11
+ import { LinearGradient } from "expo-linear-gradient";
11
12
 
12
13
  const Card: React.FC<CardProps> = ({
13
14
  children,
@@ -21,6 +22,7 @@ const Card: React.FC<CardProps> = ({
21
22
  borderColor,
22
23
  borderRadius = 8,
23
24
  backgroundImage,
25
+ gradient
24
26
  // margin,
25
27
  // padding,
26
28
  }) => {
@@ -32,35 +34,7 @@ const Card: React.FC<CardProps> = ({
32
34
  borderRadius,
33
35
  };
34
36
 
35
- switch (variant) {
36
- case "outlined":
37
- return {
38
- ...baseStyle,
39
- borderWidth: 1,
40
- borderColor: borderColor || theme.border,
41
- };
42
- case "filled":
43
- return {
44
- ...baseStyle,
45
- backgroundColor: backgroundColor || theme.primary,
46
- };
47
- case "elevated":
48
- return {
49
- ...baseStyle,
50
- borderColor: borderColor || "transparent",
51
- ...Platform.select({
52
- ios: {
53
- shadowColor: "#000",
54
- shadowOffset: { width: 0, height: elevation },
55
- shadowOpacity: 0.1,
56
- shadowRadius: elevation,
57
- },
58
- android: {
59
- elevation,
60
- },
61
- }),
62
- };
63
- }
37
+ return baseStyle;
64
38
  };
65
39
 
66
40
  const cardStyle = [
@@ -71,32 +45,50 @@ const Card: React.FC<CardProps> = ({
71
45
  backgroundImage && { backgroundColor: "transparent" },
72
46
  ];
73
47
 
74
- const renderCardContent = () =>
75
- backgroundImage ? (
76
- <ImageBackground
77
- source={backgroundImage.source}
78
- style={[styles.backgroundImage, backgroundImage.style]}
79
- imageStyle={[{ borderRadius }, backgroundImage.imageStyle]}
80
- resizeMode={backgroundImage.resizeMode || "cover"}
81
- blurRadius={backgroundImage.blurRadius}
82
- >
83
- <View
48
+ const renderCardContent = () => {
49
+ if (backgroundImage) {
50
+ return (
51
+ <ImageBackground
52
+ source={backgroundImage.source}
53
+ style={[styles.backgroundImage, backgroundImage.style]}
54
+ imageStyle={[{ borderRadius }, backgroundImage.imageStyle]}
55
+ resizeMode={backgroundImage.resizeMode || "cover"}
56
+ blurRadius={backgroundImage.blurRadius}
57
+ >
58
+ <View
59
+ style={[
60
+ styles.imageContentContainer,
61
+ {
62
+ opacity:
63
+ backgroundImage.opacity !== undefined
64
+ ? backgroundImage.opacity
65
+ : 1,
66
+ },
67
+ ]}
68
+ >
69
+ {children}
70
+ </View>
71
+ </ImageBackground>
72
+ );
73
+ } else if (gradient) {
74
+ return (
75
+ <LinearGradient
76
+ colors={gradient.colors as any}
77
+ start={gradient.start}
78
+ end={gradient.end}
84
79
  style={[
85
- styles.imageContentContainer,
86
- {
87
- opacity:
88
- backgroundImage.opacity !== undefined
89
- ? backgroundImage.opacity
90
- : 1,
91
- },
80
+ styles.gradient,
81
+ { borderRadius },
82
+ gradient.style,
92
83
  ]}
93
84
  >
94
85
  {children}
95
- </View>
96
- </ImageBackground>
97
- ) : (
98
- children
99
- );
86
+ </LinearGradient>
87
+ );
88
+ } else {
89
+ return children;
90
+ }
91
+ };
100
92
 
101
93
  if (onPress) {
102
94
  return (
@@ -135,6 +127,13 @@ const styles = StyleSheet.create({
135
127
  flex: 1,
136
128
  backgroundColor: "transparent",
137
129
  },
130
+ gradient: {
131
+ flex: 1,
132
+ width: "100%",
133
+ height: "100%",
134
+ justifyContent: "flex-start",
135
+ alignItems: "flex-start",
136
+ },
138
137
  });
139
138
 
140
139
  export default Card;
@@ -30,6 +30,12 @@ export interface CardProps {
30
30
  borderWidth?: number;
31
31
  borderColor?: string;
32
32
  };
33
+ gradient? :{
34
+ colors: string[];
35
+ start?: { x: number; y: number };
36
+ end?: { x: number; y: number };
37
+ style?: object;
38
+ }
33
39
  }
34
40
 
35
41
  export interface CardHeaderProps {
@@ -8,6 +8,7 @@ import {
8
8
  ViewStyle,
9
9
  ImageSourcePropType,
10
10
  I18nManager,
11
+ ButtonProps,
11
12
  // Remove TouchableWithoutFeedback as it's no longer needed for the overlay
12
13
  } from "react-native";
13
14
  import { GestureHandlerRootView } from "react-native-gesture-handler";
@@ -21,6 +22,7 @@ import { BrandIcon } from "../BrandIcon";
21
22
  import { Ionicons } from "@expo/vector-icons";
22
23
  import Checkbox from "expo-checkbox";
23
24
  import { useTheme, ThemeType } from "../../theme"; // Import ThemeType
25
+ import { Button } from "../Button";
24
26
 
25
27
  // ... (Keep existing type definitions: SortOption, Brand, FilterResult) ...
26
28
  type SortOption = {
@@ -93,6 +95,9 @@ interface FiltersProps {
93
95
  overlayColor?: string;
94
96
  onClose?: () => void;
95
97
  visible?: boolean;
98
+ applyButtonComponentProps?: Partial<
99
+ Omit<ButtonProps, "title" | "onPress">
100
+ >;
96
101
  }
97
102
 
98
103
  const Filters: React.FC<FiltersProps> = ({
@@ -146,6 +151,7 @@ const Filters: React.FC<FiltersProps> = ({
146
151
  headerTitleText = "Filter",
147
152
  onClose,
148
153
  visible = true,
154
+ applyButtonComponentProps
149
155
  }) => {
150
156
  const { theme, isRTL: themeIsRTL } = useTheme();
151
157
  const isRTL = isRTLProp ?? themeIsRTL ?? I18nManager.isRTL;
@@ -356,14 +362,21 @@ const Filters: React.FC<FiltersProps> = ({
356
362
  </View>
357
363
  )}
358
364
 
359
- <TouchableOpacity
365
+ <Button
366
+ style={[styles.applyButton, applyButtonStyle]}
367
+ onPress={handleApplyFilter}
368
+ title={applyButtonText}
369
+ textStyle={[styles.applyButtonText, applyButtonTextStyle]}
370
+ {...applyButtonComponentProps}
371
+ />
372
+ {/* <TouchableOpacity
360
373
  style={[styles.applyButton, applyButtonStyle]}
361
374
  onPress={handleApplyFilter}
362
375
  >
363
376
  <Text style={[styles.applyButtonText, applyButtonTextStyle]}>
364
377
  {applyButtonText}
365
378
  </Text>
366
- </TouchableOpacity>
379
+ </TouchableOpacity> */}
367
380
  </BottomSheetView>
368
381
  </View>
369
382
  </BottomSheet>
@@ -13,4 +13,5 @@ export * from "./UnlockRewards";
13
13
  export * from "./Wheel";
14
14
  export * from "./CloseIcon";
15
15
  export * from "./Marquee";
16
- export * from "./RedeemedVoucher";
16
+ export * from "./RedeemedVoucher";
17
+ export * from "./Button";
@@ -43,6 +43,12 @@ export interface ThemeType {
43
43
  xl: number;
44
44
  xxl: number;
45
45
  }
46
+
47
+ gradients?: {
48
+ primary?: string[];
49
+ secondary?: string[];
50
+ [key: string]: string[] | undefined;
51
+ };
46
52
  }
47
53
 
48
54
  // Updated Light Theme - True black and white oriented, less muted