Spice 0.2.0-beta.1
dotnet add package Spice --version 0.2.0-beta.1
NuGet\Install-Package Spice -Version 0.2.0-beta.1
<PackageReference Include="Spice" Version="0.2.0-beta.1" />
paket add Spice --version 0.2.0-beta.1
#r "nuget: Spice, 0.2.0-beta.1"
// 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 | Versions 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. |
-
net7.0
- CommunityToolkit.Mvvm (>= 8.2.0)
- Microsoft.AspNetCore.Components.WebView (>= 7.0.5)
- Microsoft.Maui.Graphics (>= 7.0.86)
-
net7.0-android33.0
- CommunityToolkit.Mvvm (>= 8.2.0)
- Microsoft.AspNetCore.Components.WebView (>= 7.0.5)
- Microsoft.Maui.Graphics (>= 7.0.86)
- Xamarin.AndroidX.AppCompat (>= 1.6.0.1)
- Xamarin.Google.Android.Material (>= 1.7.0.2)
-
net7.0-ios16.1
- CommunityToolkit.Mvvm (>= 8.2.0)
- Microsoft.AspNetCore.Components.WebView (>= 7.0.5)
- Microsoft.Maui.Graphics (>= 7.0.86)
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 | 142 | 6/2/2023 |
0.1.0-alpha.2 | 115 | 2/3/2023 |