Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarfgp committed Sep 6, 2024
1 parent ba87082 commit 29a851d
Show file tree
Hide file tree
Showing 98 changed files with 5,810 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Collections/Carousel.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Fabulous.Avalonia.Components

open Fabulous
open Fabulous.Avalonia

type IFabComponentCarousel =
inherit IFabComponentSelectingItemsControl
inherit IFabCarousel

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

/// <summary>Creates a Carousel widget.</summary>
/// <param name="items">The items to display.</param>
/// <param name="template">The template to use to render each item.</param>
static member Carousel<'msg, 'itemData, 'itemMarker when 'itemMarker :> IFabComponentControl>
(items: seq<'itemData>, template: 'itemData -> WidgetBuilder<'msg, 'itemMarker>)
=
WidgetHelpers.buildItems<'msg, IFabComponentCarousel, 'itemData, 'itemMarker> Carousel.WidgetKey ItemsControl.ItemsSourceTemplate items template
24 changes: 24 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Collections/ListBox.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Fabulous.Avalonia.Components

open Fabulous
open Fabulous.Avalonia

type IFabComponentListBox =
inherit IFabComponentSelectingItemsControl
inherit IFabListBox

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

/// <summary>Creates a ListBox widget.</summary>
/// <param name="items">The items to display.</param>
/// <param name="template">The template to use to render each item.</param>
static member ListBox<'msg, 'itemData, 'itemMarker when 'itemMarker :> IFabControl>
(items: seq<'itemData>, template: 'itemData -> WidgetBuilder<'msg, 'itemMarker>)
=
WidgetHelpers.buildItems<'msg, IFabComponentListBox, 'itemData, 'itemMarker> ListBox.WidgetKey ItemsControl.ItemsSourceTemplate items template

/// <summary>Creates a ListBox widget.</summary>
static member ListBox() =
CollectionBuilder<'msg, IFabComponentListBox, IFabComponentListBoxItem>(ListBox.WidgetKey, ComponentItemsControl.Items)
25 changes: 25 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Collections/TabControl.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentTabControl =
inherit IFabComponentSelectingItemsControl
inherit IFabTabControl

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

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

/// <summary>Creates a TabControl widget.</summary>
static member TabControl() =
CollectionBuilder<unit, IFabComponentTabControl, IFabComponentTabItem>(TabControl.WidgetKey, ComponentItemsControl.Items, TabControl.TabStripPlacement.WithValue(Dock.Top))
50 changes: 50 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Collections/TreeView.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Fabulous.Avalonia.Components

open System.Collections
open System.Runtime.CompilerServices
open Avalonia.Controls
open Fabulous
open Fabulous.Avalonia

type IFabComponentTreeView =
inherit IFabComponentItemsControl
inherit IFabTreeView

type ComponentTreeWidgetItems =
{ Nodes: IEnumerable
SubNodesFn: obj -> IEnumerable
Template: obj -> Widget }

module ComponentTreeView =
let SelectionChanged =
ComponentAttributes.defineEvent "TreeView_SelectionChanged" (fun target -> (target :?> TreeView).SelectionChanged)

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

