@oxyhq/services 6.9.30 → 6.9.32
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.
- package/lib/commonjs/ui/components/FollowButton.js +19 -51
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +19 -51
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/typescript/commonjs/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/FollowButton.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/ui/components/FollowButton.tsx +14 -64
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.FollowButton = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
9
|
var _OxyContext = require("../context/OxyContext.js");
|
|
11
10
|
var _fonts = require("../styles/fonts.js");
|
|
12
11
|
var _sonner = require("../../lib/sonner");
|
|
@@ -14,9 +13,6 @@ var _useFollow = require("../hooks/useFollow.js");
|
|
|
14
13
|
var _theme2 = require("@oxyhq/bloom/theme");
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
-
// Create animated TouchableOpacity
|
|
18
|
-
const AnimatedTouchableOpacity = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TouchableOpacity);
|
|
19
|
-
const AnimatedText = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Text);
|
|
20
16
|
/**
|
|
21
17
|
* Inner component that handles all hooks and rendering.
|
|
22
18
|
*
|
|
@@ -55,10 +51,6 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
55
51
|
fetchStatus
|
|
56
52
|
} = (0, _useFollow.useFollowForButton)(userId, oxyServices);
|
|
57
53
|
|
|
58
|
-
// Animation values
|
|
59
|
-
const animationProgress = (0, _reactNativeReanimated.useSharedValue)(isFollowing ? 1 : 0);
|
|
60
|
-
const scale = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
61
|
-
|
|
62
54
|
// Stable press handler — depends on primitives only
|
|
63
55
|
const handlePress = (0, _react.useCallback)(async event => {
|
|
64
56
|
if (preventParentActions && event && event.preventDefault) {
|
|
@@ -66,18 +58,6 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
66
58
|
event.stopPropagation?.();
|
|
67
59
|
}
|
|
68
60
|
if (disabled || isLoading) return;
|
|
69
|
-
|
|
70
|
-
// Press animation
|
|
71
|
-
scale.value = (0, _reactNativeReanimated.withTiming)(0.95, {
|
|
72
|
-
duration: 100
|
|
73
|
-
}, finished => {
|
|
74
|
-
if (finished) {
|
|
75
|
-
scale.value = (0, _reactNativeReanimated.withSpring)(1, {
|
|
76
|
-
damping: 15,
|
|
77
|
-
stiffness: 200
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
61
|
try {
|
|
82
62
|
await toggleFollow();
|
|
83
63
|
if (onFollowChange) onFollowChange(!isFollowing);
|
|
@@ -85,7 +65,7 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
85
65
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
86
66
|
_sonner.toast.error(error.message || 'Failed to update follow status');
|
|
87
67
|
}
|
|
88
|
-
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions
|
|
68
|
+
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions]);
|
|
89
69
|
|
|
90
70
|
// Set initial follow status on mount if provided and not already set
|
|
91
71
|
(0, _react.useEffect)(() => {
|
|
@@ -103,43 +83,31 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
103
83
|
}
|
|
104
84
|
}, [userId, fetchStatus]);
|
|
105
85
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const animatedButtonStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
118
|
-
return {
|
|
119
|
-
transform: [{
|
|
120
|
-
scale: scale.value
|
|
121
|
-
}],
|
|
122
|
-
backgroundColor: (0, _reactNativeReanimated.interpolateColor)(animationProgress.value, [0, 1], [colors.primary, colors.background]),
|
|
123
|
-
borderColor: (0, _reactNativeReanimated.interpolateColor)(animationProgress.value, [0, 1], [colors.primary, colors.border])
|
|
124
|
-
};
|
|
125
|
-
}, [colors]);
|
|
126
|
-
const animatedTextStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
127
|
-
return {
|
|
128
|
-
color: (0, _reactNativeReanimated.interpolateColor)(animationProgress.value, [0, 1], ['#FFFFFF', colors.text])
|
|
129
|
-
};
|
|
130
|
-
}, [colors]);
|
|
86
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
87
|
+
// Not following: bg-primary, border-primary, text white
|
|
88
|
+
// Following: bg-background, border-border, text-foreground
|
|
89
|
+
const buttonColorStyle = isFollowing ? {
|
|
90
|
+
backgroundColor: colors.background,
|
|
91
|
+
borderColor: colors.border
|
|
92
|
+
} : {
|
|
93
|
+
backgroundColor: colors.primary,
|
|
94
|
+
borderColor: colors.primary
|
|
95
|
+
};
|
|
96
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
131
97
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
132
98
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
133
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
134
|
-
style: [baseButtonStyle,
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
100
|
+
style: [baseButtonStyle, buttonColorStyle],
|
|
135
101
|
onPress: handlePress,
|
|
136
102
|
disabled: disabled || isLoading,
|
|
137
103
|
activeOpacity: 0.8,
|
|
138
104
|
children: showLoadingState && isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
139
105
|
size: "small",
|
|
140
|
-
color:
|
|
141
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
142
|
-
style: [baseTextStyle,
|
|
106
|
+
color: textColor
|
|
107
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
108
|
+
style: [baseTextStyle, {
|
|
109
|
+
color: textColor
|
|
110
|
+
}],
|
|
143
111
|
children: isFollowing ? 'Following' : 'Follow'
|
|
144
112
|
})
|
|
145
113
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_OxyContext","_fonts","_sonner","_useFollow","_theme2","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FollowButtonInner","memo","userId","oxyServices","initiallyFollowing","size","onFollowChange","style","textStyle","disabled","showLoadingState","preventParentActions","theme","_theme","bloomTheme","useTheme","colors","isFollowing","isLoading","toggleFollow","setFollowStatus","fetchStatus","useFollowForButton","handlePress","useCallback","event","preventDefault","stopPropagation","err","error","Error","String","toast","message","useEffect","buttonColorStyle","backgroundColor","background","borderColor","border","primary","textColor","text","baseButtonStyle","getBaseButtonStyle","baseTextStyle","getBaseTextStyle","jsx","TouchableOpacity","onPress","activeOpacity","children","ActivityIndicator","color","Text","FollowButton","props","isAuthenticated","user","currentUser","useOxy","currentUserId","id","trim","targetUserId","exports","baseStyle","flexDirection","alignItems","justifyContent","borderWidth","Platform","select","web","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","sizeStyle","paddingVertical","paddingHorizontal","minWidth","borderRadius","fontFamily","fontFamilies","interSemiBold","fontWeight","sizeTextStyle","fontSize","_default"],"sourceRoot":"../../../../src","sources":["ui/components/FollowButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAA8C,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,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AM;IACLJ,SAAS,GAAG;MAAEC,eAAe,EAAE,CAAC;MAAEC,iBAAiB,EAAE,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,YAAY,EAAE;IAAG,CAAC;EAC3F;EAEA,OAAO,CAACnB,SAAS,EAAEe,SAAS,EAAE1E,KAAK,CAAC;AACtC;AAEA,SAASuC,gBAAgBA,CAACzC,IAAY,EAAEG,SAAgC,EAAwB;EAC9F,MAAMqC,aAAwB,GAAG;IAC/ByC,UAAU,EAAEC,mBAAY,CAACC,aAAa;IACtCC,UAAU,EAAE;EACd,CAAC;EAED,IAAIC,aAAwB;EAC5B,IAAIrF,IAAI,KAAK,OAAO,EAAE;IACpBqF,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM,IAAItF,IAAI,KAAK,OAAO,EAAE;IAC3BqF,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM;IACLD,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC;EAEA,OAAO,CAAC9C,aAAa,EAAE6C,aAAa,EAAElF,SAAS,CAAC;AAClD;AAAC,IAAAoF,QAAA,GAAA3B,OAAA,CAAA1E,OAAA,GAGcgE,YAAY","ignoreList":[]}
|
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useCallback, memo } from 'react';
|
|
4
4
|
import { TouchableOpacity, Text, Platform, ActivityIndicator } from 'react-native';
|
|
5
|
-
import Animated, { useSharedValue, useAnimatedStyle, withSpring, interpolateColor, Easing, withTiming } from 'react-native-reanimated';
|
|
6
5
|
import { useOxy } from "../context/OxyContext.js";
|
|
7
6
|
import { fontFamilies } from "../styles/fonts.js";
|
|
8
7
|
import { toast } from '../../lib/sonner';
|
|
9
8
|
import { useFollowForButton } from "../hooks/useFollow.js";
|
|
10
9
|
import { useTheme } from '@oxyhq/bloom/theme';
|
|
11
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
// Create animated TouchableOpacity
|
|
13
|
-
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
14
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
15
11
|
/**
|
|
16
12
|
* Inner component that handles all hooks and rendering.
|
|
17
13
|
*
|
|
@@ -50,10 +46,6 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
50
46
|
fetchStatus
|
|
51
47
|
} = useFollowForButton(userId, oxyServices);
|
|
52
48
|
|
|
53
|
-
// Animation values
|
|
54
|
-
const animationProgress = useSharedValue(isFollowing ? 1 : 0);
|
|
55
|
-
const scale = useSharedValue(1);
|
|
56
|
-
|
|
57
49
|
// Stable press handler — depends on primitives only
|
|
58
50
|
const handlePress = useCallback(async event => {
|
|
59
51
|
if (preventParentActions && event && event.preventDefault) {
|
|
@@ -61,18 +53,6 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
61
53
|
event.stopPropagation?.();
|
|
62
54
|
}
|
|
63
55
|
if (disabled || isLoading) return;
|
|
64
|
-
|
|
65
|
-
// Press animation
|
|
66
|
-
scale.value = withTiming(0.95, {
|
|
67
|
-
duration: 100
|
|
68
|
-
}, finished => {
|
|
69
|
-
if (finished) {
|
|
70
|
-
scale.value = withSpring(1, {
|
|
71
|
-
damping: 15,
|
|
72
|
-
stiffness: 200
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
56
|
try {
|
|
77
57
|
await toggleFollow();
|
|
78
58
|
if (onFollowChange) onFollowChange(!isFollowing);
|
|
@@ -80,7 +60,7 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
80
60
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
81
61
|
toast.error(error.message || 'Failed to update follow status');
|
|
82
62
|
}
|
|
83
|
-
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions
|
|
63
|
+
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions]);
|
|
84
64
|
|
|
85
65
|
// Set initial follow status on mount if provided and not already set
|
|
86
66
|
useEffect(() => {
|
|
@@ -98,43 +78,31 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
98
78
|
}
|
|
99
79
|
}, [userId, fetchStatus]);
|
|
100
80
|
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const animatedButtonStyle = useAnimatedStyle(() => {
|
|
113
|
-
return {
|
|
114
|
-
transform: [{
|
|
115
|
-
scale: scale.value
|
|
116
|
-
}],
|
|
117
|
-
backgroundColor: interpolateColor(animationProgress.value, [0, 1], [colors.primary, colors.background]),
|
|
118
|
-
borderColor: interpolateColor(animationProgress.value, [0, 1], [colors.primary, colors.border])
|
|
119
|
-
};
|
|
120
|
-
}, [colors]);
|
|
121
|
-
const animatedTextStyle = useAnimatedStyle(() => {
|
|
122
|
-
return {
|
|
123
|
-
color: interpolateColor(animationProgress.value, [0, 1], ['#FFFFFF', colors.text])
|
|
124
|
-
};
|
|
125
|
-
}, [colors]);
|
|
81
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
82
|
+
// Not following: bg-primary, border-primary, text white
|
|
83
|
+
// Following: bg-background, border-border, text-foreground
|
|
84
|
+
const buttonColorStyle = isFollowing ? {
|
|
85
|
+
backgroundColor: colors.background,
|
|
86
|
+
borderColor: colors.border
|
|
87
|
+
} : {
|
|
88
|
+
backgroundColor: colors.primary,
|
|
89
|
+
borderColor: colors.primary
|
|
90
|
+
};
|
|
91
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
126
92
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
127
93
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
128
|
-
return /*#__PURE__*/_jsx(
|
|
129
|
-
style: [baseButtonStyle,
|
|
94
|
+
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
95
|
+
style: [baseButtonStyle, buttonColorStyle],
|
|
130
96
|
onPress: handlePress,
|
|
131
97
|
disabled: disabled || isLoading,
|
|
132
98
|
activeOpacity: 0.8,
|
|
133
99
|
children: showLoadingState && isLoading ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
134
100
|
size: "small",
|
|
135
|
-
color:
|
|
136
|
-
}) : /*#__PURE__*/_jsx(
|
|
137
|
-
style: [baseTextStyle,
|
|
101
|
+
color: textColor
|
|
102
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
103
|
+
style: [baseTextStyle, {
|
|
104
|
+
color: textColor
|
|
105
|
+
}],
|
|
138
106
|
children: isFollowing ? 'Following' : 'Follow'
|
|
139
107
|
})
|
|
140
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useCallback","memo","TouchableOpacity","Text","Platform","ActivityIndicator","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useCallback","memo","TouchableOpacity","Text","Platform","ActivityIndicator","useOxy","fontFamilies","toast","useFollowForButton","useTheme","jsx","_jsx","FollowButtonInner","userId","oxyServices","initiallyFollowing","size","onFollowChange","style","textStyle","disabled","showLoadingState","preventParentActions","theme","_theme","bloomTheme","colors","isFollowing","isLoading","toggleFollow","setFollowStatus","fetchStatus","handlePress","event","preventDefault","stopPropagation","err","error","Error","String","message","buttonColorStyle","backgroundColor","background","borderColor","border","primary","textColor","text","baseButtonStyle","getBaseButtonStyle","baseTextStyle","getBaseTextStyle","onPress","activeOpacity","children","color","FollowButton","props","isAuthenticated","user","currentUser","currentUserId","id","trim","targetUserId","baseStyle","flexDirection","alignItems","justifyContent","borderWidth","select","web","default","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","sizeStyle","paddingVertical","paddingHorizontal","minWidth","borderRadius","fontFamily","interSemiBold","fontWeight","sizeTextStyle","fontSize"],"sourceRoot":"../../../../src","sources":["ui/components/FollowButton.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAQ,OAAO;AAC3D,SACEC,gBAAgB,EAChBC,IAAI,EAIJC,QAAQ,EACRC,iBAAiB,QACZ,cAAc;AACrB,SAASC,MAAM,QAAQ,0BAAuB;AAC9C,SAASC,YAAY,QAAQ,oBAAiB;AAC9C,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,kBAAkB,QAAQ,uBAAoB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAgB9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,gBAAGZ,IAAI,CAAC,SAASY,iBAAiBA,CAAC;EACxDC,MAAM;EACNC,WAAW;EACXC,kBAAkB,GAAG,KAAK;EAC1BC,IAAI,GAAG,QAAQ;EACfC,cAAc;EACdC,KAAK;EACLC,SAAS;EACTC,QAAQ,GAAG,KAAK;EAChBC,gBAAgB,GAAG,IAAI;EACvBC,oBAAoB,GAAG,IAAI;EAC3BC,KAAK,EAAEC,MAAM,GAAG;AACgC,CAAC,EAAE;EACnD,MAAMC,UAAU,GAAGhB,QAAQ,CAAC,CAAC;EAC7B,MAAMiB,MAAM,GAAGD,UAAU,CAACC,MAAM;;EAEhC;EACA,MAAM;IACJC,WAAW;IACXC,SAAS;IACTC,YAAY;IACZC,eAAe;IACfC;EACF,CAAC,GAAGvB,kBAAkB,CAACK,MAAM,EAAEC,WAAW,CAAC;;EAE3C;EACA,MAAMkB,WAAW,GAAGjC,WAAW,CAAC,MAAOkC,KAAqE,IAAK;IAC/G,IAAIX,oBAAoB,IAAIW,KAAK,IAAIA,KAAK,CAACC,cAAc,EAAE;MACzDD,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBD,KAAK,CAACE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GAAG;IAC/BmC,UAAU,EAAEhF,YAAY,CAACiF,aAAa;IACtCC,UAAU,EAAE;EACd,CAAC;EAED,IAAIC,aAAwB;EAC5B,IAAIzE,IAAI,KAAK,OAAO,EAAE;IACpByE,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM,IAAI1E,IAAI,KAAK,OAAO,EAAE;IAC3ByE,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM;IACLD,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC;EAEA,OAAO,CAACvC,aAAa,EAAEsC,aAAa,EAAEtE,SAAS,CAAC;AAClD;AAEA,SAASsC,YAAY;AACrB,eAAeA,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FollowButton.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/FollowButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"FollowButton.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/FollowButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,cAAc,CAAC;AAQtB,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAyGD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkB7C,CAAC;AAmDF,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FollowButton.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/FollowButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"FollowButton.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/FollowButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,cAAc,CAAC;AAQtB,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAyGD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkB7C,CAAC;AAmDF,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.32",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@lottiefiles/dotlottie-react": "^0.13.5",
|
|
74
|
-
"@oxyhq/bloom": "0.1.
|
|
74
|
+
"@oxyhq/bloom": "0.1.22",
|
|
75
75
|
"@oxyhq/core": "*",
|
|
76
76
|
"@react-native-async-storage/async-storage": "2.2.0",
|
|
77
77
|
"@react-native-community/netinfo": "^11.4.1",
|
|
@@ -2,21 +2,12 @@ import React, { useEffect, useCallback, memo } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
TouchableOpacity,
|
|
4
4
|
Text,
|
|
5
|
-
StyleSheet,
|
|
6
5
|
type ViewStyle,
|
|
7
6
|
type TextStyle,
|
|
8
7
|
type StyleProp,
|
|
9
8
|
Platform,
|
|
10
9
|
ActivityIndicator
|
|
11
10
|
} from 'react-native';
|
|
12
|
-
import Animated, {
|
|
13
|
-
useSharedValue,
|
|
14
|
-
useAnimatedStyle,
|
|
15
|
-
withSpring,
|
|
16
|
-
interpolateColor,
|
|
17
|
-
Easing,
|
|
18
|
-
withTiming
|
|
19
|
-
} from 'react-native-reanimated';
|
|
20
11
|
import { useOxy } from '../context/OxyContext';
|
|
21
12
|
import { fontFamilies } from '../styles/fonts';
|
|
22
13
|
import { toast } from '../../lib/sonner';
|
|
@@ -24,10 +15,6 @@ import { useFollowForButton } from '../hooks/useFollow';
|
|
|
24
15
|
import { useTheme } from '@oxyhq/bloom/theme';
|
|
25
16
|
import type { OxyServices } from '@oxyhq/core';
|
|
26
17
|
|
|
27
|
-
// Create animated TouchableOpacity
|
|
28
|
-
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
29
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
30
|
-
|
|
31
18
|
export interface FollowButtonProps {
|
|
32
19
|
userId: string;
|
|
33
20
|
initiallyFollowing?: boolean;
|
|
@@ -79,10 +66,6 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
79
66
|
fetchStatus,
|
|
80
67
|
} = useFollowForButton(userId, oxyServices);
|
|
81
68
|
|
|
82
|
-
// Animation values
|
|
83
|
-
const animationProgress = useSharedValue(isFollowing ? 1 : 0);
|
|
84
|
-
const scale = useSharedValue(1);
|
|
85
|
-
|
|
86
69
|
// Stable press handler — depends on primitives only
|
|
87
70
|
const handlePress = useCallback(async (event?: { preventDefault?: () => void; stopPropagation?: () => void }) => {
|
|
88
71
|
if (preventParentActions && event && event.preventDefault) {
|
|
@@ -91,13 +74,6 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
91
74
|
}
|
|
92
75
|
if (disabled || isLoading) return;
|
|
93
76
|
|
|
94
|
-
// Press animation
|
|
95
|
-
scale.value = withTiming(0.95, { duration: 100 }, (finished) => {
|
|
96
|
-
if (finished) {
|
|
97
|
-
scale.value = withSpring(1, { damping: 15, stiffness: 200 });
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
77
|
try {
|
|
102
78
|
await toggleFollow();
|
|
103
79
|
if (onFollowChange) onFollowChange(!isFollowing);
|
|
@@ -105,7 +81,7 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
105
81
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
106
82
|
toast.error(error.message || 'Failed to update follow status');
|
|
107
83
|
}
|
|
108
|
-
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions
|
|
84
|
+
}, [disabled, isLoading, toggleFollow, onFollowChange, isFollowing, preventParentActions]);
|
|
109
85
|
|
|
110
86
|
// Set initial follow status on mount if provided and not already set
|
|
111
87
|
useEffect(() => {
|
|
@@ -123,46 +99,20 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
123
99
|
}
|
|
124
100
|
}, [userId, fetchStatus]);
|
|
125
101
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// When following (progress=1): outlined button (bg-background, border-border, text-foreground)
|
|
134
|
-
const animatedButtonStyle = useAnimatedStyle(() => {
|
|
135
|
-
return {
|
|
136
|
-
transform: [{ scale: scale.value }],
|
|
137
|
-
backgroundColor: interpolateColor(
|
|
138
|
-
animationProgress.value,
|
|
139
|
-
[0, 1],
|
|
140
|
-
[colors.primary, colors.background]
|
|
141
|
-
),
|
|
142
|
-
borderColor: interpolateColor(
|
|
143
|
-
animationProgress.value,
|
|
144
|
-
[0, 1],
|
|
145
|
-
[colors.primary, colors.border]
|
|
146
|
-
),
|
|
147
|
-
};
|
|
148
|
-
}, [colors]);
|
|
149
|
-
|
|
150
|
-
const animatedTextStyle = useAnimatedStyle(() => {
|
|
151
|
-
return {
|
|
152
|
-
color: interpolateColor(
|
|
153
|
-
animationProgress.value,
|
|
154
|
-
[0, 1],
|
|
155
|
-
['#FFFFFF', colors.text]
|
|
156
|
-
),
|
|
157
|
-
};
|
|
158
|
-
}, [colors]);
|
|
102
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
103
|
+
// Not following: bg-primary, border-primary, text white
|
|
104
|
+
// Following: bg-background, border-border, text-foreground
|
|
105
|
+
const buttonColorStyle: ViewStyle = isFollowing
|
|
106
|
+
? { backgroundColor: colors.background, borderColor: colors.border }
|
|
107
|
+
: { backgroundColor: colors.primary, borderColor: colors.primary };
|
|
108
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
159
109
|
|
|
160
110
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
161
111
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
162
112
|
|
|
163
113
|
return (
|
|
164
|
-
<
|
|
165
|
-
style={[baseButtonStyle,
|
|
114
|
+
<TouchableOpacity
|
|
115
|
+
style={[baseButtonStyle, buttonColorStyle]}
|
|
166
116
|
onPress={handlePress}
|
|
167
117
|
disabled={disabled || isLoading}
|
|
168
118
|
activeOpacity={0.8}
|
|
@@ -170,14 +120,14 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
170
120
|
{showLoadingState && isLoading ? (
|
|
171
121
|
<ActivityIndicator
|
|
172
122
|
size="small"
|
|
173
|
-
color={
|
|
123
|
+
color={textColor}
|
|
174
124
|
/>
|
|
175
125
|
) : (
|
|
176
|
-
<
|
|
126
|
+
<Text style={[baseTextStyle, { color: textColor }]}>
|
|
177
127
|
{isFollowing ? 'Following' : 'Follow'}
|
|
178
|
-
</
|
|
128
|
+
</Text>
|
|
179
129
|
)}
|
|
180
|
-
</
|
|
130
|
+
</TouchableOpacity>
|
|
181
131
|
);
|
|
182
132
|
});
|
|
183
133
|
|