Skip to content

Commit

Permalink
Use Fabulous 3.0.0-pre16 and remove SingleChild builders
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Nov 25, 2024
1 parent f5592cf commit 24cb8da
Show file tree
Hide file tree
Showing 26 changed files with 155 additions and 95 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [9.0.0-pre5] - 2024-11-25

### Changed
- Use Fabulous 3.0.0-pre16

### Removed
- Remove all SingleChildBuilder signatures

## [9.0.0-pre4] - 2024-11-21

### Changed
Expand Down Expand Up @@ -291,7 +299,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/9.0.0-pre4...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous.MauiControls/compare/9.0.0-pre5...HEAD
[9.0.0-pre5]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/9.0.0-pre5
[9.0.0-pre4]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/9.0.0-pre4
[9.0.0-pre3]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/9.0.0-pre3
[9.0.0-pre2]: https://github.com/fabulous-dev/Fabulous.MauiControls/releases/tag/9.0.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="3.0.0-pre12" />
<PackageVersion Include="Fabulous" Version="3.0.0-pre16" />
<PackageVersion Include="FsCheck.NUnit" Version="2.16.6" />
<PackageVersion Include="FSharp.Core" Version="9.0.100" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
Expand Down
4 changes: 2 additions & 2 deletions samples/Calculator/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module App =
.textColor(Colors.Black)

Application() {
Window() {
Window(
ContentPage(
(Grid(rowdefs = [ Star; Star; Star; Star; Star; Star ], coldefs = [ Star; Star; Star; Star ]) {
View
Expand Down Expand Up @@ -147,7 +147,7 @@ module App =
.columnSpacing(1.0)
.background(gray)
)
}
)
}

let program =
Expand Down
71 changes: 70 additions & 1 deletion samples/Components/HelloComponent/App.fs
Original file line number Diff line number Diff line change
@@ -1,13 +1,82 @@
namespace HelloComponent

open System
open Fabulous
open Fabulous.Maui
open Microsoft.Maui.Hosting

open type Fabulous.Maui.View
open type Fabulous.Context

open Microsoft.Maui.Storage

type Settings() =
inherit EnvironmentObject()

let mutable usePaidMode = Preferences.Default.Get("UsePaidMode", false)

member this.UsePaidMode
with get () = usePaidMode
and set v =
usePaidMode <- v
Preferences.Default.Set("UsePaidMode", v)
this.NotifyChanged()

module EnvironmentKeys =

let Settings = EnvironmentKey<Settings>("Settings")

module Child =
let view name () =
Component(name) {
let! settings = Context.EnvironmentObject(EnvironmentKeys.Settings)

VStack() {
Label($"Paid mode = {settings.UsePaidMode}")
Button("Toggle paid mode", fun () -> settings.UsePaidMode <- not settings.UsePaidMode)
}
}

module MvuChild =
type Model = { Settings: Settings }

type Msg = | TogglePaidMode

let init (settings: Settings) = { Settings = settings }, Cmd.none

let update msg model =
match msg with
| TogglePaidMode -> model, Cmd.ofEffect(fun _ -> model.Settings.UsePaidMode <- not model.Settings.UsePaidMode)

let program = Program.statefulWithCmd init update

let view name () =
Component(name) {
let! settings = EnvironmentObject(EnvironmentKeys.Settings)
let! _ = Mvu(program, settings)

VStack() {
Label($"Paid mode = {settings.UsePaidMode}")
Button("Toggle paid mode", TogglePaidMode)
}
}

module App =
let view () =
Component("root") { Application() { Window() { ContentPage() { (VStack() { Label("Hello Component").centerTextHorizontal() }).centerVertical() } } } }
Component("root") {
(Application() {
Window(
ContentPage(
(VStack() {
Child.view "1" ()
Child.view "2" ()
})
.center()
)
)
})
.environment(EnvironmentKeys.Settings, new Settings())
}

let createMauiApp () =
MauiApp.CreateBuilder().UseFabulousApp(view).Build()
8 changes: 4 additions & 4 deletions samples/Components/MultipleMvus/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module Form =
module App =
let view () =
Application() {
Window() {
ContentPage() {
Window(
ContentPage(
(VStack(spacing = 25.) {
Label("App")

Expand All @@ -67,6 +67,6 @@ module App =
})
.width(250.)
.center()
}
}
)
)
}
8 changes: 4 additions & 4 deletions samples/Components/MvuCounter/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ module App =
let! model = Context.Mvu(program)

Application() {
Window() {
ContentPage() {
Window(
ContentPage(
(VStack() {
Label($"%d{model.Count}").centerTextHorizontal()

Expand All @@ -80,7 +80,7 @@ module App =
Button("Reset", Reset)
})
.center()
}
}
)
)
}
}
4 changes: 2 additions & 2 deletions samples/Components/SimpleCounter/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module App =
let! model = Context.Mvu(program)

(Application() {
Window() {
Window(
ContentPage(
(VStack() {
Label("Theme is: " + theme.ToString()).centerTextHorizontal()
Expand All @@ -48,7 +48,7 @@ module App =
})
.center()
)
}
)
})
.environment(EnvironmentKeys.Count, model)
}
Expand Down
4 changes: 2 additions & 2 deletions samples/Components/TicTacComponent/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ module App =
let! model = Context.Mvu(program)

