Skip to content

Commit

Permalink
Use Fabulous 3.0.0-pre6
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Oct 24, 2024
1 parent 8dd64e4 commit 02e5254
Show file tree
Hide file tree
Showing 42 changed files with 207 additions and 93 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [8.1.0-pre18] - 2024-09-24

### Fixed
- Use Fabulous 3.0.0-pre6

## [8.1.0-pre17] - 2024-03-26

### Fixed
Expand Down Expand Up @@ -240,7 +245,8 @@ Essentially v2.8.1 and v8.0.0 are similar except for the required .NET version.
### Changed
- Fabulous.MauiControls has moved from the Fabulous repository to its own repository: [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)

[unreleased]: https://github.com/fabulous-dev/Fabulous.MauiControls/compare/8.1.0-pre17...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous.MauiControls/compare/8.1.0-pre18...HEAD
[8.1.0-pre18]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre18
[8.1.0-pre17]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre17
[8.1.0-pre16]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre16
[8.1.0-pre15]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre15
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Fabulous" Version="3.0.0-pre2" />
<PackageVersion Include="Fabulous" Version="3.0.0-pre6" />
<PackageVersion Include="FsCheck.NUnit" Version="2.16.6" />
<PackageVersion Include="FSharp.Core" Version="8.0.200" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Fabulous.MauiControls/AppHostBuilderExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type AppHostBuilderExtensions =
program.State.Logger,
program.SyncAction,
fun () ->
(View.Component(program.State, arg) {
(View.Component("_", program.State, arg) {
let! model = Mvu.State
program.View model
})
Expand All @@ -60,7 +60,7 @@ type AppHostBuilderExtensions =
program.State.Logger,
program.SyncAction,
fun () ->
(View.Component(program.State, arg) {
(View.Component("_", program.State, arg) {
let! model = Mvu.State
program.View model
})
Expand Down Expand Up @@ -90,5 +90,5 @@ type AppHostBuilderExtensions =
(match syncAction with
| Some synAction -> synAction
| None -> MauiViewHelpers.defaultSyncAction),
fun () -> (View.Component() { view() }).Compile()
fun () -> (View.Component("_") { view() }).Compile()
)
9 changes: 3 additions & 6 deletions src/Fabulous.MauiControls/Attributes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ module MsgValueEventData =
let create (value: 'data) (event: 'eventArgs -> 'msg) =
{ Value = value
Event = event >> box >> MsgValue }

[<Struct>]
type ValueEventData<'data, 'eventArgs> =
{ Value: 'data
Event: 'eventArgs -> unit }

module ValueEventData =
let create (value: 'data) (event: 'eventArgs -> unit) =
{ Value = value
Event = event }
let create (value: 'data) (event: 'eventArgs -> unit) = { Value = value; Event = event }

/// Maui.Controls specific attributes that can be encoded as 8 bytes
module SmallScalars =
Expand Down Expand Up @@ -249,8 +247,7 @@ module Attributes =
// Set the new event handler
let event = getEvent target

let handler =
event.Subscribe(curr.Event)
let handler = event.Subscribe(curr.Event)

node.SetHandler(name, handler))
)
Expand Down
23 changes: 16 additions & 7 deletions src/Fabulous.MauiControls/Component.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ module Component =
module ComponentBuilders =
type Fabulous.Maui.View with

static member inline Component<'msg, 'marker when 'msg : equality>() = ComponentBuilder<'msg>()

static member inline Component<'msg, 'model, 'marker, 'parentMsg when 'msg : equality and 'parentMsg : equality>(program: Program<unit, 'model, 'msg>) =
MvuComponentBuilder<unit, 'msg, 'model, 'marker, 'parentMsg>(program, ())

static member inline Component<'arg, 'msg, 'model, 'marker, 'parentMsg when 'msg : equality and 'parentMsg : equality>(program: Program<'arg, 'model, 'msg>, arg: 'arg) =
MvuComponentBuilder<'arg, 'msg, 'model, 'marker, 'parentMsg>(program, arg)
static member inline Component<'msg, 'marker when 'msg: equality>(key: string) = ComponentBuilder<'msg>(key)

static member inline Component<'msg, 'model, 'marker, 'parentMsg when 'msg: equality and 'parentMsg: equality>
(
key: string,
program: Program<unit, 'model, 'msg>
) =
MvuComponentBuilder<unit, 'msg, 'model, 'marker, 'parentMsg>(key, program, ())

static member inline Component<'arg, 'msg, 'model, 'marker, 'parentMsg when 'msg: equality and 'parentMsg: equality>
(
key: string,
program: Program<'arg, 'model, 'msg>,
arg: 'arg
) =
MvuComponentBuilder<'arg, 'msg, 'model, 'marker, 'parentMsg>(key, program, arg)
4 changes: 2 additions & 2 deletions src/Fabulous.MauiControls/Fabulous.MauiControls.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<UseLocalProjectReference>true</UseLocalProjectReference>
<UseLocalProjectReference>false</UseLocalProjectReference>

<TargetFramework>net8.0</TargetFramework>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -157,7 +157,7 @@
This version will be used as the lower bound in the NuGet package
-->
<PackageReference Include="FSharp.Core" VersionOverride="8.0.100" PrivateAssets="All" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[3.0.0-pre2]" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[3.0.0-pre6]" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="Microsoft.Maui.Controls" VersionOverride="8.0.3" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" VersionOverride="8.0.3" />
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.MauiControls/Style.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type FabElementExtensions =
/// <param name="this">Current widget</param>
/// <param name="fn">The style modifier function</param>
[<Extension>]
static member inline style<'msg, 'marker when 'msg : equality and 'marker :> IFabElement>
static member inline style<'msg, 'marker when 'msg: equality and 'marker :> IFabElement>
(
this: WidgetBuilder<'msg, 'marker>,
fn: WidgetBuilder<'msg, 'marker> -> WidgetBuilder<'msg, 'marker>
Expand Down
10 changes: 10 additions & 0 deletions src/Fabulous.MauiControls/Views/Any.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ module AnyBuilders =
/// <param name="this">Current widget</param>
static member AnyCell(this: WidgetBuilder<'msg, Memo.Memoized<#IFabCell>>) =
WidgetBuilder<'msg, IFabCell>(this.Key, this.Attributes)

/// <summary>Downcast to Shape widget to allow to return different types of shapes in a single expression (e.g. if/else, match with pattern, etc.)</summary>
/// <param name="this">Current widget</param>
static member AnyShape(this: WidgetBuilder<'msg, #IFabShape>) =
WidgetBuilder<'msg, IFabShape>(this.Key, this.Attributes)

/// <summary>Downcast to Shape widget to allow to return different types of shapes in a single expression (e.g. if/else, match with pattern, etc.)</summary>
/// <param name="this">Current widget</param>
static member AnyShape(this: WidgetBuilder<'msg, Memo.Memoized<#IFabShape>>) =
WidgetBuilder<'msg, IFabShape>(this.Key, this.Attributes)
9 changes: 5 additions & 4 deletions src/Fabulous.MauiControls/Views/Application.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ module Application =
Attributes.defineEvent<AppThemeChangedEventArgs> "Application_RequestedThemeChangedMsg" (fun target -> (target :?> Application).RequestedThemeChanged)

let RequestedThemeChangedFn =
Attributes.defineEventNoDispatch<AppThemeChangedEventArgs> "Application_RequestedThemeChangedFn" (fun target -> (target :?> Application).RequestedThemeChanged)
Attributes.defineEventNoDispatch<AppThemeChangedEventArgs> "Application_RequestedThemeChangedFn" (fun target ->
(target :?> Application).RequestedThemeChanged)

let ResumeMsg =
Attributes.defineEventNoArg "Application_ResumeMsg" (fun target -> (target :?> FabApplication).Resume)
Expand Down Expand Up @@ -145,7 +146,7 @@ module ApplicationBuilders =
WidgetHelpers.buildWidgets<'msg, IFabApplication> Application.WidgetKey [| Application.MainPage.WithValue(mainPage.Compile()) |]

/// <summary>Create an Application widget with a list of windows</summary>
static member inline Application<'msg, 'itemMarker when 'msg : equality and 'itemMarker :> IFabWindow>() =
static member inline Application<'msg, 'itemMarker when 'msg: equality and 'itemMarker :> IFabWindow>() =
CollectionBuilder<'msg, IFabApplication, 'itemMarker>(Application.WidgetKey, Application.Windows)

[<Extension>]
Expand All @@ -156,7 +157,7 @@ type ApplicationModifiers =
[<Extension>]
static member inline onModalPopped(this: WidgetBuilder<'msg, #IFabApplication>, fn: ModalPoppedEventArgs -> 'msg) =
this.AddScalar(Application.ModalPoppedMsg.WithValue(fn))

/// <summary>Listen for the ModalPopped event</summary>
/// <param name="this">Current widget</param>
/// <param name="fn">Message to dispatch</param>
Expand Down Expand Up @@ -293,7 +294,7 @@ type ApplicationModifiers =
[<Extension>]
type ApplicationYieldExtensions =
[<Extension>]
static member inline Yield<'msg, 'marker, 'itemType when 'msg : equality and 'marker :> IFabApplication and 'itemType :> IFabWindow>
static member inline Yield<'msg, 'marker, 'itemType when 'msg: equality and 'marker :> IFabApplication and 'itemType :> IFabWindow>
(
_: CollectionBuilder<'msg, 'marker, IFabWindow>,
x: WidgetBuilder<'msg, 'itemType>
Expand Down
6 changes: 3 additions & 3 deletions src/Fabulous.MauiControls/Views/Cells/_Cell.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type IFabCell =
module Cell =
let AppearingMsg =
Attributes.defineEventNoArg "Cell_AppearingMsg" (fun target -> (target :?> Cell).Appearing)

let AppearingFn =
Attributes.defineEventNoArgNoDispatch "Cell_AppearingFn" (fun target -> (target :?> Cell).Appearing)

Expand Down Expand Up @@ -104,13 +104,13 @@ type CellModifiers =
/// <summary>Set the context actions of the cell</summary>
/// <param name="this">Current widget</param>
[<Extension>]
static member inline contextActions<'msg, 'marker when 'msg : equality and 'marker :> IFabCell>(this: WidgetBuilder<'msg, 'marker>) =
static member inline contextActions<'msg, 'marker when 'msg: equality and 'marker :> IFabCell>(this: WidgetBuilder<'msg, 'marker>) =
WidgetHelpers.buildAttributeCollection<'msg, 'marker, IFabMenuItem> Cell.ContextActions this

[<Extension>]
type CellYieldExtensions =
[<Extension>]
static member inline Yield<'msg, 'marker, 'itemType when 'msg : equality and 'marker :> IFabCell and 'itemType :> IFabMenuItem>
static member inline Yield<'msg, 'marker, 'itemType when 'msg: equality and 'marker :> IFabCell and 'itemType :> IFabMenuItem>
(
_: AttributeCollectionBuilder<'msg, 'marker, IFabMenuItem>,
x: WidgetBuilder<'msg, 'itemType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module CarouselViewBuilders =

/// <summary>Create a CarouselView widget with a list of items</summary>
/// <param name="items">The items list</param>
static member inline CarouselView<'msg, 'itemData, 'itemMarker when 'msg : equality and 'itemMarker :> IFabView>(items: seq<'itemData>) =
static member inline CarouselView<'msg, 'itemData, 'itemMarker when 'msg: equality and 'itemMarker :> IFabView>(items: seq<'itemData>) =
WidgetHelpers.buildItems<'msg, IFabCarouselView, 'itemData, 'itemMarker> CarouselView.WidgetKey ItemsView.ItemsSource items

[<Extension>]
Expand Down
7 changes: 4 additions & 3 deletions src/Fabulous.MauiControls/Views/Collections/CollectionView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ module CollectionView =
Attributes.defineEvent<SelectionChangedEventArgs> "CollectionView_SelectionChangedMsg" (fun target -> (target :?> CollectionView).SelectionChanged)

let SelectionChangedFn =
Attributes.defineEventNoDispatch<SelectionChangedEventArgs> "CollectionView_SelectionChangedFn" (fun target -> (target :?> CollectionView).SelectionChanged)
Attributes.defineEventNoDispatch<SelectionChangedEventArgs> "CollectionView_SelectionChangedFn" (fun target ->
(target :?> CollectionView).SelectionChanged)

let SelectionMode =
Attributes.defineBindableEnum<SelectionMode> CollectionView.SelectionModeProperty
Expand All @@ -63,13 +64,13 @@ module CollectionViewBuilders =

/// <summary>Create a CollectionView widget with a list of items</summary>
/// <param name="items">The items list</param>
static member inline CollectionView<'msg, 'itemData, 'itemMarker when 'msg : equality and 'itemMarker :> IFabView>(items: seq<'itemData>) =
static member inline CollectionView<'msg, 'itemData, 'itemMarker when 'msg: equality and 'itemMarker :> IFabView>(items: seq<'itemData>) =
WidgetHelpers.buildItems<'msg, IFabCollectionView, 'itemData, 'itemMarker> CollectionView.WidgetKey ItemsView.ItemsSource items

/// <summary>Create a CollectionView widget with a list of grouped items</summary>
/// <param name="items">The grouped items list</param>
static member inline GroupedCollectionView<'msg, 'groupData, 'groupMarker, 'itemData, 'itemMarker
when 'msg : equality and 'itemMarker :> IFabView and 'groupMarker :> IFabView and 'groupData :> System.Collections.Generic.IEnumerable<'itemData>>
when 'msg: equality and 'itemMarker :> IFabView and 'groupMarker :> IFabView and 'groupData :> System.Collections.Generic.IEnumerable<'itemData>>
(items: seq<'groupData>)
=
WidgetHelpers.buildGroupItems<'msg, IFabCollectionView, 'groupData, 'itemData, 'groupMarker, 'itemMarker>
Expand Down
4 changes: 2 additions & 2 deletions src/Fabulous.MauiControls/Views/Collections/ListView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ module ListViewBuilders =

/// <summary>Create a ListView with a list of items</summary>
/// <param name="items">The items list</param>
static member inline ListView<'msg, 'itemData, 'itemMarker when 'msg : equality and 'itemMarker :> IFabCell>(items: seq<'itemData>) =
static member inline ListView<'msg, 'itemData, 'itemMarker when 'msg: equality and 'itemMarker :> IFabCell>(items: seq<'itemData>) =
WidgetHelpers.buildItems<'msg, IFabListView, 'itemData, 'itemMarker> ListView.WidgetKey ItemsViewOfCell.ItemsSource items

/// <summary>Create a ListView with a list of grouped items</summary>
/// <param name="items">The grouped items list</param>
static member inline GroupedListView<'msg, 'groupData, 'groupMarker, 'itemData, 'itemMarker
when 'msg : equality and 'itemMarker :> IFabCell and 'groupMarker :> IFabCell and 'groupData :> System.Collections.Generic.IEnumerable<'itemData>>
when 'msg: equality and 'itemMarker :> IFabCell and 'groupMarker :> IFabCell and 'groupData :> System.Collections.Generic.IEnumerable<'itemData>>
(items: seq<'groupData>)
=
WidgetHelpers.buildGroupItemsNoFooter<'msg, IFabListView, 'groupData, 'itemData, 'groupMarker, 'itemMarker>
Expand Down
8 changes: 8 additions & 0 deletions src/Fabulous.MauiControls/Views/Controls/Button.fs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ type ButtonExtraModifiers =
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabButton>, uniformSize: float) = this.padding(Thickness(uniformSize))

/// <summary>Set the padding inside the widget</summary>
/// <param name="this">Current widget</param>
/// <param name="horizontalSize">The padding value that will be applied to both left and right sides</param>
/// <param name="verticalSize">The padding value that will be applied to both top and bottom sides</param>
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabButton>, horizontalSize: float, verticalSize: float) =
this.padding(Thickness(horizontalSize, verticalSize))

/// <summary>Set the padding inside the button</summary>
/// <param name="this">Current widget</param>
/// <param name="left">The left component of the padding inside the button</param>
Expand Down
4 changes: 3 additions & 1 deletion src/Fabulous.MauiControls/Views/Controls/CheckBox.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ module CheckBoxBuilders =
static member inline CheckBox(isChecked: bool, onCheckedChanged: bool -> 'msg) =
WidgetBuilder<'msg, IFabCheckBox>(
CheckBox.WidgetKey,
CheckBox.IsCheckedWithEventMsg.WithValue(MsgValueEventData.create isChecked (fun (args: CheckedChangedEventArgs) -> onCheckedChanged args.Value))
CheckBox.IsCheckedWithEventMsg.WithValue(
MsgValueEventData.create isChecked (fun (args: CheckedChangedEventArgs) -> onCheckedChanged args.Value)
)
)

/// <summary>Create a CheckBox widget with a state and listen for state changes</summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Fabulous.MauiControls/Views/Controls/DatePicker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ module DatePicker =
target.SetValue(valueProperty, value)

// Set the new event handler
let handler =
target.DateSelected.Subscribe(curr.Event)
let handler = target.DateSelected.Subscribe(curr.Event)

node.SetHandler(name, handler))
)
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.MauiControls/Views/Controls/GraphicsView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type GraphicsViewModifiers =
[<Extension>]
static member inline onCancelInteraction(this: WidgetBuilder<'msg, #IGraphicsView>, msg: 'msg) =
this.AddScalar(GraphicsView.CancelInteractionMsg.WithValue(MsgValue(msg)))

/// <summary>Listen for the CancelInteraction event, which is raised when the press that made contact with the GraphicsView loses contact</summary>
/// <param name="this">Current widget</param>
/// <param name="fn">Function to execute</param>
Expand Down
8 changes: 8 additions & 0 deletions src/Fabulous.MauiControls/Views/Controls/ImageButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ type ImageButtonExtraModifiers =
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabImageButton>, uniformSize: float) = this.padding(Thickness(uniformSize))

