Skip to content

Commit

Permalink
Merge pull request #60 from fabulous-dev/use-fabulous-pre7
Browse files Browse the repository at this point in the history
Use Fabulous pre7
  • Loading branch information
edgarfgp authored Jan 30, 2024
2 parents e2334e1 + 9b9fab9 commit 595f0a6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 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-pre8] - 2024-01-30

### Changed
- Use Fabulous 2.5.0-pre7

## [8.1.0-pre7] - 2024-01-29

### Changed
Expand Down Expand Up @@ -190,7 +195,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-pre7...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous.MauiControls/compare/8.1.0-pre8...HEAD
[8.1.0-pre8]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre8
[8.1.0-pre7]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre7
[8.1.0-pre6]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre6
[8.1.0-pre5]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/8.1.0-pre5
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-pre6" />
<PackageVersion Include="Fabulous" Version="2.5.0-pre7" />
<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
4 changes: 3 additions & 1 deletion src/Fabulous.MauiControls.Tests/WidgetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open System
open Fabulous
open Microsoft.Maui.ApplicationModel
open NUnit.Framework

open Fabulous.Maui
Expand Down Expand Up @@ -56,7 +57,8 @@ type WidgetTests() =
GetViewNode = ViewNode.get
Logger = ProgramDefaults.defaultLogger()
Dispatch = dispatch
GetComponent = Component.get }
GetComponent = Component.get
SyncAction = MainThread.BeginInvokeOnMainThread }

let navPage = FabNavigationPage()
let weakRef = WeakReference(navPage)
Expand Down
23 changes: 21 additions & 2 deletions src/Fabulous.MauiControls/AppHostBuilderExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ open System
[<Extension>]
type AppHostBuilderExtensions =
[<Extension>]
static member inline private UseFabulousApp(this: MauiAppBuilder, canReuseView, logger, [<InlineIfLambda>] viewFn: unit -> Widget) : MauiAppBuilder =
static member inline private UseFabulousApp
(
this: MauiAppBuilder,
canReuseView,
logger,
syncAction: (unit -> unit) -> unit,
[<InlineIfLambda>] viewFn: unit -> Widget
) : MauiAppBuilder =
this.UseMauiApp(fun (_serviceProvider: IServiceProvider) ->
let widget = viewFn()

let treeContext: ViewTreeContext =
{ CanReuseView = canReuseView
Logger = logger
Dispatch = ignore
SyncAction = syncAction
GetViewNode = ViewNode.get
GetComponent = Component.get }

Expand All @@ -31,6 +39,7 @@ type AppHostBuilderExtensions =
this.UseFabulousApp(
program.CanReuseView,
program.State.Logger,
program.SyncAction,
fun () ->
(View.Component(program.State, arg) {
let! model = Mvu.State
Expand All @@ -44,13 +53,23 @@ type AppHostBuilderExtensions =
this.UseFabulousApp(program, ())

[<Extension>]
static member UseFabulousApp(this: MauiAppBuilder, view: unit -> WidgetBuilder<unit, #IFabApplication>, ?canReuseView, ?logger) : MauiAppBuilder =
static member UseFabulousApp
(
this: MauiAppBuilder,
view: unit -> WidgetBuilder<unit, #IFabApplication>,
?canReuseView,
?logger,
?syncAction: (unit -> unit) -> unit
) : MauiAppBuilder =
this.UseFabulousApp(
(match canReuseView with
| Some fn -> fn
| None -> MauiViewHelpers.canReuseView),
(match logger with
| Some logger -> logger
| None -> ProgramDefaults.defaultLogger()),
(match syncAction with
| Some synAction -> synAction
| None -> MauiViewHelpers.defaultSyncAction),
fun () -> (View.Component() { view() }).Compile()
)
2 changes: 1 addition & 1 deletion src/Fabulous.MauiControls/Fabulous.MauiControls.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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="[2.5.0-pre6]" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[2.5.0-pre7]" />
<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
5 changes: 4 additions & 1 deletion src/Fabulous.MauiControls/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module MauiViewHelpers =
| None -> ValueNone
| Some attr -> ValueSome attr.Value

let defaultSyncAction (action: unit -> unit) =
MainThread.BeginInvokeOnMainThread(action)

/// Extend the canReuseView function to check Microsoft.Maui specific constraints
let rec canReuseView (prev: Widget) (curr: Widget) =
if ViewHelpers.canReuseView prev curr && canReuseAutomationId prev curr then
Expand Down Expand Up @@ -77,7 +80,7 @@ module Program =
{ State = state
View = view
CanReuseView = MauiViewHelpers.canReuseView
SyncAction = MainThread.BeginInvokeOnMainThread }
SyncAction = MauiViewHelpers.defaultSyncAction }

let stateless (view: unit -> WidgetBuilder<unit, 'marker>) : Program<unit, unit, unit, 'marker> =
Program.stateful (fun _ -> ()) (fun _ _ -> ()) |> withView view
Expand Down
2 changes: 1 addition & 1 deletion templates/content/blank/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"type": "parameter",
"dataType": "string",
"replaces": "FabulousPkgVersion",
"defaultValue": "2.5.0-pre5"
"defaultValue": "2.5.0-pre7"
},
"FabulousMauiControlsPkgVersion": {
"type": "parameter",
Expand Down

0 comments on commit 595f0a6

Please sign in to comment.