Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Feb 2, 2023
1 parent a6db146 commit 3897b85
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/Fabulous.Maui/AppHostBuilderExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module FabulousHandlers =
| FabGridLayoutAttachedDataKeys.Row -> Microsoft.Maui.Controls.Grid.RowProperty
| FabGridLayoutAttachedDataKeys.RowSpan -> Microsoft.Maui.Controls.Grid.RowSpanProperty
| _ -> failwith $"Unknown key {key}"

let getDefaultValueByKey (key: string) =
match key with
| FabGridLayoutAttachedDataKeys.Column -> box GridLayoutDefaults.Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ type FormattedLabelYieldExtensions =
x: WidgetBuilder<'msg, Memo.Memoized<'itemType>>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ type GestureElementYieldExtensions =
x: WidgetBuilder<'msg, #IFabCompatGestureRecognizer>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }

[<Extension>]
static member inline Yield
(
_: AttributeCollectionBuilder<'msg, #IFabCompatGestureElement, IFabCompatGestureRecognizer>,
x: WidgetBuilder<'msg, Memo.Memoized<#IFabCompatGestureRecognizer>>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
{ Widgets = MutStackArray1.One(x.Compile()) }
11 changes: 7 additions & 4 deletions src/Fabulous.Maui/Compatibility/Views/Layouts/AbsoluteLayout.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ type IFabCompatAbsoluteLayout =
inherit IAbsoluteLayout

module FabCompatAbsoluteLayoutAttachedDataKeys =
let [<Literal>] LayoutBounds = "FabCompatAbsoluteLayout_LayoutBounds"
let [<Literal>] LayoutFlags = "FabCompatAbsoluteLayout_LayoutFlags"
[<Literal>]
let LayoutBounds = "FabCompatAbsoluteLayout_LayoutBounds"

[<Literal>]
let LayoutFlags = "FabCompatAbsoluteLayout_LayoutFlags"

module AbsoluteLayout =
let WidgetKey = CompatWidgets.register<AbsoluteLayout>()

module AbsoluteLayoutAttachedData =
let LayoutBounds =
SharedAttributes.defineAttachedData<Rect> FabCompatAbsoluteLayoutAttachedDataKeys.LayoutBounds

let LayoutFlags =
SharedAttributes.defineAttachedData<AbsoluteLayoutFlags> FabCompatAbsoluteLayoutAttachedDataKeys.LayoutFlags

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@ module CompatLayoutOfView =
[<Extension>]
type CompatLayoutOfViewYieldExtensions =
[<Extension>]
static member inline Yield
(
_: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>,
x: WidgetBuilder<'msg, 'itemType>
) : Content<'msg> =
static member inline Yield(_: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>, x: WidgetBuilder<'msg, 'itemType>) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }

