Skip to content

Commit

Permalink
Merge pull request #57 from fabulous-dev/component-changes
Browse files Browse the repository at this point in the history
Component changes
  • Loading branch information
TimLariviere authored Jan 18, 2024
2 parents 17886fa + 1333235 commit 95b258e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 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-pre5] - 2024-01-18

### Changed
- Use Fabulous 2.5.0-pre4

## [8.1.0-pre4] - 2024-01-16

### Changed
Expand Down Expand Up @@ -175,7 +180,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-pre4...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous.MauiControls/compare/8.1.0-pre5...HEAD
[8.1.0-pre5]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre5
[8.1.0-pre4]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre4
[8.1.0-pre3]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre3
[8.1.0-pre2]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre2
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="2.5.0-pre3" />
<PackageVersion Include="Fabulous" Version="2.5.0-pre4" />
<PackageVersion Include="FsCheck.NUnit" Version="2.16.6" />
<PackageVersion Include="FSharp.Core" Version="8.0.100" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
Expand Down
16 changes: 12 additions & 4 deletions src/Fabulous.MauiControls/AppHostBuilderExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type AppHostBuilderExtensions =
static member UseFabulousApp(this: MauiAppBuilder, program: Program<'arg, 'model, 'msg, #IFabApplication>, arg: 'arg) : MauiAppBuilder =
this.UseFabulousApp(
program.CanReuseView,
program.Program.Logger,
program.State.Logger,
fun () ->
(View.Component(program.Program, arg) {
(View.Component(program.State, arg) {
let! model = Mvu.State
program.View model
})
Expand All @@ -44,5 +44,13 @@ type AppHostBuilderExtensions =
this.UseFabulousApp(program, ())

[<Extension>]
static member UseFabulousApp(this: MauiAppBuilder, view: unit -> WidgetBuilder<unit, #IFabApplication>) : MauiAppBuilder =
this.UseFabulousApp(MauiViewHelpers.canReuseView, ProgramDefaults.defaultLogger(), (fun () -> view().Compile()))
static member UseFabulousApp(this: MauiAppBuilder, view: unit -> WidgetBuilder<unit, #IFabApplication>, ?canReuseView, ?logger) : MauiAppBuilder =
this.UseFabulousApp(
(match canReuseView with
| Some fn -> fn
| None -> MauiViewHelpers.canReuseView),
(match logger with
| Some logger -> logger
| None -> ProgramDefaults.defaultLogger()),
fun () -> (View.Component() { view() }).Compile()
)
8 changes: 5 additions & 3 deletions src/Fabulous.MauiControls/Component.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ module Component =
module ComponentBuilders =
type Fabulous.Maui.View with

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

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

static member inline Component(program: Program<'arg, 'model, 'msg>, arg: 'arg) = MvuComponentBuilder(program, arg)
static member inline Component<'arg, 'msg, 'model, 'marker, 'parentMsg>(program: Program<'arg, 'model, 'msg>, arg: 'arg) =
MvuComponentBuilder<'arg, 'msg, 'model, 'marker, 'parentMsg>(program, arg)
7 changes: 5 additions & 2 deletions src/Fabulous.MauiControls/Fabulous.MauiControls.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<UseLocalProjectReference>false</UseLocalProjectReference>

<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<UseMaui>true</UseMaui>
<IsPackable>true</IsPackable>
</PropertyGroup>
Expand Down Expand Up @@ -155,9 +155,12 @@
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="[2.5.0-pre3]" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[2.5.0-pre4]" />
<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" />
</ItemGroup>
<ItemGroup>
<ProjectReference Condition="'$(UseLocalProjectReference)' == 'true'" Include="..\..\..\Fabulous\src\Fabulous\Fabulous.fsproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Fabulous.MauiControls/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ module MauiViewHelpers =
| _ -> true

module Program =
let withView (view: 'model -> WidgetBuilder<'msg, 'marker>) (program: Program<'arg, 'model, 'msg>) : Program<'arg, 'model, 'msg, 'marker> =
{ Program = program
let withView (view: 'model -> WidgetBuilder<'msg, 'marker>) (state: Program<'arg, 'model, 'msg>) : Program<'arg, 'model, 'msg, 'marker> =
{ State = state
View = view
CanReuseView = MauiViewHelpers.canReuseView
SyncAction = MainThread.BeginInvokeOnMainThread }
Expand Down

0 comments on commit 95b258e

Please sign in to comment.