@oxyhq/services 6.9.29 → 6.9.31
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 +27 -31
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +28 -32
- 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 +19 -42
|
@@ -11,12 +11,11 @@ var _OxyContext = require("../context/OxyContext.js");
|
|
|
11
11
|
var _fonts = require("../styles/fonts.js");
|
|
12
12
|
var _sonner = require("../../lib/sonner");
|
|
13
13
|
var _useFollow = require("../hooks/useFollow.js");
|
|
14
|
-
var
|
|
14
|
+
var _theme2 = require("@oxyhq/bloom/theme");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
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
17
|
// Create animated TouchableOpacity
|
|
18
18
|
const AnimatedTouchableOpacity = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TouchableOpacity);
|
|
19
|
-
const AnimatedText = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Text);
|
|
20
19
|
/**
|
|
21
20
|
* Inner component that handles all hooks and rendering.
|
|
22
21
|
*
|
|
@@ -41,9 +40,10 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
41
40
|
disabled = false,
|
|
42
41
|
showLoadingState = true,
|
|
43
42
|
preventParentActions = true,
|
|
44
|
-
theme = 'light'
|
|
43
|
+
theme: _theme = 'light'
|
|
45
44
|
}) {
|
|
46
|
-
const
|
|
45
|
+
const bloomTheme = (0, _theme2.useTheme)();
|
|
46
|
+
const colors = bloomTheme.colors;
|
|
47
47
|
|
|
48
48
|
// Uses granular Zustand selectors — only re-renders when THIS user's data changes
|
|
49
49
|
const {
|
|
@@ -55,7 +55,6 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
55
55
|
} = (0, _useFollow.useFollowForButton)(userId, oxyServices);
|
|
56
56
|
|
|
57
57
|
// Animation values
|
|
58
|
-
const animationProgress = (0, _reactNativeReanimated.useSharedValue)(isFollowing ? 1 : 0);
|
|
59
58
|
const scale = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
60
59
|
|
|
61
60
|
// Stable press handler — depends on primitives only
|
|
@@ -102,41 +101,38 @@ const FollowButtonInner = /*#__PURE__*/(0, _react.memo)(function FollowButtonInn
|
|
|
102
101
|
}
|
|
103
102
|
}, [userId, fetchStatus]);
|
|
104
103
|
|
|
105
|
-
//
|
|
106
|
-
(0,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, [isFollowing, animationProgress]);
|
|
104
|
+
// Scale-only animated style
|
|
105
|
+
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
106
|
+
transform: [{
|
|
107
|
+
scale: scale.value
|
|
108
|
+
}]
|
|
109
|
+
}));
|
|
112
110
|
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
const
|
|
124
|
-
return {
|
|
125
|
-
color: (0, _reactNativeReanimated.interpolateColor)(animationProgress.value, [0, 1], [colors.text, '#FFFFFF'])
|
|
126
|
-
};
|
|
127
|
-
}, [colors]);
|
|
111
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
112
|
+
// Not following: bg-primary, border-primary, text white
|
|
113
|
+
// Following: bg-background, border-border, text-foreground
|
|
114
|
+
const buttonColorStyle = isFollowing ? {
|
|
115
|
+
backgroundColor: colors.background,
|
|
116
|
+
borderColor: colors.border
|
|
117
|
+
} : {
|
|
118
|
+
backgroundColor: colors.primary,
|
|
119
|
+
borderColor: colors.primary
|
|
120
|
+
};
|
|
121
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
128
122
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
129
123
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
130
124
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedTouchableOpacity, {
|
|
131
|
-
style: [baseButtonStyle,
|
|
125
|
+
style: [baseButtonStyle, buttonColorStyle, animatedStyle],
|
|
132
126
|
onPress: handlePress,
|
|
133
127
|
disabled: disabled || isLoading,
|
|
134
128
|
activeOpacity: 0.8,
|
|
135
129
|
children: showLoadingState && isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
136
130
|
size: "small",
|
|
137
|
-
color:
|
|
138
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
139
|
-
style: [baseTextStyle,
|
|
131
|
+
color: textColor
|
|
132
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
133
|
+
style: [baseTextStyle, {
|
|
134
|
+
color: textColor
|
|
135
|
+
}],
|
|
140
136
|
children: isFollowing ? 'Following' : 'Follow'
|
|
141
137
|
})
|
|
142
138
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_OxyContext","_fonts","_sonner","_useFollow","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_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","AnimatedTouchableOpacity","Animated","createAnimatedComponent","TouchableOpacity","FollowButtonInner","memo","userId","oxyServices","initiallyFollowing","size","onFollowChange","style","textStyle","disabled","showLoadingState","preventParentActions","theme","_theme","bloomTheme","useTheme","colors","isFollowing","isLoading","toggleFollow","setFollowStatus","fetchStatus","useFollowForButton","scale","useSharedValue","handlePress","useCallback","event","preventDefault","stopPropagation","value","withTiming","duration","finished","withSpring","damping","stiffness","err","error","Error","String","toast","message","useEffect","animatedStyle","useAnimatedStyle","transform","buttonColorStyle","backgroundColor","background","borderColor","border","primary","textColor","text","baseButtonStyle","getBaseButtonStyle","baseTextStyle","getBaseTextStyle","jsx","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,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAA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YAAY,EAAE;IAAG,CAAC;EAC3F;EAEA,OAAO,CAACnB,SAAS,EAAEe,SAAS,EAAErF,KAAK,CAAC;AACtC;AAEA,SAASmD,gBAAgBA,CAACrD,IAAY,EAAEG,SAAgC,EAAwB;EAC9F,MAAMiD,aAAwB,GAAG;IAC/BwC,UAAU,EAAEC,mBAAY,CAACC,aAAa;IACtCC,UAAU,EAAE;EACd,CAAC;EAED,IAAIC,aAAwB;EAC5B,IAAIhG,IAAI,KAAK,OAAO,EAAE;IACpBgG,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM,IAAIjG,IAAI,KAAK,OAAO,EAAE;IAC3BgG,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM;IACLD,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC;EAEA,OAAO,CAAC7C,aAAa,EAAE4C,aAAa,EAAE7F,SAAS,CAAC;AAClD;AAAC,IAAA+F,QAAA,GAAA3B,OAAA,CAAAzF,OAAA,GAGc+E,YAAY","ignoreList":[]}
|
|
@@ -2,16 +2,15 @@
|
|
|
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,
|
|
5
|
+
import Animated, { useSharedValue, useAnimatedStyle, withSpring, withTiming } from 'react-native-reanimated';
|
|
6
6
|
import { useOxy } from "../context/OxyContext.js";
|
|
7
7
|
import { fontFamilies } from "../styles/fonts.js";
|
|
8
8
|
import { toast } from '../../lib/sonner';
|
|
9
9
|
import { useFollowForButton } from "../hooks/useFollow.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
// Create animated TouchableOpacity
|
|
13
13
|
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
14
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
15
14
|
/**
|
|
16
15
|
* Inner component that handles all hooks and rendering.
|
|
17
16
|
*
|
|
@@ -36,9 +35,10 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
36
35
|
disabled = false,
|
|
37
36
|
showLoadingState = true,
|
|
38
37
|
preventParentActions = true,
|
|
39
|
-
theme = 'light'
|
|
38
|
+
theme: _theme = 'light'
|
|
40
39
|
}) {
|
|
41
|
-
const
|
|
40
|
+
const bloomTheme = useTheme();
|
|
41
|
+
const colors = bloomTheme.colors;
|
|
42
42
|
|
|
43
43
|
// Uses granular Zustand selectors — only re-renders when THIS user's data changes
|
|
44
44
|
const {
|
|
@@ -50,7 +50,6 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
50
50
|
} = useFollowForButton(userId, oxyServices);
|
|
51
51
|
|
|
52
52
|
// Animation values
|
|
53
|
-
const animationProgress = useSharedValue(isFollowing ? 1 : 0);
|
|
54
53
|
const scale = useSharedValue(1);
|
|
55
54
|
|
|
56
55
|
// Stable press handler — depends on primitives only
|
|
@@ -97,41 +96,38 @@ const FollowButtonInner = /*#__PURE__*/memo(function FollowButtonInner({
|
|
|
97
96
|
}
|
|
98
97
|
}, [userId, fetchStatus]);
|
|
99
98
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}, [isFollowing, animationProgress]);
|
|
99
|
+
// Scale-only animated style
|
|
100
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
101
|
+
transform: [{
|
|
102
|
+
scale: scale.value
|
|
103
|
+
}]
|
|
104
|
+
}));
|
|
107
105
|
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
const
|
|
119
|
-
return {
|
|
120
|
-
color: interpolateColor(animationProgress.value, [0, 1], [colors.text, '#FFFFFF'])
|
|
121
|
-
};
|
|
122
|
-
}, [colors]);
|
|
106
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
107
|
+
// Not following: bg-primary, border-primary, text white
|
|
108
|
+
// Following: bg-background, border-border, text-foreground
|
|
109
|
+
const buttonColorStyle = isFollowing ? {
|
|
110
|
+
backgroundColor: colors.background,
|
|
111
|
+
borderColor: colors.border
|
|
112
|
+
} : {
|
|
113
|
+
backgroundColor: colors.primary,
|
|
114
|
+
borderColor: colors.primary
|
|
115
|
+
};
|
|
116
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
123
117
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
124
118
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
125
119
|
return /*#__PURE__*/_jsx(AnimatedTouchableOpacity, {
|
|
126
|
-
style: [baseButtonStyle,
|
|
120
|
+
style: [baseButtonStyle, buttonColorStyle, animatedStyle],
|
|
127
121
|
onPress: handlePress,
|
|
128
122
|
disabled: disabled || isLoading,
|
|
129
123
|
activeOpacity: 0.8,
|
|
130
124
|
children: showLoadingState && isLoading ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
131
125
|
size: "small",
|
|
132
|
-
color:
|
|
133
|
-
}) : /*#__PURE__*/_jsx(
|
|
134
|
-
style: [baseTextStyle,
|
|
126
|
+
color: textColor
|
|
127
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
128
|
+
style: [baseTextStyle, {
|
|
129
|
+
color: textColor
|
|
130
|
+
}],
|
|
135
131
|
children: isFollowing ? 'Following' : 'Follow'
|
|
136
132
|
})
|
|
137
133
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useCallback","memo","TouchableOpacity","Text","Platform","ActivityIndicator","Animated","useSharedValue","useAnimatedStyle","withSpring","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useCallback","memo","TouchableOpacity","Text","Platform","ActivityIndicator","Animated","useSharedValue","useAnimatedStyle","withSpring","withTiming","useOxy","fontFamilies","toast","useFollowForButton","useTheme","jsx","_jsx","AnimatedTouchableOpacity","createAnimatedComponent","FollowButtonInner","userId","oxyServices","initiallyFollowing","size","onFollowChange","style","textStyle","disabled","showLoadingState","preventParentActions","theme","_theme","bloomTheme","colors","isFollowing","isLoading","toggleFollow","setFollowStatus","fetchStatus","scale","handlePress","event","preventDefault","stopPropagation","value","duration","finished","damping","stiffness","err","error","Error","String","message","animatedStyle","transform","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,OAAOC,QAAQ,IACbC,cAAc,EACdC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAChC,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;AAG9C;AACA,MAAMC,w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,EAAE;IAAG,CAAC;EAC3F;EAEA,OAAO,CAACnB,SAAS,EAAEe,SAAS,EAAEvE,KAAK,CAAC;AACtC;AAEA,SAAS0C,gBAAgBA,CAAC5C,IAAY,EAAEG,SAAgC,EAAwB;EAC9F,MAAMwC,aAAwB,GAAG;IAC/BmC,UAAU,EAAE1F,YAAY,CAAC2F,aAAa;IACtCC,UAAU,EAAE;EACd,CAAC;EAED,IAAIC,aAAwB;EAC5B,IAAIjF,IAAI,KAAK,OAAO,EAAE;IACpBiF,aAAa,GAAG;MAAEC,QAAQ,EAAE;IAAG,CAAC;EAClC,CAAC,MAAM,IAAIlF,IAAI,KAAK,OAAO,EAAE;IAC3BiF,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,EAAE9E,SAAS,CAAC;AAClD;AAEA,SAAS8C,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;AAiBtB,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;AAwHD;;;;;;;;;;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;AAiBtB,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;AAwHD;;;;;;;;;;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.31",
|
|
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,7 +2,6 @@ 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,
|
|
@@ -13,20 +12,17 @@ import Animated, {
|
|
|
13
12
|
useSharedValue,
|
|
14
13
|
useAnimatedStyle,
|
|
15
14
|
withSpring,
|
|
16
|
-
interpolateColor,
|
|
17
|
-
Easing,
|
|
18
15
|
withTiming
|
|
19
16
|
} from 'react-native-reanimated';
|
|
20
17
|
import { useOxy } from '../context/OxyContext';
|
|
21
18
|
import { fontFamilies } from '../styles/fonts';
|
|
22
19
|
import { toast } from '../../lib/sonner';
|
|
23
20
|
import { useFollowForButton } from '../hooks/useFollow';
|
|
24
|
-
import {
|
|
21
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
25
22
|
import type { OxyServices } from '@oxyhq/core';
|
|
26
23
|
|
|
27
24
|
// Create animated TouchableOpacity
|
|
28
25
|
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
29
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
30
26
|
|
|
31
27
|
export interface FollowButtonProps {
|
|
32
28
|
userId: string;
|
|
@@ -65,9 +61,10 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
65
61
|
disabled = false,
|
|
66
62
|
showLoadingState = true,
|
|
67
63
|
preventParentActions = true,
|
|
68
|
-
theme = 'light',
|
|
64
|
+
theme: _theme = 'light',
|
|
69
65
|
}: FollowButtonProps & { oxyServices: OxyServices }) {
|
|
70
|
-
const
|
|
66
|
+
const bloomTheme = useTheme();
|
|
67
|
+
const colors = bloomTheme.colors;
|
|
71
68
|
|
|
72
69
|
// Uses granular Zustand selectors — only re-renders when THIS user's data changes
|
|
73
70
|
const {
|
|
@@ -79,7 +76,6 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
79
76
|
} = useFollowForButton(userId, oxyServices);
|
|
80
77
|
|
|
81
78
|
// Animation values
|
|
82
|
-
const animationProgress = useSharedValue(isFollowing ? 1 : 0);
|
|
83
79
|
const scale = useSharedValue(1);
|
|
84
80
|
|
|
85
81
|
// Stable press handler — depends on primitives only
|
|
@@ -122,44 +118,25 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
122
118
|
}
|
|
123
119
|
}, [userId, fetchStatus]);
|
|
124
120
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Animated styles
|
|
131
|
-
const animatedButtonStyle = useAnimatedStyle(() => {
|
|
132
|
-
return {
|
|
133
|
-
transform: [{ scale: scale.value }],
|
|
134
|
-
backgroundColor: interpolateColor(
|
|
135
|
-
animationProgress.value,
|
|
136
|
-
[0, 1],
|
|
137
|
-
[colors.background, colors.primary]
|
|
138
|
-
),
|
|
139
|
-
borderColor: interpolateColor(
|
|
140
|
-
animationProgress.value,
|
|
141
|
-
[0, 1],
|
|
142
|
-
[colors.border, colors.primary]
|
|
143
|
-
),
|
|
144
|
-
};
|
|
145
|
-
}, [colors]);
|
|
121
|
+
// Scale-only animated style
|
|
122
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
123
|
+
transform: [{ scale: scale.value }],
|
|
124
|
+
}));
|
|
146
125
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
155
|
-
}, [colors]);
|
|
126
|
+
// Colors from bloom theme — follows NativeWind convention via useTheme()
|
|
127
|
+
// Not following: bg-primary, border-primary, text white
|
|
128
|
+
// Following: bg-background, border-border, text-foreground
|
|
129
|
+
const buttonColorStyle: ViewStyle = isFollowing
|
|
130
|
+
? { backgroundColor: colors.background, borderColor: colors.border }
|
|
131
|
+
: { backgroundColor: colors.primary, borderColor: colors.primary };
|
|
132
|
+
const textColor = isFollowing ? colors.text : '#FFFFFF';
|
|
156
133
|
|
|
157
134
|
const baseButtonStyle = getBaseButtonStyle(size, style);
|
|
158
135
|
const baseTextStyle = getBaseTextStyle(size, textStyle);
|
|
159
136
|
|
|
160
137
|
return (
|
|
161
138
|
<AnimatedTouchableOpacity
|
|
162
|
-
style={[baseButtonStyle,
|
|
139
|
+
style={[baseButtonStyle, buttonColorStyle, animatedStyle]}
|
|
163
140
|
onPress={handlePress}
|
|
164
141
|
disabled={disabled || isLoading}
|
|
165
142
|
activeOpacity={0.8}
|
|
@@ -167,12 +144,12 @@ const FollowButtonInner = memo(function FollowButtonInner({
|
|
|
167
144
|
{showLoadingState && isLoading ? (
|
|
168
145
|
<ActivityIndicator
|
|
169
146
|
size="small"
|
|
170
|
-
color={
|
|
147
|
+
color={textColor}
|
|
171
148
|
/>
|
|
172
149
|
) : (
|
|
173
|
-
<
|
|
150
|
+
<Text style={[baseTextStyle, { color: textColor }]}>
|
|
174
151
|
{isFollowing ? 'Following' : 'Follow'}
|
|
175
|
-
</
|
|
152
|
+
</Text>
|
|
176
153
|
)}
|
|
177
154
|
</AnimatedTouchableOpacity>
|
|
178
155
|
);
|