Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Feb 2, 2023
1 parent c7d60db commit d336ce4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module CompatImageButtonBuilders =

View.CompatImageButton<'msg>(aspect, light = light, onClicked = onClicked, ?dark = dark)

static member inline ImageButton<'msg>(aspect: Aspect, light: Stream, onClicked: 'msg, ?dark: Stream) =
static member inline CompatImageButton<'msg>(aspect: Aspect, light: Stream, onClicked: 'msg, ?dark: Stream) =
let light = ImageSource.FromStream(fun () -> light)

let dark =
Expand Down
4 changes: 2 additions & 2 deletions src/Fabulous.Maui/Compatibility/Views/Controls/Entry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ type EntryModifiers =
this.AddScalar(Entry.CursorPosition.WithValue(value))

[<Extension>]
static member inline font
static member inline font<'msg, 'marker when 'marker :> IFabCompatEntry>
(
this: WidgetBuilder<'msg, #IFabCompatEntry>,
this: WidgetBuilder<'msg, 'marker>,
?size: float,
?attributes: FontAttributes,
?fontFamily: string,
Expand Down
22 changes: 21 additions & 1 deletion src/Fabulous.Maui/Compatibility/Views/Controls/FormattedLabel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Fabulous.Maui.Compatibility

open System.Runtime.CompilerServices
open Fabulous
open Fabulous.StackAllocatedCollections
open Microsoft.Maui.Controls

type IFabCompatFormattedLabel =
Expand Down Expand Up @@ -31,4 +32,23 @@ type FormattedLabelModifiers =
/// <summary>Link a ViewRef to access the direct Label control instance</summary>
[<Extension>]
static member inline reference(this: WidgetBuilder<'msg, IFabCompatFormattedLabel>, value: ViewRef<Label>) =
this.AddScalar(ViewRefAttributes.ViewRef.WithValue(value.Unbox))
this.AddScalar(ViewRefAttributes.ViewRef.WithValue(value.Unbox))

[<Extension>]
type FormattedLabelCollectionBuilderExtensions =
[<Extension>]
static member inline Yield<'msg, 'marker, 'itemType when 'marker :> IFabCompatFormattedLabel and 'itemType :> IFabCompatSpan>
(
_: CollectionBuilder<'msg, 'marker, IFabCompatSpan>,
x: WidgetBuilder<'msg, 'itemType>
) : Content<'msg> =
{ Widgets = MutStackArray1.One(x.Compile()) }

[<Extension>]
static member inline Yield<'msg, 'marker, 'itemType when 'marker :> IFabCompatFormattedLabel and 'itemType :> IFabCompatSpan>
(
_: CollectionBuilder<'msg, 'marker, IFabCompatSpan>,
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 @@ -20,6 +20,10 @@ module AbsoluteLayout =

let LayoutFlags =
Attributes.defineBindableEnum<AbsoluteLayoutFlags> AbsoluteLayout.LayoutFlagsProperty

module AbsoluteLayoutAttachedData =
let LayoutBounds =
Attributes.defineMauiAttachedData FabGridLayoutAttachedDataKeys.Column GridLayoutDefaults.Column

[<AutoOpen>]
module AbsoluteLayoutBuilders =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module CompatLayoutOfView =
Attributes.defineListWidgetCollection "LayoutOfWidget_Children" (fun target -> (target :?> Microsoft.Maui.Controls.Layout).Children)

[<Extension>]
type CollectionBuilderExtensions =
type CompatLayoutOfViewCollectionBuilderExtensions =
[<Extension>]
static member inline Yield
(
Expand Down
9 changes: 9 additions & 0 deletions src/Fabulous.Maui/Core/Views/Controls/ImageButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Fabulous.Maui
open Fabulous.Maui.Controls.ImageSources
open Fabulous
open Fabulous.Maui.Controls
open Microsoft.Maui

module ImageButton =
let WidgetKey = Widgets.register<FabImageButton>()
Expand All @@ -17,3 +18,11 @@ 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,
ImageSourcePart.Source.WithValue(FabFileImageSource(source)),
Image.Aspect.WithValue(aspect),
Button.Clicked.WithValue(fun () -> box onClicked)
)
8 changes: 8 additions & 0 deletions src/Fabulous.Maui/Core/Views/Controls/Partials/_TextStyle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ type TextStyleExtraModifiers =
[<Extension>]
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
| Some size, Some fontFamily -> this.font(Font.OfSize(fontFamily, size))
| Some size, None -> this.font(Font.SystemFontOfSize(size))
| None, Some fontFamily -> this.font(Font.OfSize(fontFamily, Font.Default.Size))
| None, None -> this
44 changes: 43 additions & 1 deletion src/Fabulous.Maui/Core/Views/Partials/_Transform.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Fabulous.Maui

open System.Runtime.CompilerServices
open Fabulous
open Microsoft.Maui.Handlers.Defaults
open Fabulous.Maui.Controls

module Transform =
let AnchorX =
Expand Down Expand Up @@ -34,3 +34,45 @@ module Transform =

let TranslationY =
Attributes.defineMauiProperty "TranslationY" TransformDefaults.TranslationY (fun (target: IFabTransform) -> target.SetTranslationY)

[<Extension>]
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))

0 comments on commit d336ce4

Please sign in to comment.