Skip to content

Commit

Permalink
textVariableAnchor style for SymbolLayer works on iOS (#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDanielTom authored Dec 2, 2023
1 parent d2d4186 commit a20e541
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ios/RNMBX/RNMBXStyleValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,28 @@ class RNMBXStyleValue {
}

func mglStyleValueArrayTextVariableAnchor() -> Value<[TextAnchor]> {
return Value.constant([.left])
guard let value = value as? Dictionary<String,Any> else {
Logger.log(level: .error, message: "Invalid value for array of TextAnchor: \(value)")
return .constant([.left])
}
let valueObj = RNMBXStyleValue.convert(value["stylevalue"] as! [String:Any])

if let valueObj = valueObj as? [String] {
let convertedVal = valueObj.compactMap(TextAnchor.init(rawValue:))
return .constant(convertedVal)
} else {
do {
if valueObj is String {
throw StyleConversionError.unexpectedType(message: "should be array constant or expression")
}
let data = try JSONSerialization.data(withJSONObject: valueObj, options: .prettyPrinted)
let decodedExpression = try JSONDecoder().decode(Expression.self, from: data)
return .expression(decodedExpression)
} catch {
Logger.log(level: .error, message: "Invalid value for array => value: \(value) error: \(error) setting dummy value")
return .constant([.left])
}
}
}

#if RNMBX_11
Expand Down

0 comments on commit a20e541

Please sign in to comment.