Application() {
Window() {
Window(
ContentPage(
Grid(coldefs = [ Star ], rowdefs = [ Star; Auto; Auto ]) {
(Grid(coldefs = [ Star; Absolute 5.0; Star; Absolute 5.0; Star ], rowdefs = [ Star; Absolute 5.0; Star; Absolute 5.0; Star ]) {
Expand Down Expand Up @@ -264,6 +264,6 @@ module App =
.gridRow(2)
}
)
}
)
}
}
4 changes: 2 additions & 2 deletions samples/CounterApp/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module App =

let view model =
Application() {
Window() {
Window(
ContentPage(
(VStack() {
Label($"%d{model.Count}").centerTextHorizontal()
Expand All @@ -76,7 +76,7 @@ module App =
})
.center()
)
}
)
}

let program = Program.statefulWithCmd init update |> Program.withView view
4 changes: 2 additions & 2 deletions samples/Gallery/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module App =

let view model =
Application() {
Window() {
Window(
TabbedPage() {
ContentPage(
match List.head model.Paths with
Expand All @@ -59,7 +59,7 @@ module App =
)
.title("Info")
}
}
)
}

let program = Program.stateful init update |> Program.withView view
2 changes: 1 addition & 1 deletion samples/HelloWorld/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open type Fabulous.Maui.View

module App =
let view () =
Application() { Window() { ContentPage(Label("Hello World").center()) } }
Application() { Window(ContentPage(Label("Hello World").center())) }

type MauiProgram =
static member CreateMauiApp() =
Expand Down
4 changes: 2 additions & 2 deletions samples/Navigation/BasicNavigation/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Sample =

let view model =
Application() {
Window() {
Window(
ContentPage(
(Grid(coldefs = [ Star; Star; Star ], rowdefs = [ Auto; Star ]) {
Button("Page A", GoToPageA).gridColumn(0)
Expand All @@ -76,7 +76,7 @@ module Sample =
})
.rowSpacing(30.)
)
}
)
}

let program = Program.stateful init update |> Program.withView view
4 changes: 2 additions & 2 deletions samples/Navigation/ComponentNavigation/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Sample =
let! model = Context.Mvu(program nav appMsgDispatcher)

Application() {
Window() {
Window(
(NavigationPage() {
// We inject in the NavigationPage history the back stack of our navigation
for navPath in List.rev model.Navigation.BackStack do
Expand All @@ -64,6 +64,6 @@ module Sample =
})
.onBackButtonPressed(BackButtonPressed)
.onBackNavigated(BackNavigationMsg)
}
)
}
}
4 changes: 2 additions & 2 deletions samples/Navigation/NavigationPath/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module Sample =
/// To be able to wrap those Msgs into the app's root Msg type, we use the View.map helper function.
let view model =
Application() {
Window() {
Window(
(NavigationPage() {
// We inject in the NavigationPage history the back stack of our navigation
for navModel in List.rev model.Navigation.BackStack do
Expand All @@ -73,7 +73,7 @@ module Sample =
.hasBackButton(false)
})
.onBackButtonPressed(BackButtonPressed)
}
)
}