/// <summary>Set the padding inside the widget</summary>
/// <param name="this">Current widget</param>
/// <param name="horizontalSize">The padding value that will be applied to both left and right sides</param>
/// <param name="verticalSize">The padding value that will be applied to both top and bottom sides</param>
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabImageButton>, horizontalSize: float, verticalSize: float) =
this.padding(Thickness(horizontalSize, verticalSize))

/// <summary>Set the padding inside the button</summary>
/// <param name="this">Current widget</param>
/// <param name="left">The left component of the padding inside the button</param>
Expand Down
8 changes: 8 additions & 0 deletions src/Fabulous.MauiControls/Views/Controls/Label.fs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ type LabelExtraModifiers =
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabLabel>, uniformSize: float) = this.padding(Thickness(uniformSize))

/// <summary>Set the padding inside the widget</summary>
/// <param name="this">Current widget</param>
/// <param name="horizontalSize">The padding value that will be applied to both left and right sides</param>
/// <param name="verticalSize">The padding value that will be applied to both top and bottom sides</param>
[<Extension>]
static member inline padding(this: WidgetBuilder<'msg, #IFabLabel>, horizontalSize: float, verticalSize: float) =
this.padding(Thickness(horizontalSize, verticalSize))

/// <summary>Set the padding inside the text</summary>
/// <param name="this">Current widget</param>
/// <param name="left">The left component of the padding inside the text</param>
Expand Down
Loading

0 comments on commit 02e5254

Please sign in to comment.