[<Extension>]
static member inline Yield
(
_: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>,
x: WidgetBuilder<'msg, Memo.Memoized<#IView>>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
static member inline Yield(_: CollectionBuilder<'msg, #IFabCompatLayoutOfView, IView>, x: WidgetBuilder<'msg, Memo.Memoized<#IView>>) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
8 changes: 2 additions & 6 deletions src/Fabulous.Maui/Compatibility/Views/Pages/NavigationPage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,5 @@ type NavigationPagePlatformModifiers =
[<Extension>]
type NavigationPageYieldExtensions =
[<Extension>]
static member inline Yield
(
_: CollectionBuilder<'msg, 'marker, #IFabCompatPage>,
x: WidgetBuilder<'msg, Memo.Memoized<'itemType>>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
static member inline Yield(_: CollectionBuilder<'msg, 'marker, #IFabCompatPage>, x: WidgetBuilder<'msg, Memo.Memoized<'itemType>>) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
4 changes: 2 additions & 2 deletions src/Fabulous.Maui/Compatibility/Views/_CompatView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ type CompatViewYieldExtensions =
x: WidgetBuilder<'msg, #IFabCompatGestureRecognizer>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }

[<Extension>]
static member inline Yield
(
_: AttributeCollectionBuilder<'msg, #IFabCompatView, IFabCompatGestureRecognizer>,
x: WidgetBuilder<'msg, Memo.Memoized<#IFabCompatGestureRecognizer>>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }
{ Widgets = MutStackArray1.One(x.Compile()) }
8 changes: 2 additions & 6 deletions src/Fabulous.Maui/Core/Attributes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ module Attributes =
if element.Handler <> null then
element.Handler.UpdateValue(propertyName))

let inline defineMauiFuncBool<'target, 'args>
(propertyName: string)
(defaultValue: Func<bool>)
([<InlineIfLambda>] set: 'target -> Func<bool> -> unit)
=
let inline defineMauiFuncBool<'target, 'args> (propertyName: string) (defaultValue: Func<bool>) ([<InlineIfLambda>] set: 'target -> Func<bool> -> unit) =
Attributes.defineSimpleScalar
$"{typeof<'target>.Name}_{propertyName}"
ScalarAttributeComparers.noCompare
Expand All @@ -67,7 +63,7 @@ module Attributes =
| ValueNone -> set target defaultValue
| ValueSome curr ->
let fn () =
let r = curr ()
let r = curr()
Dispatcher.dispatch node r
true

Expand Down
9 changes: 3 additions & 6 deletions src/Fabulous.Maui/Core/Views/Controls/Image.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ module Image =
[<AutoOpen>]
module ImageBuilders =
type Fabulous.Maui.View with

static member inline Image(file: string) =
WidgetBuilder<'msg, IFabImage>(Image.WidgetKey, ImageSourcePart.Source.WithValue(FabFileImageSource(file)))

static member inline Image(file: string, aspect: Aspect) =
WidgetBuilder<'msg, IFabImage>(
Image.WidgetKey,
ImageSourcePart.Source.WithValue(FabFileImageSource(file)),
Image.Aspect.WithValue(aspect)
)
WidgetBuilder<'msg, IFabImage>(Image.WidgetKey, ImageSourcePart.Source.WithValue(FabFileImageSource(file)), Image.Aspect.WithValue(aspect))

[<Extension>]
type ImageModifiers =
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.Maui/Core/Views/Controls/ImageButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module ImageButtonBuilders =
ImageSourcePart.Source.WithValue(FabFileImageSource(source)),
Button.Clicked.WithValue(fun () -> box onClicked)
)

static member inline ImageButton<'msg>(source: string, onClicked: 'msg, aspect: Aspect) =
WidgetBuilder<'msg, IFabImageButton>(
ImageButton.WidgetKey,
Expand Down
4 changes: 2 additions & 2 deletions src/Fabulous.Maui/Core/Views/Controls/Partials/_Button.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ open Fabulous.Maui.Controls
module Button =
let Clicked =
Attributes.defineMauiAction "Clicked" ButtonDefaults.OnClicked (fun (target: IFabButton) -> target.SetOnClicked)

let Pressed =
Attributes.defineMauiAction "Pressed" ButtonDefaults.OnPressed (fun (target: IFabButton) -> target.SetOnPressed)

let Released =
Attributes.defineMauiAction "Released" ButtonDefaults.OnReleased (fun (target: IFabButton) -> target.SetOnReleased)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ButtonStrokeModifiers =
[<Extension>]
static member strokeColor(this: WidgetBuilder<'msg, #IFabButtonStroke>, value: FabColor) =
this.AddScalar(ButtonStroke.StrokeColor.WithValue(value.ToMauiColor()))

[<Extension>]
static member strokeThickness(this: WidgetBuilder<'msg, #IFabButtonStroke>, value: float) =
this.AddScalar(ButtonStroke.StrokeThickness.WithValue(value))
this.AddScalar(ButtonStroke.StrokeThickness.WithValue(value))
5 changes: 2 additions & 3 deletions src/Fabulous.Maui/Core/Views/Controls/Partials/_TextStyle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ type TextStyleModifiers =
[<Extension>]
type TextStyleExtraModifiers =
[<Extension>]
static member inline textColor(this: WidgetBuilder<'msg, #IFabTextStyle>, value: FabColor) =
this.textColor(value.ToMauiColor())

static member inline textColor(this: WidgetBuilder<'msg, #IFabTextStyle>, value: FabColor) = this.textColor(value.ToMauiColor())

[<Extension>]
static member inline font(this: WidgetBuilder<'msg, #IFabTextStyle>, ?size: float, ?fontFamily: string) =
match size, fontFamily with
Expand Down
3 changes: 1 addition & 2 deletions src/Fabulous.Maui/Core/Views/Layouts/Grid.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ module GridAttachedData =
let ColumnSpan =
SharedAttributes.defineAttachedData FabGridLayoutAttachedDataKeys.ColumnSpan

let Row =
SharedAttributes.defineAttachedData FabGridLayoutAttachedDataKeys.Row
let Row = SharedAttributes.defineAttachedData FabGridLayoutAttachedDataKeys.Row

let RowSpan =
SharedAttributes.defineAttachedData FabGridLayoutAttachedDataKeys.RowSpan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module BorderStroke =
type BorderStrokeModifiers =
[<Extension>]
static member shape(this: WidgetBuilder<'msg, #IFabBorderStroke>, shape: IShape) =
this.AddScalar(BorderStroke.Shape.WithValue(shape))
this.AddScalar(BorderStroke.Shape.WithValue(shape))
16 changes: 8 additions & 8 deletions src/Fabulous.Maui/Core/Views/Layouts/Partials/_Stroke.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,33 @@ type StrokeModifiers =
[<Extension>]
static member stroke(this: WidgetBuilder<'msg, #IFabStroke>, value: Paint) =
this.AddScalar(Stroke.Stroke.WithValue(value))

[<Extension>]
static member strokeThickness(this: WidgetBuilder<'msg, #IFabStroke>, value: float) =
this.AddScalar(Stroke.StrokeThickness.WithValue(value))

[<Extension>]
static member strokeLineCap(this: WidgetBuilder<'msg, #IFabStroke>, value: LineCap) =
this.AddScalar(Stroke.StrokeLineCap.WithValue(value))

[<Extension>]
static member strokeLineJoin(this: WidgetBuilder<'msg, #IFabStroke>, value: LineJoin) =
this.AddScalar(Stroke.StrokeLineJoin.WithValue(value))

[<Extension>]
static member strokeDashPattern(this: WidgetBuilder<'msg, #IFabStroke>, value: float list) =
this.AddScalar(Stroke.StrokeDashPattern.WithValue(value |> List.map float32 |> List.toArray))

[<Extension>]
static member strokeDashOffset(this: WidgetBuilder<'msg, #IFabStroke>, value: float) =
this.AddScalar(Stroke.StrokeDashOffset.WithValue(float32 value))

[<Extension>]
static member strokeMiterLimit(this: WidgetBuilder<'msg, #IFabStroke>, value: float) =
this.AddScalar(Stroke.StrokeMiterLimit.WithValue(float32 value))

[<Extension>]
type StrokeExtraModifiers =
[<Extension>]
static member stroke(this: WidgetBuilder<'msg, #IFabStroke>, value: FabColor) =
this.stroke(SolidPaint(value.ToMauiColor()))
this.stroke(SolidPaint(value.ToMauiColor()))
20 changes: 10 additions & 10 deletions src/Fabulous.Maui/Core/Views/Partials/_Transform.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,39 @@ type TransformModifiers =
[<Extension>]
static member anchorX(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.AnchorX.WithValue(value))

[<Extension>]
static member anchorY(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.AnchorY.WithValue(value))

[<Extension>]
static member rotation(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.Rotation.WithValue(value))

[<Extension>]
static member rotationX(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.RotationX.WithValue(value))

[<Extension>]
static member rotationY(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.RotationY.WithValue(value))

[<Extension>]
static member scale(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.Scale.WithValue(value))

[<Extension>]
static member scaleX(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.ScaleX.WithValue(value))

[<Extension>]
static member scaleY(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.ScaleY.WithValue(value))

[<Extension>]
static member translationX(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.TranslationX.WithValue(value))

[<Extension>]
static member translationY(this: WidgetBuilder<'msg, #IFabTransform>, value: float) =
this.AddScalar(Transform.TranslationY.WithValue(value))
this.AddScalar(Transform.TranslationY.WithValue(value))
33 changes: 13 additions & 20 deletions src/Fabulous.Maui/Core/Views/Partials/_View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ type ViewExtraModifiers =

[<Extension>]
static member inline center(this: WidgetBuilder<'msg, #IFabView>) =
this
.centerHorizontal()
.centerVertical()
this.centerHorizontal().centerVertical()

[<Extension>]
static member inline alignStartHorizontal(this: WidgetBuilder<'msg, #IFabView>) =
Expand All @@ -183,19 +181,19 @@ type ViewExtraModifiers =
[<Extension>]
static member inline alignStartVertical(this: WidgetBuilder<'msg, #IFabView>) =
this.verticalLayoutAlignment(LayoutAlignment.Start)

[<Extension>]
static member inline alignEndHorizontal(this: WidgetBuilder<'msg, #IFabView>) =
this.horizontalLayoutAlignment(LayoutAlignment.End)

[<Extension>]
static member inline alignEndVertical(this: WidgetBuilder<'msg, #IFabView>) =
this.verticalLayoutAlignment(LayoutAlignment.End)

[<Extension>]
static member inline fillHorizontal(this: WidgetBuilder<'msg, #IFabView>) =
this.horizontalLayoutAlignment(LayoutAlignment.Fill)

[<Extension>]
static member inline fillVertical(this: WidgetBuilder<'msg, #IFabView>) =
this.verticalLayoutAlignment(LayoutAlignment.Fill)
Expand All @@ -210,22 +208,17 @@ type ViewExtraModifiers =
[<Extension>]
static member margin(this: WidgetBuilder<'msg, #IFabView>, left: float, top: float, right: float, bottom: float) =
this.margin(Thickness(left, top, right, bottom))

[<Extension>]
static member inline size(this: WidgetBuilder<'msg, #IFabView>, ?width: float, ?height: float) =
match width, height with
| None, None -> this
| Some w, None -> this.AddScalar(View'.Width.WithValue(w))
| None, Some h -> this.AddScalar(View'.Height.WithValue(h))
| Some w, Some h ->
this
.AddScalar(View'.Width.WithValue(w))
.AddScalar(View'.Height.WithValue(h))

[<Extension>]
static member inline background(this: WidgetBuilder<'msg, #IFabView>, value: Color) =
this.background(SolidPaint(value))

[<Extension>]
static member inline background(this: WidgetBuilder<'msg, #IFabView>, value: FabColor) =
this.background(value.ToMauiColor())
| Some w, Some h -> this.AddScalar(View'.Width.WithValue(w)).AddScalar(View'.Height.WithValue(h))

[<Extension>]
static member inline background(this: WidgetBuilder<'msg, #IFabView>, value: Color) = this.background(SolidPaint(value))

[<Extension>]
static member inline background(this: WidgetBuilder<'msg, #IFabView>, value: FabColor) = this.background(value.ToMauiColor())
Loading

0 comments on commit 3897b85

Please sign in to comment.