squircle-view 0.0.0-stage → 0.2.0
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/LICENSE +20 -0
- package/README.md +82 -2
- package/SquircleView.podspec +22 -0
- package/android/CMakeLists.txt +17 -0
- package/android/build.gradle +78 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/SquircleGeometryJni.cpp +52 -0
- package/android/src/main/java/com/squircleview/SquircleViewManager.kt +72 -0
- package/android/src/main/java/com/squircleview/SquircleViewPackage.kt +16 -0
- package/android/src/main/java/com/squircleview/geometry/SquircleGeometry.kt +58 -0
- package/android/src/main/java/com/squircleview/style/SquircleStyle.kt +142 -0
- package/android/src/main/java/com/squircleview/views/SquircleView.kt +361 -0
- package/common/cpp/SquircleGeometry.cpp +248 -0
- package/common/cpp/SquircleGeometry.h +75 -0
- package/ios/Geometry/SquirclePath.h +21 -0
- package/ios/Geometry/SquirclePath.mm +39 -0
- package/ios/Layers/SquircleBorderLayer.h +24 -0
- package/ios/Layers/SquircleBorderLayer.m +102 -0
- package/ios/Views/SquircleView.h +16 -0
- package/ios/Views/SquircleView.mm +337 -0
- package/lib/module/components/index.js +4 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/squircle-view.js +22 -0
- package/lib/module/components/squircle-view.js.map +1 -0
- package/lib/module/components/squircle-view.native.js +23 -0
- package/lib/module/components/squircle-view.native.js.map +1 -0
- package/lib/module/constants/index.js +5 -0
- package/lib/module/constants/index.js.map +1 -0
- package/lib/module/constants/native.constants.js +10 -0
- package/lib/module/constants/native.constants.js.map +1 -0
- package/lib/module/constants/squircle.constants.js +5 -0
- package/lib/module/constants/squircle.constants.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces/index.js +5 -0
- package/lib/module/interfaces/index.js.map +1 -0
- package/lib/module/interfaces/squircle-style.interface.js +4 -0
- package/lib/module/interfaces/squircle-style.interface.js.map +1 -0
- package/lib/module/interfaces/squircle-view.interface.js +4 -0
- package/lib/module/interfaces/squircle-view.interface.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/root/index.js +4 -0
- package/lib/module/root/index.js.map +1 -0
- package/lib/module/types/index.js +5 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/native-component-registry.d.js +2 -0
- package/lib/module/types/native-component-registry.d.js.map +1 -0
- package/lib/module/types/native.types.js +4 -0
- package/lib/module/types/native.types.js.map +1 -0
- package/lib/module/types/squircle.types.js +4 -0
- package/lib/module/types/squircle.types.js.map +1 -0
- package/lib/module/utils/index.js +4 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/style.utils.js +22 -0
- package/lib/module/utils/style.utils.js.map +1 -0
- package/lib/module/views/SquircleViewNativeComponent.ts +12 -0
- package/lib/module/views/index.js +15 -0
- package/lib/module/views/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/index.d.ts +2 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/squircle-view.d.ts +5 -0
- package/lib/typescript/src/components/squircle-view.d.ts.map +1 -0
- package/lib/typescript/src/components/squircle-view.native.d.ts +5 -0
- package/lib/typescript/src/components/squircle-view.native.d.ts.map +1 -0
- package/lib/typescript/src/constants/index.d.ts +3 -0
- package/lib/typescript/src/constants/index.d.ts.map +1 -0
- package/lib/typescript/src/constants/native.constants.d.ts +8 -0
- package/lib/typescript/src/constants/native.constants.d.ts.map +1 -0
- package/lib/typescript/src/constants/squircle.constants.d.ts +3 -0
- package/lib/typescript/src/constants/squircle.constants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/interfaces/index.d.ts +3 -0
- package/lib/typescript/src/interfaces/index.d.ts.map +1 -0
- package/lib/typescript/src/interfaces/squircle-style.interface.d.ts +7 -0
- package/lib/typescript/src/interfaces/squircle-style.interface.d.ts.map +1 -0
- package/lib/typescript/src/interfaces/squircle-view.interface.d.ts +10 -0
- package/lib/typescript/src/interfaces/squircle-view.interface.d.ts.map +1 -0
- package/lib/typescript/src/root/index.d.ts +6 -0
- package/lib/typescript/src/root/index.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +3 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/native.types.d.ts +5 -0
- package/lib/typescript/src/types/native.types.d.ts.map +1 -0
- package/lib/typescript/src/types/squircle.types.d.ts +6 -0
- package/lib/typescript/src/types/squircle.types.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/style.utils.d.ts +6 -0
- package/lib/typescript/src/utils/style.utils.d.ts.map +1 -0
- package/lib/typescript/src/views/SquircleViewNativeComponent.d.ts +8 -0
- package/lib/typescript/src/views/SquircleViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/views/index.d.ts +7 -0
- package/lib/typescript/src/views/index.d.ts.map +1 -0
- package/package.json +200 -4
- package/src/components/index.ts +1 -0
- package/src/components/squircle-view.native.tsx +34 -0
- package/src/components/squircle-view.tsx +24 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/native.constants.ts +9 -0
- package/src/constants/squircle.constants.ts +3 -0
- package/src/index.ts +1 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/squircle-style.interface.ts +8 -0
- package/src/interfaces/squircle-view.interface.ts +11 -0
- package/src/root/index.ts +5 -0
- package/src/types/index.ts +2 -0
- package/src/types/native-component-registry.d.ts +15 -0
- package/src/types/native.types.ts +8 -0
- package/src/types/squircle.types.ts +7 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/style.utils.ts +17 -0
- package/src/views/SquircleViewNativeComponent.ts +12 -0
- package/src/views/index.ts +27 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SquircleView } from '../components';
|
|
2
|
+
export type { ISquircleViewProps } from '../interfaces';
|
|
3
|
+
export type { TSquircleViewStyle } from '../types';
|
|
4
|
+
export type { ISquircleViewProps as SquircleViewProps } from '../interfaces';
|
|
5
|
+
export type { TSquircleViewStyle as SquircleViewStyle } from '../types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module 'react-native/Libraries/NativeComponent/NativeComponentRegistry' {
|
|
2
|
+
import type { HostComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface IPartialViewConfig {
|
|
5
|
+
uiViewClassName: string;
|
|
6
|
+
validAttributes: Record<string, boolean>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function get<TProps extends object>(
|
|
10
|
+
name: string,
|
|
11
|
+
viewConfigProvider: () => IPartialViewConfig
|
|
12
|
+
): HostComponent<TProps>;
|
|
13
|
+
|
|
14
|
+
export { get };
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { COMPONENT_NAMES, NATIVE_VIEW_NAMES } from '../constants';
|
|
2
|
+
|
|
3
|
+
type TNativeViewName =
|
|
4
|
+
(typeof NATIVE_VIEW_NAMES)[keyof typeof NATIVE_VIEW_NAMES];
|
|
5
|
+
|
|
6
|
+
type TComponentName = (typeof COMPONENT_NAMES)[keyof typeof COMPONENT_NAMES];
|
|
7
|
+
|
|
8
|
+
export type { TNativeViewName, TComponentName };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './style.utils';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyleSheet, type StyleProp } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ISquircleStyle } from '../interfaces';
|
|
4
|
+
import type { TSquircleViewStyle } from '../types';
|
|
5
|
+
|
|
6
|
+
const splitSquircleStyle = <T extends StyleProp<TSquircleViewStyle>>(
|
|
7
|
+
style: T
|
|
8
|
+
): ISquircleStyle => {
|
|
9
|
+
const flattened = StyleSheet.flatten(style);
|
|
10
|
+
if (flattened?.borderSmoothing === undefined) {
|
|
11
|
+
return { style, borderSmoothing: undefined };
|
|
12
|
+
}
|
|
13
|
+
const { borderSmoothing, ...viewStyle } = flattened;
|
|
14
|
+
return { style: viewStyle, borderSmoothing };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { splitSquircleStyle };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import { codegenNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface INativeSquircleViewProps extends ViewProps {
|
|
5
|
+
borderSmoothing?: CodegenTypes.WithDefault<CodegenTypes.Float, 0>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { INativeSquircleViewProps };
|
|
9
|
+
|
|
10
|
+
export default codegenNativeComponent<INativeSquircleViewProps>(
|
|
11
|
+
'SquircleView'
|
|
12
|
+
) as HostComponent<INativeSquircleViewProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HostComponent } from 'react-native';
|
|
2
|
+
// Registers the codegen view config outside the spec module, so Fast Refresh can re-run this file without registering the view twice.
|
|
3
|
+
// eslint-disable-next-line @react-native/no-deep-imports
|
|
4
|
+
import { get } from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
|
|
5
|
+
|
|
6
|
+
import { NATIVE_VIEW_NAMES } from '../constants';
|
|
7
|
+
import type { INativeSquircleViewProps } from './SquircleViewNativeComponent';
|
|
8
|
+
|
|
9
|
+
type TNativeSquircleView = HostComponent<INativeSquircleViewProps>;
|
|
10
|
+
|
|
11
|
+
const registry = globalThis as typeof globalThis & {
|
|
12
|
+
__squircleViewNativeComponent?: TNativeSquircleView;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const NativeSquircleView: TNativeSquircleView =
|
|
16
|
+
registry.__squircleViewNativeComponent ??
|
|
17
|
+
(registry.__squircleViewNativeComponent = get<INativeSquircleViewProps>(
|
|
18
|
+
NATIVE_VIEW_NAMES.SQUIRCLE_VIEW,
|
|
19
|
+
() => ({
|
|
20
|
+
uiViewClassName: NATIVE_VIEW_NAMES.SQUIRCLE_VIEW,
|
|
21
|
+
validAttributes: { borderSmoothing: true },
|
|
22
|
+
})
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
export type { INativeSquircleViewProps } from './SquircleViewNativeComponent';
|
|
26
|
+
|
|
27
|
+
export { NativeSquircleView };
|