Skip to content

Commit

Permalink
Merge branch 'main' into wpf-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson authored Dec 10, 2023
2 parents 6ad54b7 + 017183b commit 6710fed
Show file tree
Hide file tree
Showing 94 changed files with 2,845 additions and 1,494 deletions.
11 changes: 7 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ updates:
- package-ecosystem: nuget
directory: "/Sample"
schedule:
interval: daily
time: "00:00"
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: nuget
directory: "/src"
schedule:
interval: daily
time: "00:00"
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
48 changes: 37 additions & 11 deletions .github/workflows/build-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,62 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-samples:
strategy:
matrix:
configuration: [Debug, Release]

runs-on: windows-latest
runs-on: windows-2022

steps:
- name: Install Windows SDK 10.0.16299
shell: pwsh
run: |
Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/p/?linkid=864422 -OutFile winsdk.exe
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "winsdk.exe"
$startInfo.Arguments = "/norestart /quiet"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$process.Start()
$process.WaitForExit()
- name: Setup Java JDK
uses: actions/[email protected]
with:
distribution: 'microsoft'
java-version: '11'

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true

# Install the .NET Core workload
- name: Install .NET Core 3.1.x
uses: actions/setup-dotnet@v1
# Install the .NET workload
- name: Setup .NET 6/7/8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.x
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Install .NET 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Install DotNet workloads
shell: bash
run: |
dotnet workload install android
dotnet workload install ios
dotnet workload install tvos
dotnet workload install macos
dotnet workload install maui
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v1.3.1

- name: Restore/Build the sample
run: msbuild SextantSample.sln /t:restore,build /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=$env:Configuration
Expand Down
134 changes: 13 additions & 121 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,130 +4,22 @@ on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [ main ]

env:
configuration: Release
productNamespacePrefix: "Sextant"

permissions:
contents: read

jobs:
build:
runs-on: windows-latest
outputs:
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true

- name: Install .NET Core 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Install .NET 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Add MSBuild to PATH
uses: glennawatson/[email protected]

# - name: Update VS2019
# shell: powershell
# run: Start-Process -Wait -PassThru -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "update --passive --norestart --installpath ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"""

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true

- name: NuGet Restore
run: dotnet restore
working-directory: src

- name: Build
run: msbuild /t:build,pack /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
working-directory: src

- name: Run Unit Tests and Generate Coverage
uses: glennawatson/coverlet-msbuild@v1
with:
project-files: '**/*Tests*.csproj'
no-build: true
exclude-filter: '[${{env.productNamespacePrefix}}.*.Tests.*]*'
include-filter: '[${{env.productNamespacePrefix}}*]*'
output-format: cobertura
output: '../../artifacts/'
configuration: ${{ env.configuration }}

- name: Upload Code Coverage
shell: bash
run: |
echo $PWD
bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -t ${{ env.CODECOV_TOKEN }} -s '$PWD/artifacts' -f '*.xml'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Create NuGet Artifacts
uses: actions/upload-artifact@master
with:
name: nuget
path: '**/*.nupkg'

release:
runs-on: ubuntu-latest
needs: build
if: contains(github.event.pull_request.labels.*.name, 'release') && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download NuGet Packages
uses: actions/download-artifact@v2
with:
name: nuget

- name: Save SignClient Configuration
run: 'echo "$SIGN_CLIENT_CONFIG" > SignPackages.json'
shell: bash
env:
SIGN_CLIENT_CONFIG: ${{secrets.SIGN_CLIENT_CONFIG}}

- name: Sign NuGet Packages
uses: glennawatson/signclient@v1
with:
input-files: '**/*.nupkg'
sign-client-secret: ${{ secrets.SIGN_CLIENT_SECRET }}
sign-client-user: ${{ secrets.SIGN_CLIENT_USER_ID }}
project-name: reactiveui
description: reactiveui
config-file: SignPackages.json

- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ needs.build.outputs.nbgv }}
release_name: ${{ needs.build.outputs.nbgv }}
body: |
${{ steps.changelog.outputs.commitLog }}
- name: NuGet Push
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}
SOURCE_URL: https://api.nuget.org/v3/index.json
run: |
dotnet nuget push -s ${{ env.SOURCE_URL }} -k ${{ env.NUGET_AUTH_TOKEN }} **/*.nupkg
permissions:
contents: none
uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main
with:
configuration: Release
productNamespacePrefix: "Sextant"
useVisualStudioPreview: false
useMauiCheckDotNetTool: false
solutionFile: "Sextant.sln"
31 changes: 31 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Lock Threads'

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-inactive-days: '14'
pr-inactive-days: '14'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
push:
branches:
- main
- patches/*

env:
productNamespacePrefix: "Sextant"

jobs:
release:
uses: reactiveui/actions-common/.github/workflows/workflow-common-release.yml@main
with:
configuration: Release
productNamespacePrefix: "Sextant"
useVisualStudioPreview: true
useMauiCheckDotNetTool: false
solutionFile: "Sextant.sln"
secrets:
SIGN_CLIENT_USER_ID: ${{ secrets.SIGN_CLIENT_USER_ID }}
SIGN_CLIENT_SECRET: ${{ secrets.SIGN_CLIENT_SECRET }}
SIGN_CLIENT_CONFIG: ${{ secrets.SIGN_CLIENT_CONFIG }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
69 changes: 58 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ Locator
.CurrentMutable
.RegisterNavigationView(() => new NavigationView(RxApp.MainThreadScheduler, RxApp.TaskpoolScheduler, ViewLocator.Current))
.RegisterParameterViewStackService()
.RegisterView<RedPage, RedViewModel>()
.RegisterView<FirstPage, FirstViewModel>();
.RegisterViewForNavigation(() => new PassPage(), () => new PassViewModel())
.RegisterViewForNavigation(() => new ReceivedPage(), () => new ReceivedViewModel());
```

Set the initial page:
```csharp
Locator
.Current
.GetService<IParameterViewStackService>()
.PushPage(new PassViewModel(), null, true, false)
.PushPage<PassViewModel>()
.Subscribe();

MainPage = Locator.Current.GetNavigationView("NavigationView");
Expand Down Expand Up @@ -117,10 +117,22 @@ IObservable<Unit> PushPage(IPageViewModel page, string contract = null, bool res

### Example
```csharp
OpenModal = ReactiveCommand
.CreateFromObservable(() =>
this.ViewStackService.PushModal(new FirstModalViewModel(ViewStackService)),
outputScheduler: RxApp.MainThreadScheduler);
public class ViewModel
{
private readonly IViewStackServicen _viewStackService; // or IParameterViewStackServicen
public ViewModel(IViewStackServicen viewStackService)
{
_viewStackService = viewStackService;

OpenModal = ReactiveCommand
// FirstModalViewModel must implement IViewModel or INavigable
.CreateFromObservable(() => viewStackService.PushModal<FirstModalViewModel>(),
outputScheduler: RxApp.MainThreadScheduler);
}

public ReactiveCommand<Unit, Unit> OpenModal { get; }
}
```

## Pass Parameters
Expand All @@ -130,14 +142,49 @@ Version 2.0 added support for passing parameters when navigating.
### Example

```csharp
Navigate = ReactiveCommand.CreateFromObservable(
() => navigationService
.PushPage(new NavigableViewModel(), new NavigationParameter { { "parameter", parameter } }),
outputScheduler: RxApp.MainThreadScheduler);
public class ViewModel
{
private readonly IParameterViewStackServicen _viewStackService;

public ViewModel(IParameterViewStackServicen viewStackService)
{
_viewStackService = viewStackService;

Navigate = ReactiveCommand
// NavigableViewModel must implement INavigable
.CreateFromObservable(() => viewStackService.PushModal<NavigableViewModel>(new NavigationParameter { { "parameter", parameter } }),
outputScheduler: RxApp.MainThreadScheduler);
}

public ReactiveCommand<Unit, Unit> Navigate { get; }
}
```

The `INavigable` interface exposes view model lifecycle methods that can be subscribed to. These methods unbox your parameter object. Implementing the interface allows you to assign values to the View Model during Navigation.

```csharp
public class NavigableViewModel : INavigable
{
public string? _parameter;

public IObservable<Unit> WhenNavigatedFrom(INavigationParameter parameter)
{
return Observable.Return(Unit.Default)
}

public IObservable<Unit> WhenNavigatedTo(INavigationParameter parameter)
{
parameter.TryGetValue("parameter", out _parameter);
return Observable.Return(Unit.Default);
}

public IObservable<Unit> WhenNavigatingTo(INavigationParameter parameter)
{
return Observable.Return(Unit.Default);
}
}
```

## Samples

- [Sample](https://github.com/reactiveui/Sextant/tree/main/Sample)
Expand Down
Loading

0 comments on commit 6710fed

Please sign in to comment.