Files
discord-decomp/sources/components_native/common/Carousel.tsx
T
2026-07-28 01:06:53 +03:00

216 lines
11 KiB
TypeScript

/* Metro module 7939; source: components_native/common/Carousel.tsx; dependencies: [6, 7, 15, 17, 18, 31, 27, 33, 4501, 697, 1305, 3868, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Native from '../../external/discord_common/js/packages/tokens/native.tsx'; /* Metro dependency 697 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
import * as NativeModule from '../../external/discord_common/js/packages/design/native.tsx'; /* Metro dependency 3868 */
import * as CreateStylesModule from '../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
function _fun63352(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#63352, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:6, offset: 0x01b7bc06, size: 528 bytes, params: 8, frame: 23
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const createLegacyClassComponentStyles = CreateStylesModule.createLegacyClassComponentStyles;
object = {};
object.container = {alignItems: 'center'};
object.carouselContentWrapper = {flexDirection: 'row'};
object.pageIndicator = {'flexDirection': 'row', 'justifyContent': 'space-around', 'alignItems': 'center'};
const ICON_STRONG = (Native).colors.ICON_STRONG;
object.activeIndicator = {color: ICON_STRONG};
const ICON_SUBTLE = (Native).colors.ICON_SUBTLE;
object.inactiveIndicator = {color: ICON_SUBTLE};
const env0_11 = Reflect.apply(createLegacyClassComponentStyles, CreateStylesModule, [object]);
let Component = value.Component;
const value5 = _fun63357(Component);
const ThemeContext = (NativeModule).ThemeContext;
value5.contextType = ThemeContext;
value5.defaultProps = {'indicatorSpace': 10, 'indicatorSize': 20};
Component = value.Component;
value = _fun63360(Component);
value.contextType = ThemeContext;
value.defaultProps = {'pageIndictor': true, 'width': 375};
(FileImportTrackerModule).fileFinishedImporting('components_native/common/Carousel.tsx');
exports.default = value;
function _callSuper_63353(a0, a1, a2) { // fn#63353, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:225, offset: 0x01b7be16, size: 100 bytes, params: 4, frame: 20
var r0;
var Reflect;
let value = a2;
const value3 = Module00017(a1);
if (_isNativeReflectConstruct_63354()) {
Reflect = global.Reflect;
value = Reflect.construct(value3, value || [], Module00017(a0).constructor);
r0 = value;
} else {
value = value3.apply(a0, value);
r0 = value;
}
return PossibleConstructorReturn(a0, r0);
}
function _isNativeReflectConstruct_63354() { // fn#63354, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:356, offset: 0x01b7be7a, size: 94 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_63354_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun63357(a0) { // fn#63357, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:870, offset: 0x01b7bed8, size: 68 bytes, params: 2, frame: 15
const PageIndicator2 = PageIndicator;
Inherits(PageIndicator2, a0);
return CreateClass(PageIndicator2, [{key: 'render', value: value_63359}]);
function PageIndicator() { // fn#63358, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:882, offset: 0x01b7bf1c, size: 42 bytes, params: 1, frame: 16
env1_2(this, PageIndicator);
return _callSuper_63353(this, PageIndicator, arguments);
}
function value_63359() { // fn#63359, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:1040, offset: 0x01b7bf46, size: 232 bytes, params: 1, frame: 29
var r7;
var r17;
var push;
var jsxRuntimeEnv1_9Binding;
var LegacyText;
var inactiveIndicator;
var activeIndicator;
var value4;
const value2 = env1_11(this.context);
const {count, activeIndex, indicatorSpace, indicatorSize, pageIndicatorStyle} = this.props;
const items2 = [];
const value3 = 0;
if (value3 < count) {
r7 = value3;
while (true) {
push = items2.push;
jsxRuntimeEnv1_9Binding = jsxRuntimeEnv1_9;
LegacyText = (require(1305) /* metro dependency 1305: native */).LegacyText;
if (r7 === activeIndex) {
activeIndicator = value2.activeIndicator;
r17 = activeIndicator;
} else {
inactiveIndicator = value2.inactiveIndicator;
r17 = inactiveIndicator;
}
Reflect.apply(push, items2, [<LegacyText style={[{fontSize: indicatorSize},
r17]} key={r7}>{'•'}</LegacyText>]);
value4 = typeof r7 === 'bigint' ? r7 + 1n : +r7 + 1;
if (value4 < count) {
r7 = value4;
continue;
}
break;
}
}
return (
<View style={[value2.pageIndicator, {width: count * indicatorSpace}, pageIndicatorStyle]}>
{items2}
</View>
);
}
}
function _fun63360(a0) { // fn#63360, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:1483, offset: 0x01b7c02e, size: 68 bytes, params: 2, frame: 15
const Carousel2 = Carousel;
Inherits(Carousel2, a0);
return CreateClass(Carousel2, [{key: 'render', value: value_63363}]);
function Carousel(a0) { // fn#63361, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:1495, offset: 0x01b7c072, size: 92 bytes, params: 2, frame: 18
let value = copyRestArgs(0, undefined);
env1_2(this, Carousel);
const _callSuper_63353Binding = _callSuper_63353;
const items2 = [];
arraySpread(items2, value, 0, value);
value = _callSuper_63353Binding(this, Carousel, items2);
value.state = {activeIndex: 0};
value.onAnimationEnd = onAnimationEnd;
return value;
function onAnimationEnd({nativeEvent}) { // fn#63362, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:1625, owner: Carousel.onAnimationEnd, offset: 0x01b7c0ce, size: 118 bytes, params: 2, frame: 14
const Math = global.Math;
const round = Math.round;
const x = nativeEvent.contentOffset.x;
const binding = env0_0;
const value2 = Reflect.apply(round, Math, [x / binding.props.width]);
binding.setState({activeIndex: value2});
if (binding.props.onPageChange != null) {
env0_0.props.onPageChange(value2);
}
}
}
function value_63363() { // fn#63363, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8117:1827, offset: 0x01b7c144, size: 320 bytes, params: 1, frame: 22
var environment;
let value = environment.__proto__;
const binding = env1_11;
const context = this.context;
const value2 = undefined;
const value3 = binding(context);
const pageIndicatorStyle = this.props.pageIndicatorStyle;
const length = this.props.children.length;
const r5 = (
this.props.pageIndictor === true && length > 1
? ((Component) => <Component count={length} activeIndex={this.state.activeIndex} pageIndicatorStyle={pageIndicatorStyle} />)(env1_12)
: value2
);
const r8 = this.props.scrollViewProps ?? ({});
const items2 = [value3.container];
items2[1] = this.props.style;
const scrollViewBindingProps2 = {'automaticallyAdjustContentInsets': false, 'horizontal': true,
'pagingEnabled': true, 'scrollEnabled': null, 'nestedScrollEnabled': true,
'showsHorizontalScrollIndicator': false, scrollEnabled: length > 1, onMomentumScrollEnd: this.onAnimationEnd,
...r8};
value = (
<View style={value3.carouselContentWrapper} onStartShouldSetResponder={function() {
return true;
}}>
{this.props.children}
</View>
);
value = (
<ScrollView {...scrollViewBindingProps2}>
{value}
</ScrollView>
);
return (
<View style={items2}>
{value}
{r5}
</View>
);
}
}
}
global.__d(_fun63352, 7939, [6, 7, 15, 17, 18, 31, 27, 33, 4501, 697, 1305, 3868,
2]) /* metro module 7939, dependencies: [6, 7, 15, 17, 18, 31, 27, 33, 4501, 697, 1305, 3868, 2] */;