Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Nov 4, 2024
1 parent 6fc5287 commit 6855de2
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 134 deletions.
2 changes: 2 additions & 0 deletions src/Fabulous.Avalonia/Fabulous.Avalonia.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@
<Compile Include="Views\Collections\ListBox.Mvu.fs" />
<Compile Include="Views\Collections\Carousel.fs" />
<Compile Include="Views\Collections\TabControl.fs" />
<Compile Include="Views\Collections\TabControl.Mvu.fs" />
<Compile Include="Views\Collections\TabControl.Components.fs" />
<Compile Include="Views\Collections\TreeView.fs" />
<Compile Include="Views\Collections\TreeView.Components.fs" />
<Compile Include="Views\Collections\TreeView.Mvu.fs" />
Expand Down
20 changes: 20 additions & 0 deletions src/Fabulous.Avalonia/Views/Collections/TabControl.Components.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Fabulous.Avalonia

open System.Runtime.CompilerServices
open Avalonia.Controls
open Avalonia.Layout
open Fabulous
open Fabulous.StackAllocatedCollections

[<AutoOpen>]
module ComponentTabControlBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a TabControl widget.</summary>
/// <param name="placement">The placement of the tab strip.</param>
static member TabControl(placement: Dock) =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, ComponentItemsControl.Items, TabControl.TabStripPlacement.WithValue(placement))

/// <summary>Creates a TabControl widget.</summary>
static member TabControl() =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, ComponentItemsControl.Items, TabControl.TabStripPlacement.WithValue(Dock.Top))
21 changes: 21 additions & 0 deletions src/Fabulous.Avalonia/Views/Collections/TabControl.Mvu.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Fabulous.Avalonia

open System.Runtime.CompilerServices
open Avalonia.Controls
open Avalonia.Layout
open Fabulous
open Fabulous.StackAllocatedCollections

[<AutoOpen>]
module MvuTabControlBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a TabControl widget.</summary>
/// <param name="placement">The placement of the tab strip.</param>
static member TabControl(placement: Dock) =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, MvuItemsControl.Items, TabControl.TabStripPlacement.WithValue(placement))

/// <summary>Creates a TabControl widget.</summary>
static member TabControl() =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, MvuItemsControl.Items, TabControl.TabStripPlacement.WithValue(Dock.Top))

14 changes: 0 additions & 14 deletions src/Fabulous.Avalonia/Views/Collections/TabControl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@ module TabControl =
let VerticalContentAlignment =
Attributes.defineAvaloniaPropertyWithEquality TabControl.VerticalContentAlignmentProperty

[<AutoOpen>]
module TabControlBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a TabControl widget.</summary>
/// <param name="placement">The placement of the tab strip.</param>
static member TabControl(placement: Dock) =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, MvuItemsControl.Items, TabControl.TabStripPlacement.WithValue(placement))

/// <summary>Creates a TabControl widget.</summary>
static member TabControl() =
CollectionBuilder<'msg, IFabTabControl, IFabTabItem>(TabControl.WidgetKey, MvuItemsControl.Items, TabControl.TabStripPlacement.WithValue(Dock.Top))


type TabControlModifiers =
/// <summary>Sets the HorizontalContentAlignment property.</summary>
/// <param name="this">Current widget.</param>
Expand Down
14 changes: 0 additions & 14 deletions src/Fabulous.Avalonia/Views/Controls/AutoCompleteBox.Components.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ module ComponentAutoCompleteBox =
Attributes.defineEventNoDispatch<SelectionChangedEventArgs> "AutoCompleteBox_SelectionChanged" (fun target ->
(target :?> AutoCompleteBox).SelectionChanged)

[<AutoOpen>]
module ComponentAutoCompleteBoxBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="items">The items to display.</param>
static member AutoCompleteBox(items: seq<_>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.ItemsSource.WithValue(items))

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="populator">The function to populate the items.</param>
static member AutoCompleteBox(populator: string -> CancellationToken -> Task<seq<_>>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.AsyncPopulator.WithValue(populator))

type ComponentAutoCompleteBoxModifiers =
/// <summary>Binds the AutoCompleteBox.TextProperty.</summary>
/// <param name="this">Current widget.</param>
Expand Down
14 changes: 0 additions & 14 deletions src/Fabulous.Avalonia/Views/Controls/AutoCompleteBox.Mvu.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ module MvuAutoCompleteBox =
let SelectionChanged =
Attributes.defineEvent<SelectionChangedEventArgs> "AutoCompleteBox_SelectionChanged" (fun target -> (target :?> AutoCompleteBox).SelectionChanged)