let program = Program.statefulWithCmd init update |> Program.withView view
8 changes: 4 additions & 4 deletions samples/Playground/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module App =

let view model =
Application() {
Window() {
Window(
ContentPage(
(VStack(spacing = 20.) {
let text =
Expand All @@ -68,18 +68,18 @@ module App =
})
.margin(20.)
)
}
)

if model.WindowOpened then
Window() {
Window(
ContentPage(
(VStack(spacing = 20.) {
Label("Window opened")
Button("Close window", CloseWindow)
})
.margin(20.)
)
}
)
}

let program = Program.stateful init update |> Program.withView view
4 changes: 2 additions & 2 deletions samples/TicTacToe/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module App =
/// The dynamic 'view' function giving the updated content for the view
let view model =
Application() {
Window() {
Window(
ContentPage(
Grid(coldefs = [ Star ], rowdefs = [ Star; Auto; Auto ]) {
(Grid(coldefs = [ Star; Absolute 5.0; Star; Absolute 5.0; Star ], rowdefs = [ Star; Absolute 5.0; Star; Absolute 5.0; Star ]) {
Expand Down Expand Up @@ -248,7 +248,7 @@ module App =
.gridRow(2)
}
)
}
)
}

let subscribe _ =
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.MauiControls/Fabulous.MauiControls.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
This version will be used as the lower bound in the NuGet package
-->
<PackageReference Include="FSharp.Core" VersionOverride="9.0.100" PrivateAssets="All" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[3.0.0-pre13]" />
<PackageReference Include="Fabulous" Condition="'$(UseLocalProjectReference)' != 'true'" VersionOverride="[3.0.0-pre16]" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="Microsoft.Maui.Controls" VersionOverride="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" VersionOverride="9.0.0" />
Expand Down
4 changes: 0 additions & 4 deletions src/Fabulous.MauiControls/Views/Layouts/Border.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ module BorderBuilders =
static member inline Border(content: WidgetBuilder<'msg, #IFabView>) =
WidgetBuilder<'msg, IFabBorder>(Border.WidgetKey, Border.Content.WithValue(content.Compile()))

/// <summary>Create a Border widget with a content widget</summary>
static member inline Border() =
SingleChildBuilder<'msg, IFabBorder, #IFabView>(Border.WidgetKey, Border.Content)

[<Extension>]
type BorderModifiers =
/// <summary>Set the padding inside the border</summary>
Expand Down
4 changes: 0 additions & 4 deletions src/Fabulous.MauiControls/Views/Layouts/ContentView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ module ContentViewBuilders =
static member inline ContentView(content: WidgetBuilder<'msg, #IFabView>) =
WidgetHelpers.buildWidgets<'msg, IFabContentView> ContentView.WidgetKey [| ContentView.Content.WithValue(content.Compile()) |]

/// <summary>Create a ContentView widget with a content</summary>
static member inline ContentView() =
SingleChildBuilder<'msg, IFabContentView, #IFabView>(ContentView.WidgetKey, ContentView.Content)

[<Extension>]
type ContentViewModifiers =
/// <summary>Link a ViewRef to access the direct ContentView control instance</summary>
Expand Down
Loading

0 comments on commit 24cb8da

Please sign in to comment.