Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ViewRef in extensions #636

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ module FFImageLoadingExtension =
let attribCount = match finish with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match success with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match error with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<CachedImage>) -> Some ref.Unbox

// Populate the attributes of the base element
let attribs =
Expand All @@ -112,7 +115,7 @@ module FFImageLoadingExtension =
?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor,
?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor,
?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId,
?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)
?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)

// Add our own attributes. They must have unique names which must match the names below.
match source with None -> () | Some v -> attribs.Add (CachedImageSourceAttribKey, v)
Expand Down
5 changes: 4 additions & 1 deletion Fabulous.XamarinForms/extensions/Maps/Xamarin.Forms.Maps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ module MapsExtension =
let attribCount = match mapType with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match hasZoomEnabled with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match requestedRegion with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<Xamarin.Forms.Maps.Map>) -> Some ref.Unbox

// Count and populate the inherited attributes
let attribs =
Expand All @@ -56,7 +59,7 @@ module MapsExtension =
?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor,
?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor,
?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId,
?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)
?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)

// Add our own attributes. They must have unique names which must match the names below.
match pins with None -> () | Some v -> attribs.Add(MapPinsAttribKey, v)
Expand Down
5 changes: 4 additions & 1 deletion Fabulous.XamarinForms/extensions/OxyPlot/OxyPlot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module OxyPlotExtension =
// Count the number of additional attributes
let attribCount = 1
let attribCount = match controller with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<PlotView>) -> Some ref.Unbox

// Populate the attributes of the base element
let attribs =
Expand All @@ -47,7 +50,7 @@ module OxyPlotExtension =
?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor,
?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor,
?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId,
?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)
?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)

// Add our own attributes.
attribs.Add(ModelAttribKey, model)
Expand Down
5 changes: 4 additions & 1 deletion Fabulous.XamarinForms/extensions/SkiaSharp/SkiaSharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ module SkiaSharpExtension =
let attribCount = match ignorePixelScaling with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match paintSurface with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match touch with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<SKCanvas>) -> Some ref.Unbox

// Populate the attributes of the base element
let attribs =
Expand All @@ -49,7 +52,7 @@ module SkiaSharpExtension =
?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor,
?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor,
?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId,
?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)
?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)

// Add our own attributes. They must have unique names which must match the names below.
match enableTouchEvents with None -> () | Some v -> attribs.Add(CanvasEnableTouchEventsAttribKey, v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module VideoManagerExtension =
let attribCount = match source with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match videoAspect with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match showControls with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<VideoView>) -> Some ref.Unbox

// Populate the attributes of the base element
let attribs =
Expand All @@ -47,7 +50,7 @@ module VideoManagerExtension =
?shellTabBarDisabledColor=shellTabBarDisabledColor, ?shellTabBarForegroundColor=shellTabBarForegroundColor,
?shellTabBarIsVisible=shellTabBarIsVisible, ?shellTabBarTitleColor=shellTabBarTitleColor, ?shellTabBarUnselectedColor=shellTabBarUnselectedColor,
?shellTitleColor=shellTitleColor, ?shellTitleView=shellTitleView, ?shellUnselectedColor=shellUnselectedColor, ?automationId=automationId,
?classId=classId, ?effects=effects, ?menu=menu, ?ref=ref, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)
?classId=classId, ?effects=effects, ?menu=menu, ?ref=viewRef, ?styleId=styleId, ?tag=tag, ?focused=focused, ?unfocused=unfocused, ?created=created)

// Add our own attributes.
match source with None -> () | Some v -> attribs.Add(SourceAttribKey, v)
Expand Down
5 changes: 4 additions & 1 deletion docs/Fabulous.XamarinForms/views-extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ module MyViewExtensions =
let attribCount = 0
let attribCount = match prop1 with Some _ -> attribCount + 1 | None -> attribCount
let attribCount = match prop2 with Some _ -> attribCount + 1 | None -> attribCount

// Unbox the ViewRef
let viewRef = match ref with None -> None | Some (ref: ViewRef<ABC>) -> Some ref.Unbox

// Populate the attributes of the base element
let attribs = ViewBuilders.BuildBASE(attribCount, ... inherited attributes ... )
let attribs = ViewBuilders.BuildBASE(attribCount, ... inherited attributes (with ?ref=viewRef) ... )

// Add our own attributes.
match prop1 with None -> () | Some v -> attribs.Add (Prop1AttribKey, v)
Expand Down