mirror of
https://github.com/status-im/react-native-mapbox-gl.git
synced 2026-08-30 20:41:08 +00:00
106 lines
4.5 KiB
Plaintext
106 lines
4.5 KiB
Plaintext
<%
|
|
const layers = locals.layers;
|
|
-%>
|
|
// DO NOT MODIFY
|
|
// THIS FILE IS AUTOGENERATED
|
|
|
|
package com.mapbox.rctmgl.components.styles;
|
|
|
|
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
|
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
|
|
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
|
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
|
import com.mapbox.mapboxsdk.style.light.Light;
|
|
import com.mapbox.mapboxsdk.style.light.Position;
|
|
|
|
import java.util.List;
|
|
|
|
public class RCTMGLStyleFactory {
|
|
public static final String VALUE_KEY = "value";
|
|
|
|
<%_ for (const layer of layers) { _%>
|
|
public static void <%- setLayerMethodName(layer) -%>(<%- getLayerType(layer, 'android') -%> layer, RCTMGLStyle style) {
|
|
List<String> styleKeys = style.getAllStyleKeys();
|
|
|
|
if (styleKeys.size() == 0) {
|
|
return;
|
|
}
|
|
|
|
for (String styleKey : styleKeys) {
|
|
RCTMGLStyleValue styleValue = style.getStyleValueForKey(styleKey);
|
|
|
|
switch (styleKey) {
|
|
<%_ for (const prop of layer.properties) { _%>
|
|
case "<%= prop.name %>":
|
|
<%_ if (prop.image) { _%>
|
|
style.addImage(styleValue.getString(VALUE_KEY));
|
|
<%_ } _%>
|
|
RCTMGLStyleFactory.set<%- pascelCase(prop.name) -%>(layer, styleValue);
|
|
break;
|
|
<%_ if (prop.transition) { _%>
|
|
case "<%= prop.name %>Transition":
|
|
RCTMGLStyleFactory.set<%- pascelCase(prop.name) -%>Transition(layer, styleValue);
|
|
break;
|
|
<%_ } _%>
|
|
<%_ } _%>
|
|
}
|
|
}
|
|
}
|
|
<%_ } _%>
|
|
|
|
<%_ for (const layer of layers) { _%>
|
|
<%_ for (const prop of layer.properties) { _%>
|
|
public static void set<%- pascelCase(prop.name) -%>(<%- getLayerType(layer, 'android') -%> layer, RCTMGLStyleValue styleValue) {
|
|
<%_ if (prop.allowedFunctionTypes.length > 0) { _%>
|
|
if (styleValue.isFunction()) {
|
|
RCTMGLStyleFunctionParser<<%- androidInputType(prop.type, prop.value) -%>, <%- androidOutputType(prop.type, prop.value) -%>> parser = new RCTMGLStyleFunctionParser<<%- androidInputType(prop.type, prop.value) -%>, <%- androidOutputType(prop.type, prop.value) -%>>(styleValue) {
|
|
@Override
|
|
protected <%- androidInputType(prop.type, prop.value) -%> getRawStopValue(RCTMGLStyleValue styleValue) {
|
|
return <%- androidGetConfigType(androidInputType(prop.type, prop.value)) -%>;
|
|
}
|
|
|
|
@Override
|
|
protected PropertyValue<<%- androidOutputType(prop.type, prop.value) -%>> getStopValue(<%- androidInputType(prop.type, prop.value) -%> value) {
|
|
return PropertyFactory.<%= prop.name %>(value);
|
|
}
|
|
};
|
|
|
|
<%_ if (prop.allowedFunctionTypes.length === 1) { _%>
|
|
layer.setProperties(PropertyFactory.fillPattern(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
|
|
<%_ } else { _%>
|
|
layer.setProperties(PropertyFactory.<%= prop.name %>(styleValue.makeStyleFunction(parser)));
|
|
<%_ } _%>
|
|
} else {
|
|
layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value)) -%>));
|
|
}
|
|
<%_ } else { _%>
|
|
<%_ if (layer.name === 'light' && prop.name === 'position') { _%>
|
|
Float[] values = styleValue.getFloatArray(VALUE_KEY);
|
|
layer.set<%- pascelCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2]));
|
|
<%_ } else if (layer.name === 'light') { _%>
|
|
layer.set<%- pascelCase(prop.name) -%>(<%- androidGetConfigType(androidInputType(prop.type, prop.value)) -%>);
|
|
<%_ } else { _%>
|
|
layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value)) -%>));
|
|
<%_ } _%>
|
|
<%_ } _%>
|
|
}
|
|
|
|
<%_ if (prop.transition) { %>
|
|
public static void set<%- pascelCase(prop.name) -%>Transition(<%- getLayerType(layer, 'android') -%> layer, RCTMGLStyleValue styleValue) {
|
|
TransitionOptions transition = styleValue.getTransition();
|
|
if (transition != null) {
|
|
layer.set<%- pascelCase(prop.name) -%>Transition(transition);
|
|
}
|
|
}
|
|
|
|
<%_ } _%>
|
|
<%_ } _%>
|
|
<%_ } _%>
|
|
}
|