/// <summary>Creates a TreeView widget.</summary>
/// <param name="nodes">The root nodes used to populate the TreeView.</param>
/// <param name="subNodes">The sub nodes used to populate the children of each node.</param>
/// <param name="template">The template used to render each node.</param>
static member TreeView<'msg, 'itemData, 'itemMarker when 'itemMarker :> IFabComponentControl>
(nodes: seq<'itemData>, subNodes: 'itemData -> seq<'itemData>, template: 'itemData -> WidgetBuilder<unit, 'itemMarker>)
=
let template (item: obj) =
let item = unbox<'itemData> item
(template item).Compile()

let data: TreeWidgetItems =
{ Nodes = nodes
SubNodesFn = (fun subNode -> subNodes(unbox subNode) :> IEnumerable)
Template = template }

WidgetBuilder<'msg, IFabComponentTreeView>(TreeView.WidgetKey, TreeView.ItemsSource.WithValue(data))

type ComponentTreeViewModifiers =
/// <summary>Listens to the TreeView SelectionChanged event.</summary>
/// <param name="this">Current widget.</param>
/// <param name="fn">Raised when the TreeView SelectionChanged event is fired.</param>
[<Extension>]
static member inline onSelectionChanged(this: WidgetBuilder<unit, #IFabComponentTreeView>, fn: SelectionChangedEventArgs -> unit) =
this.AddScalar(ComponentTreeView.SelectionChanged.WithValue(fn))
26 changes: 26 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Controls/Border.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentBorder =
inherit IFabComponentDecorator
inherit IFabBorder

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

/// <summary>Creates a Border widget.</summary>
/// <param name="content">The content of the Border.</param>
static member Border(content: WidgetBuilder<unit, #IFabControl>) =
WidgetBuilder<unit, IFabComponentBorder>(
Border.WidgetKey,
AttributesBundle(StackList.empty(), ValueSome [| Decorator.ChildWidget.WithValue(content.Compile()) |], ValueNone)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Fabulous.Avalonia.Components

open Fabulous.Avalonia

type IFabComponentDataValidationErrors =
inherit IFabComponentContentControl
inherit IFabDataValidationErrors
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentExperimentalAcrylicBorder =
inherit IFabComponentDecorator
inherit IFabExperimentalAcrylicBorder

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

/// <summary>Creates a ExperimentalAcrylicBorder widget.</summary>
/// <param name="content">The content of the ExperimentalAcrylicBorder.</param>
static member ExperimentalAcrylicBorder(content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<unit, IFabComponentExperimentalAcrylicBorder>(
ExperimentalAcrylicBorder.WidgetKey,
AttributesBundle(StackList.empty(), ValueSome [| Decorator.ChildWidget.WithValue(content.Compile()) |], ValueNone)
)

/// <summary>Creates a ExperimentalAcrylicBorder widget.</summary>
static member ExperimentalAcrylicBorder() =
WidgetBuilder<unit, IFabComponentExperimentalAcrylicBorder>(
ExperimentalAcrylicBorder.WidgetKey,
AttributesBundle(StackList.empty(), ValueNone, ValueNone)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentExperimentalAcrylicMaterial =
inherit IFabComponentElement
inherit IFabExperimentalAcrylicMaterial

module ComponentExperimentalAcrylicMaterial =
let Invalidated =
ComponentAttributes.defineEventNoArg "ExperimentalAcrylicMaterial_Invalidated" (fun target -> (target :?> ExperimentalAcrylicMaterial).Invalidated)

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

/// <summary>Creates a ExperimentalAcrylicMaterial widget.</summary>
static member ExperimentalAcrylicMaterial() =
WidgetBuilder<unit, IFabExperimentalAcrylicMaterial>(
ExperimentalAcrylicMaterial.WidgetKey,
AttributesBundle(StackList.empty(), ValueNone, ValueNone)
)

type ComponentExperimentalAcrylicMaterialModifiers =
/// <summary>Listens the ExperimentalAcrylicMaterial Invalidated event.</summary>
/// <param name="this">Current widget.</param>
/// <param name="fn">Raised when the ExperimentalAcrylicMaterial is invalidated.</param>
[<Extension>]
static member inline onInvalidated(this: WidgetBuilder<unit, #IFabComponentExperimentalAcrylicMaterial>, fn: unit -> unit) =
this.AddScalar(ComponentExperimentalAcrylicMaterial.Invalidated.WithValue(fn))
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Fabulous.Avalonia.Components

open Fabulous
open Fabulous.Avalonia
open Fabulous.StackAllocatedCollections.StackList

type IFabComponentHeaderedContentControl =
inherit IFabComponentContentControl
inherit IFabHeaderedContentControl

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

/// <summary>Creates a HeaderedContentControl widget.</summary>
/// <param name="header">The header string.</param>
/// <param name="content">The content widget.</param>
static member HeaderedContentControl(header: string, content: WidgetBuilder<unit, #IFabControl>) =
WidgetBuilder<unit, IFabComponentHeaderedContentControl>(
HeaderedContentControl.WidgetKey,
AttributesBundle(
StackList.one(HeaderedContentControl.HeaderString.WithValue(header)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HeaderedContentControl widget.</summary>
/// <param name="header">The header widget.</param>
/// <param name="content">The content widget.</param>
static member HeaderedContentControl(header: WidgetBuilder<unit, #IFabControl>, content: WidgetBuilder<unit, #IFabControl>) =
WidgetBuilder<unit, IFabComponentHeaderedContentControl>(
HeaderedContentControl.WidgetKey,
AttributesBundle(
StackList.empty(),
ValueSome
[| HeaderedContentControl.HeaderWidget.WithValue(header.Compile())
ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone
)
)

/// <summary>Creates a HeaderedContentControl widget.</summary>
/// <param name="header">The header string.</param>
/// <param name="content">The content string.</param>
static member HeaderedContentControl(header: string, content: string) =
WidgetBuilder<unit, IFabComponentHeaderedContentControl>(
HeaderedContentControl.WidgetKey,
HeaderedContentControl.HeaderString.WithValue(header),
ContentControl.ContentString.WithValue(content)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentLayoutTransformControl =
inherit IFabComponentDecorator
inherit IFabLayoutTransformControl

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

/// <summary>Creates a LayoutTransformControl widget.</summary>
/// <param name="content">The content of the LayoutTransformControl.</param>
static member LayoutTransformControl(content: WidgetBuilder<'msg, #IFabControl>) =
WidgetBuilder<unit, IFabComponentLayoutTransformControl>(
LayoutTransformControl.WidgetKey,
AttributesBundle(StackList.empty(), ValueSome [| Decorator.ChildWidget.WithValue(content.Compile()) |], ValueNone)
)
37 changes: 37 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Controls/RefreshContainer.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Fabulous.Avalonia.Components

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

type IFabComponentRefreshContainer =
inherit IFabComponentContentControl
inherit IFabRefreshContainer

module ComponentRefreshContainer =
let RefreshRequested =
ComponentAttributes.defineEvent<RefreshRequestedEventArgs> "RefreshContainer_RefreshRequested" (fun target ->
(target :?> RefreshContainer).RefreshRequested)

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

/// <summary>Creates a RefreshContainer widget.</summary>
/// <param name="content">The content of the RefreshContainer.</param>
static member RefreshContainer(content: WidgetBuilder<unit, #IFabControl>) =
WidgetBuilder<unit, IFabComponentRefreshContainer>(
RefreshContainer.WidgetKey,
AttributesBundle(StackList.empty(), ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |], ValueNone)
)

type ComponentRefreshContainerModifiers =
/// <summary>Listens the RefreshContainer RefreshRequested event.</summary>
/// <param name="this">Current widget.</param>
/// <param name="fn">Raised when the RefreshRequested event is fired.</param>
[<Extension>]
static member inline onRefreshRequested(this: WidgetBuilder<unit, #IFabComponentRefreshContainer>, fn: RefreshRequestedEventArgs -> unit) =
this.AddScalar(ComponentRefreshContainer.RefreshRequested.WithValue(fn))
37 changes: 37 additions & 0 deletions src/Fabulous.Avalonia/ComponentViews/Controls/RefreshVisualizer.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Fabulous.Avalonia.Components

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

type IFaComponentRefreshVisualizer =
inherit IFabComponentContentControl
inherit IFabRefreshVisualizer

module ComponentRefreshVisualizer =
let RefreshRequested =
ComponentAttributes.defineEvent<RefreshRequestedEventArgs> "RefreshVisualizer_RefreshRequested" (fun target ->
(target :?> RefreshVisualizer).RefreshRequested)

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

/// <summary>Creates a RefreshVisualizer widget.</summary>
/// <param name="content">The content of the RefreshVisualizer.</param>
static member RefreshVisualizer(content: WidgetBuilder<unit, #IFabControl>) =
WidgetBuilder<unit, IFaComponentRefreshVisualizer>(
RefreshVisualizer.WidgetKey,
AttributesBundle(StackList.empty(), ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |], ValueNone)
)

type ComponentRefreshVisualizerModifiers =
/// <summary>Listens the RefreshVisualizer RefreshRequested event.</summary>
/// <param name="this">Current widget.</param>
/// <param name="fn">Raised when the RefreshRequested event is fired.</param>
[<Extension>]
static member inline onRefreshRequested(this: WidgetBuilder<'msg, #IFaComponentRefreshVisualizer>, fn: RefreshRequestedEventArgs -> unit) =
this.AddScalar(ComponentRefreshVisualizer.RefreshRequested.WithValue(fn))
Loading

0 comments on commit 29a851d

Please sign in to comment.