fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 121 forks source link

OriginalType property support #847

Closed Dolfik1 closed 3 years ago

Dolfik1 commented 3 years ago

I noticed that generator supports OriginalType property, but this property is not exposed. The PR exposes this property.

TimLariviere commented 3 years ago

Would you have an example use case where you require this field exposed? OriginalType is meant as an internal tracking field of the original input type and is driven by InputType.

Dolfik1 commented 3 years ago
{
      "type": "UIKit.UIVisualEffectView",
      "properties": [
        {
          "source": null,
          "name": "Effect",
          "inputType": "IViewElement",
          "originalType": "UIKit.UIVisualEffect",
          "defaultValue": "null"
        }
      ]
    }

the generated code:

        match struct (prevEffectOpt, currEffectOpt) with
        // For structured objects, dependsOn on reference equality
        | struct (ValueSome prevValue, ValueSome newValue) when identical prevValue newValue -> ()
        | struct (ValueSome prevValue, ValueSome newValue) when definition.canReuseView prevValue newValue ->
            newValue.Update(definition, ValueSome prevValue, target.Effect)
        | struct (_, ValueSome newValue) ->
            target.Effect <- (newValue.Create(definition, ValueSome (box target)) :?> UIKit.UIVisualEffect)
        | struct (ValueSome _, ValueNone) ->
            target.Effect <- null
        | struct (ValueNone, ValueNone) -> ()
        ViewUpdaters.UIVisualEffectView.updateContentView definition prevContentViewOpt currContentViewOpt target
TimLariviere commented 3 years ago

@Dolfik1 I've added a few missing pieces for a full support of OriginalType in the mapping file. Will run the checks before merging.

TimLariviere commented 3 years ago

/azp run full build

azure-pipelines[bot] commented 3 years ago
Azure Pipelines successfully started running 1 pipeline(s).