[<AutoOpen>]
module MvuAutoCompleteBoxBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="items">The items to display.</param>
static member AutoCompleteBox(items: seq<_>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.ItemsSource.WithValue(items))

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="populator">The function to populate the items.</param>
static member AutoCompleteBox(populator: string -> CancellationToken -> Task<seq<_>>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.AsyncPopulator.WithValue(populator))

type MvuAutoCompleteBoxModifiers =
/// <summary>Binds the AutoCompleteBox.TextProperty.</summary>
/// <param name="this">Current widget.</param>
Expand Down
16 changes: 16 additions & 0 deletions src/Fabulous.Avalonia/Views/Controls/AutoCompleteBox.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ namespace Fabulous.Avalonia

open System
open System.Runtime.CompilerServices
open System.Threading
open System.Threading.Tasks
open Avalonia.Controls
open Fabulous

Expand Down Expand Up @@ -73,6 +75,20 @@ module AutoCompleteBox =
| ValueSome template ->
autoComplete.SetValue(AutoCompleteBox.ItemTemplateProperty, WidgetDataTemplate(node, template))
|> ignore)

[<AutoOpen>]
module AutoCompleteBoxBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="items">The items to display.</param>
static member AutoCompleteBox(items: seq<_>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.ItemsSource.WithValue(items))

/// <summary>Creates an AutoCompleteBox widget.</summary>
/// <param name="populator">The function to populate the items.</param>
static member AutoCompleteBox(populator: string -> CancellationToken -> Task<seq<_>>) =
WidgetBuilder<'msg, IFabAutoCompleteBox>(AutoCompleteBox.WidgetKey, AutoCompleteBox.AsyncPopulator.WithValue(populator))

type AutoCompleteBoxModifiers =
/// <summary>Sets the MinimumPrefixLength property.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ module ComponentHyperlinkButton =
module ComponentHyperlinkButtonBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: Uri) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(uri)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
Expand All @@ -37,16 +27,6 @@ module ComponentHyperlinkButtonBuilders =
ComponentHyperlinkButton.IsVisitedChanged.WithValue(ComponentValueEventData.create isVisited fn)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: string) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(Uri(uri))
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
Expand All @@ -60,19 +40,6 @@ module ComponentHyperlinkButtonBuilders =
ComponentHyperlinkButton.IsVisitedChanged.WithValue(ComponentValueEventData.create isVisited fn)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: Uri, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(uri)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
Expand All @@ -91,19 +58,6 @@ module ComponentHyperlinkButtonBuilders =
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: string, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(Uri(uri))),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ module MvuHyperlinkButton =
module MvuHyperlinkButtonBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: Uri) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(uri)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
Expand All @@ -37,16 +27,6 @@ module MvuHyperlinkButtonBuilders =
MvuHyperlinkButton.IsVisitedChanged.WithValue(MvuValueEventData.create isVisited fn)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: string) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(Uri(uri))
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
Expand All @@ -60,19 +40,6 @@ module MvuHyperlinkButtonBuilders =
MvuHyperlinkButton.IsVisitedChanged.WithValue(MvuValueEventData.create isVisited fn)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: Uri, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(uri)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
Expand All @@ -91,19 +58,6 @@ module MvuHyperlinkButtonBuilders =
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: string, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(Uri(uri))),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
Expand Down
53 changes: 53 additions & 0 deletions src/Fabulous.Avalonia/Views/Controls/Buttons/HyperlinkButton.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace Fabulous.Avalonia

open System
open System.Runtime.CompilerServices
open Avalonia.Controls
open Fabulous
open Fabulous.StackAllocatedCollections.StackList

type IFabHyperlinkButton =
inherit IFabButton
Expand All @@ -16,6 +18,57 @@ module HyperlinkButton =
let IsVisited =
Attributes.defineAvaloniaPropertyWithEquality HyperlinkButton.IsVisitedProperty

[<AutoOpen>]
module HyperlinkButtonBuilders =
type Fabulous.Avalonia.View with

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: Uri) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(uri)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="text">The text to display.</param>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
static member HyperlinkButton(text: string, uri: string) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
ContentControl.ContentString.WithValue(text),
HyperlinkButton.NavigateUri.WithValue(Uri(uri))
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: Uri, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(uri)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HyperlinkButton widget.</summary>
/// <param name="uri">The Uri to navigate to when the HyperlinkButton is clicked.</param>
/// <param name="content">The content of the HyperlinkButton.</param>
static member HyperlinkButton(uri: string, content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<'msg, IFabHyperlinkButton>(
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(Uri(uri))),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)


type HyperlinkButtonModifiers =

/// <summary>Sets the IsVisited property.</summary>
Expand Down

0 comments on commit 6855de2

Please sign in to comment.