Spice 0.2.0-beta.1

This is a prerelease version of Spice.
dotnet add package Spice --version 0.2.0-beta.1
NuGet\Install-Package Spice -Version 0.2.0-beta.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Spice" Version="0.2.0-beta.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Spice --version 0.2.0-beta.1
#r "nuget: Spice, 0.2.0-beta.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Spice as a Cake Addin
#addin nuget:?package=Spice&version=0.2.0-beta.1&prerelease

// Install Spice as a Cake Tool
#tool nuget:?package=Spice&version=0.2.0-beta.1&prerelease

Spice 🌶, a spicy cross-platform UI framework!

A prototype (and design) of API minimalism for mobile.

The idea is we could build apps in a simple way, in a similar vein as minimal APIs in ASP.NET Core but for mobile & maybe one day desktop:

public class App : Application
{
    public App()
    {
        int count = 0;
    
        var label = new Label
        {
            Text = "Hello, Spice 🌶",
        };
    
        var button = new Button
        {
            Text = "Click Me",
            Clicked = _ => label.Text = $"Times: {++count}"
        };
    
        Main = new StackView { label, button };
    }
}

These "view" types are mostly just POCOs.

Thus you can easily write unit tests in a vanilla net7.0 Xunit project, such as:

[Fact]
public void Application()
{
    var app = new App();
    var label = (Label)app.Main.Children[0];
    var button = (Button)app.Main.Children[1];

    button.Clicked(button);
    Assert.Equal("Times: 1", label.Text);

    button.Clicked(button);
    Assert.Equal("Times: 2", label.Text);
}

The above views in a net7.0 project are not real UI, while net7.0-android and net7.0-ios projects get the full implementations that actually do something on screen.

So for example, adding App to the screen on Android:

protected override void OnCreate(Bundle? savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    SetContentView(new App());
}

And on iOS:

var vc = new UIViewController();
vc.View.AddSubview(new App());
Window.RootViewController = vc;

App is a native view on both platforms. You just add it to an the screen as you would any other control or view. This can be mix & matched with regular iOS & Android UI because Spice 🌶 views are just native views.

Getting Started

Simply install the template:

dotnet new install Spice.Templates

Create the project and build it as you would for other .NET MAUI projects:

dotnet new spice
dotnet build
# To run on Android
dotnet build -f net7.0-android -t:Run
# To run on iOS
dotnet build -f net7.0-ios -t:Run

Of course, you can also just open the project in Visual Studio and hit F5.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Spice:

Repository Stars
jonathanpeppers/spice
Spice 🌶, a spicy cross-platform UI framework!
Version Downloads Last updated
0.2.0-beta.1 122 6/2/2023
0.1.0-alpha.2 104 2/3/2023