Skip to content

Commit

Permalink
refactor: code improvements (#3117)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfazekas authored Oct 18, 2023
1 parent e87beed commit 8fc47c6
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class RNMBXSkyLayerManager : ViewGroupManager<RNMBXSkyLayer>(),
layer.setReactStyle(style.asMap())
}

// not available
// @ReactProp(name = "sourceLayerID")
// override fun setSourceLayerId(layer: RNMBXSkyLayer, sourceLayerID: Dynamic) {
// layer.setSourceLayerID(sourceLayerID.asString())
// }

@ReactProp(name = "filter")
override fun setFilter(layer: RNMBXSkyLayer, filterList: Dynamic) {
layer.setFilter(filterList.asArray())
Expand Down
15 changes: 9 additions & 6 deletions src/specs/RNMBXBackgroundLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
25 changes: 14 additions & 11 deletions src/specs/RNMBXCameraNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {

import type { NativeCameraStop, UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

type UserTrackingModeChangeEventType = {
type: string;
payloadRenamed: {
Expand All @@ -18,21 +21,21 @@ type UserTrackingModeChangeEventType = {

export interface NativeProps extends ViewProps {
maxBounds?: UnsafeMixed<string | null>;
animationDuration?: UnsafeMixed<Double>;
animationMode?: UnsafeMixed<string>;
animationDuration?: OptionalProp<Double>;
animationMode?: OptionalProp<string>;
defaultStop?: UnsafeMixed<NativeCameraStop>;
userTrackingMode?: UnsafeMixed<Int32>;
userTrackingMode?: OptionalProp<Int32>;

followUserLocation?: UnsafeMixed<boolean>;
followUserMode?: UnsafeMixed<string>;
followZoomLevel?: UnsafeMixed<Double>;
followPitch?: UnsafeMixed<Double>;
followHeading?: UnsafeMixed<Double>;
followUserLocation?: OptionalProp<boolean>;
followUserMode?: OptionalProp<string>;
followZoomLevel?: OptionalProp<Double>;
followPitch?: OptionalProp<Double>;
followHeading?: OptionalProp<Double>;
followPadding?: UnsafeMixed<any>;

zoomLevel?: UnsafeMixed<Double>;
maxZoomLevel?: UnsafeMixed<Double>;
minZoomLevel?: UnsafeMixed<Double>;
zoomLevel?: OptionalProp<Double>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
stop?: UnsafeMixed<NativeCameraStop>;

onUserTrackingModeChange?: DirectEventHandler<UserTrackingModeChangeEventType>;
Expand Down
19 changes: 11 additions & 8 deletions src/specs/RNMBXCircleLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
sourceID: OptionalProp<string>;
existing: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID: OptionalProp<string>;
belowLayerID: OptionalProp<string>;
layerIndex: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel: OptionalProp<Double>;
minZoomLevel: OptionalProp<Double>;
sourceLayerID: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
21 changes: 12 additions & 9 deletions src/specs/RNMBXFillExtrusionLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
id?: UnsafeMixed<string>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
sourceLayerID?: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
19 changes: 11 additions & 8 deletions src/specs/RNMBXFillLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
sourceLayerID?: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
21 changes: 12 additions & 9 deletions src/specs/RNMBXHeatmapLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
id: OptionalProp<string>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
sourceLayerID?: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
19 changes: 11 additions & 8 deletions src/specs/RNMBXLineLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
sourceLayerID?: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
33 changes: 18 additions & 15 deletions src/specs/RNMBXMapViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,50 @@ import {

import type { LocalizeLabels, Point, UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

type OnCameraChangedEventType = { type: string; payload: string };
type OnPressEventType = { type: string; payload: string };
type OnMapChangeEventType = { type: string; payload: string };

export interface NativeProps extends ViewProps {
onCameraChanged?: DirectEventHandler<OnCameraChangedEventType>;

attributionEnabled?: UnsafeMixed<boolean>;
attributionEnabled?: OptionalProp<boolean>;
attributionPosition?: UnsafeMixed<any>;

logoEnabled?: UnsafeMixed<boolean>;
logoEnabled?: OptionalProp<boolean>;
logoPosition?: UnsafeMixed<any>;

compassEnabled?: UnsafeMixed<boolean>;
compassFadeWhenNorth?: UnsafeMixed<boolean>;
compassEnabled?: OptionalProp<boolean>;
compassFadeWhenNorth?: OptionalProp<boolean>;
compassPosition?: UnsafeMixed<any>;
compassViewPosition?: UnsafeMixed<Int32>;
compassViewMargins?: UnsafeMixed<Point>;
compassViewPosition?: OptionalProp<Int32>;
compassViewMargins?: OptionalProp<Point>;

scaleBarEnabled?: UnsafeMixed<boolean>;
scaleBarEnabled?: OptionalProp<boolean>;
scaleBarPosition?: UnsafeMixed<any>;

zoomEnabled?: UnsafeMixed<boolean>;
scrollEnabled?: UnsafeMixed<boolean>;
rotateEnabled?: UnsafeMixed<boolean>;
pitchEnabled?: UnsafeMixed<boolean>;
zoomEnabled?: OptionalProp<boolean>;
scrollEnabled?: OptionalProp<boolean>;
rotateEnabled?: OptionalProp<boolean>;
pitchEnabled?: OptionalProp<boolean>;

requestDisallowInterceptTouchEvent?: UnsafeMixed<boolean>;
requestDisallowInterceptTouchEvent?: OptionalProp<boolean>;

projection?: UnsafeMixed<string>;
projection?: OptionalProp<string>;
localizeLabels?: UnsafeMixed<LocalizeLabels>;

styleURL?: UnsafeMixed<string>;
styleURL?: OptionalProp<string>;

// Android only
scaleBarViewMargins?: UnsafeMixed<any>;
attributionViewMargins?: UnsafeMixed<any>;
attributionViewPosition?: UnsafeMixed<any>;

// iOS only
compassImage?: UnsafeMixed<string>;
compassImage?: OptionalProp<string>;

onPress?: DirectEventHandler<OnPressEventType>;
onLongPress?: DirectEventHandler<OnPressEventType>;
Expand Down
21 changes: 12 additions & 9 deletions src/specs/RNMBXRasterLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
id: OptionalProp<string>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle: UnsafeMixed<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
sourceLayerID: UnsafeMixed<string>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
sourceLayerID?: OptionalProp<string>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
21 changes: 12 additions & 9 deletions src/specs/RNMBXSkyLayerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';

import type { UnsafeMixed } from './codegenUtils';

// see https://github.com/rnmapbox/maps/wiki/FabricOptionalProp
type OptionalProp<T> = UnsafeMixed<T>;

export interface NativeProps extends ViewProps {
id: UnsafeMixed<string>;
sourceID: UnsafeMixed<string>;
existing: UnsafeMixed<boolean>;
id?: OptionalProp<string>;
sourceID?: OptionalProp<string>;
existing?: OptionalProp<boolean>;
filter: UnsafeMixed<any[]>;

aboveLayerID: UnsafeMixed<string>;
belowLayerID: UnsafeMixed<string>;
layerIndex: UnsafeMixed<Int32>;
reactStyle: UnsafeMixed<any>;
aboveLayerID?: OptionalProp<string>;
belowLayerID?: OptionalProp<string>;
layerIndex?: OptionalProp<Int32>;
reactStyle?: OptionalProp<any>;

maxZoomLevel: UnsafeMixed<Double>;
minZoomLevel: UnsafeMixed<Double>;
maxZoomLevel?: OptionalProp<Double>;
minZoomLevel?: OptionalProp<Double>;
}

export default codegenNativeComponent<NativeProps>(
Expand Down
Loading

0 comments on commit 8fc47c6

Please sign in to comment.