Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrote iOS renderer, TouchInputPage and refactoring #7

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
name: Build
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@v4

# Use Xcode 15.2 until 15.3 is recommended
# see https://github.com/dotnet/maui/issues/21057
- name: Select Xcode 15.2
run: sudo xcode-select -s /Applications/Xcode_15.2.app

- name: Setup .NET according to global.json
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

Expand All @@ -55,7 +55,7 @@ jobs:
dotnet pack -o staging -c Debug src/Rive.Maui/Rive.Maui.csproj /p:VersionSuffix="-pr-${{ github.event.number }}"

- name: Upload NuGet Artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@v4
with:
name: rive-ci-build
path: staging
4 changes: 2 additions & 2 deletions .github/workflows/nuget-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ jobs:
name: Build
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@v4

# Use Xcode 15.2 until 15.3 is recommended
# see https://github.com/dotnet/maui/issues/21057
- name: Select Xcode 15.2
run: sudo xcode-select -s /Applications/Xcode_15.2.app

- name: Setup .NET according to global.json
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Wrapper around the iOS/Android runtime

_(Work in progress)_

### NOTE: iOS only works in simulator for now..

<img src="./images/ios.gif" width="200"> <img src="./images/ios2.gif" width="200">
<img src="./images/ios.gif" width="180"> <img src="./images/ios2.gif" width="180">
<br>
<br>
<img src="./images/android.gif" width="200"> <img src="./images/android2.gif" width="200">
<img src="./images/android.gif" width="180"> <img src="./images/android2.gif" width="180">


## Getting started
- Install [Rive.Maui nuget](https://www.nuget.org/packages/Rive.Maui/)
- Call .UseRive() on MauiAppBuilder in MauiProgram.cs
- Set iOS target version in .csproj to at least 14: ```<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.0</SupportedOSPlatformVersion>```
- Add .riv files to Resources/Images
7 changes: 7 additions & 0 deletions samples/Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<MauiXaml Update="Pages\StateMachinePage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Pages\TouchInputPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>

<ItemGroup>
Expand All @@ -63,6 +66,10 @@
<DependentUpon>StateMachinePage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Pages\TouchInputPage.xaml.cs">
<DependentUpon>TouchInputPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions samples/Example/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />

<Button Text="StateMachine" Clicked="Button_OnClicked" />
<Button Text="StateMachine" Clicked="StateMachine_OnClicked" />

<riveMaui:Rive ResourceName="runner" Fit="Cover" WidthRequest="300" HeightRequest="300" />
<Button Text="TouchInput" Clicked="TouchInput_OnClicked" />

<riveMaui:RivePlayer ResourceName="runner" Fit="Cover" WidthRequest="300" HeightRequest="300" />

</VerticalStackLayout>
</ScrollView>
Expand Down
7 changes: 6 additions & 1 deletion samples/Example/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ public MainPage()
InitializeComponent();
}

private void Button_OnClicked(object? sender, EventArgs e)
private void StateMachine_OnClicked(object? sender, EventArgs e)
{
Navigation.PushAsync(new StateMachinePage());
}

private void TouchInput_OnClicked(object? sender, EventArgs e)
{
Navigation.PushAsync(new TouchInputPage());
}
}
6 changes: 3 additions & 3 deletions samples/Example/Pages/StateMachinePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
xmlns:riveMaui="clr-namespace:Rive.Maui;assembly=Rive.Maui"
x:Class="Example.Pages.StateMachinePage"
Title="StateMachine">
<Grid RowDefinitions="300,*" RowSpacing="25">
<riveMaui:Rive
<Grid RowDefinitions="350,*" RowSpacing="25">
<riveMaui:RivePlayer
Grid.Row="0"
Fit="Cover"
ResourceName="animatedloginscreen">
Expand Down Expand Up @@ -35,7 +35,7 @@
x:Name="TrigSuccess"
StateMachineName="Login Machine"
InputName="trigSuccess" />
</riveMaui:Rive>
</riveMaui:RivePlayer>

<StackLayout Grid.Row="1" Spacing="25" Padding="25, 0">
<HorizontalStackLayout Spacing="10">
Expand Down
38 changes: 38 additions & 0 deletions samples/Example/Pages/TouchInputPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>

<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:riveMaui="clr-namespace:Rive.Maui;assembly=Rive.Maui"
xmlns:pages="clr-namespace:Example.Pages"
x:Class="Example.Pages.TouchInputPage"
x:DataType="pages:TouchInputPageViewModel"
Title="TouchPage">

<ContentPage.BindingContext>
<pages:TouchInputPageViewModel />
</ContentPage.BindingContext>

<VerticalStackLayout>
<Label
Margin="0,50,0,0"
Text="{Binding CurrentStateName, StringFormat='State name: {0}'}"
HorizontalOptions="Center"
FontAttributes="Bold"
FontSize="20" />

<Label
Text="{Binding NumberInputValue, StringFormat='Number input: {0}'}"
HorizontalOptions="Center"
FontAttributes="Bold"
FontSize="20" />

<riveMaui:RivePlayer
Margin="0,40,0,0"
ResourceName="lil_guy"
Fit="Cover"
HeightRequest="500"
OnStateMachineChangeCommand="{Binding StateChangedCommand}" />
</VerticalStackLayout>

</ContentPage>
9 changes: 9 additions & 0 deletions samples/Example/Pages/TouchInputPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Example.Pages;

public partial class TouchInputPage : ContentPage
{
public TouchInputPage()
{
InitializeComponent();
}
}
48 changes: 48 additions & 0 deletions samples/Example/Pages/TouchInputPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Rive.Maui;

namespace Example.Pages;

public class TouchInputPageViewModel : INotifyPropertyChanged
{
private string? _currentStateName;
private double _numberInputValue;

public string? CurrentStateName
{
get => _currentStateName;
set => SetField(ref _currentStateName, value);
}

public double NumberInputValue
{
get => _numberInputValue;
set => SetField(ref _numberInputValue, value);
}

public Command<StateMachineChange> StateChangedCommand => new(state =>
{
CurrentStateName = state.StateName;
if (state.Inputs.TryGetValue("Number 1", out var value)
&& value is float floatValue)
{
NumberInputValue = floatValue;
}
});

public event PropertyChangedEventHandler? PropertyChanged;

private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
Binary file added samples/Example/Resources/Images/lil_guy.riv
Binary file not shown.
3 changes: 2 additions & 1 deletion src/Rive.Android/Rive.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<NoWarn>BG8401;BG8605;BG8606;CS0108;CS0114</NoWarn>
<PackageId>Rive.Android</PackageId>
<Title>Rive Android</Title>
<Description>Wrapper around the Android runtime</Description>
<Version>1.0.0-pre.4</Version>
<Version>1.0.0-pre.5</Version>
<PackageProjectUrl>https://github.com/matmork/rive-maui</PackageProjectUrl>
<RepositoryUrl>https://github.com/matmork/rive-maui</RepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
2 changes: 1 addition & 1 deletion src/Rive.Maui/MauiAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static MauiAppBuilder UseRive(this MauiAppBuilder builder)

builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler<Rive, RiveRenderer>();
handlers.AddHandler<RivePlayer, RivePlayerRenderer>();
});

return builder;
Expand Down
Loading
Loading