diff --git a/Fabulous.XamarinForms.Maps.sln b/Fabulous.XamarinForms.Maps.sln index bd0d295..15c9db8 100644 --- a/Fabulous.XamarinForms.Maps.sln +++ b/Fabulous.XamarinForms.Maps.sln @@ -33,9 +33,9 @@ Global {77D266C1-CEB9-4342-BCCF-C767B4D9C3B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {1C73C577-0B28-46E8-90F6-60868E259B01}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator {1C73C577-0B28-46E8-90F6-60868E259B01}.Release|Any CPU.Build.0 = Release|iPhoneSimulator - {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.ActiveCfg = Debug|iPhone - {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.Build.0 = Debug|iPhone - {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.Deploy.0 = Debug|iPhone + {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator + {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator + {1C73C577-0B28-46E8-90F6-60868E259B01}.Debug|Any CPU.Deploy.0 = Debug|iPhoneSimulator EndGlobalSection GlobalSection(NestedProjects) = preSolution {42433804-9F8B-4F47-9A69-8073E0E7259C} = {C85DF18C-B918-40DA-907C-29F57C72A6D9} diff --git a/src/Fabulous.XamarinForms.Maps.fsproj b/src/Fabulous.XamarinForms.Maps.fsproj index d0e3cb4..a00aa19 100644 --- a/src/Fabulous.XamarinForms.Maps.fsproj +++ b/src/Fabulous.XamarinForms.Maps.fsproj @@ -14,6 +14,7 @@ + diff --git a/src/Map.fs b/src/Map.fs index 62d813b..239efc6 100644 --- a/src/Map.fs +++ b/src/Map.fs @@ -11,6 +11,38 @@ type IMap = module Map = let WidgetKey = Widgets.register () + + let HasScrollEnabled = Attributes.defineBindableBool Map.HasScrollEnabledProperty + let HasZoomEnabled = Attributes.defineBindableBool Map.HasZoomEnabledProperty + let IsShowingUse = Attributes.defineBindableBool Map.IsShowingUserProperty + + let TrafficEnabledProperty = Attributes.defineBindableBool Map.TrafficEnabledProperty + + let MoveToLastRegionOnLayoutChange = Attributes.defineBindableBool Map.MoveToLastRegionOnLayoutChangeProperty + + let MapType = + Attributes.defineEnum + "Map_MapType" + (fun _ newValueOpt node -> + let map = node.Target :?> Map + + let value = + match newValueOpt with + | ValueNone -> MapType.Street + | ValueSome v -> v + + map.MapType <- value) + + let ItemsSource<'T> = + Attributes.defineBindable, System.Collections.Generic.IEnumerable> + Map.ItemsSourceProperty + (fun modelValue -> + seq { + for x in modelValue.OriginalItems do + modelValue.Template x + }) + (fun a b -> ScalarAttributeComparers.equalityCompare a.OriginalItems b.OriginalItems) + [] module MapBuilders = diff --git a/src/Pin.fs b/src/Pin.fs new file mode 100644 index 0000000..df7aca7 --- /dev/null +++ b/src/Pin.fs @@ -0,0 +1,28 @@ +namespace Fabulous.XamarinForms.Maps + +open System.Runtime.CompilerServices +open Fabulous +open Fabulous.StackAllocatedCollections.StackList +open Fabulous.XamarinForms +open Xamarin.Forms.Maps + +type IPin = + inherit Fabulous.XamarinForms.IElement + +module Pin = + let WidgetKey = Widgets.register () + +[] +module PinBuilders = + type Fabulous.XamarinForms.View with + + /// Defines a Pin widget + static member inline Pin<'msg>() = + WidgetBuilder<'msg, IPin>(Pin.WidgetKey, AttributesBundle(StackList.empty (), ValueNone, ValueNone)) + +[] +type PinModifiers = + /// Link a ViewRef to access the direct Pin control instance + [] + static member inline reference(this: WidgetBuilder<'msg, IPin>, value: ViewRef) = + this.AddScalar(ViewRefAttributes.ViewRef.WithValue(value.Unbox))