Skip to content
forked from reactiveui/Sextant

A ReactiveUI navigation library for Xamarin.Forms

License

Notifications You must be signed in to change notification settings

giusepe/Sextant

 
 

Repository files navigation

Sextant

NuGet Stats Build Status Code Coverage

Sextant

A ReactiveUI navigation library for Xamarin.Forms

Sextant was born from a fork of Xamvvm which is nice and simple MVVM Framework with a good navigation system. The problem is, I just wanted a simple navigation system to use with ReactiveUI without all the things that come along an MVVM framework. Plus, I wanted to make it more "Reactive Friendly".

Then a wild Rodney Littles appears, and with him an implementation of this AMAZING POST by Kent

Sextant is in a very initial stage and in constant change, so please be pantience with use... because we will break things.

This library is nothing more than me "standing on the shoulders of giants": Kent for been the original and true creator of this, I pretty much just copied and pasted it :) Geoffrey Huntley maintainer on ReactiveUI (especially the build.cake) from where learned a lot about Cake + AppVeyor

Usage

Install the nuget package on your Forms project and ViewModels project.

Register the views:

SextantHelper.RegisterView<HomeView,HomeViewModel>();
SextantHelper.RegisterView<FirstModalView,FirstModalViewModel>();
SextantHelper.RegisterView<SecondModalView, SecondModalViewModel>();
SextantHelper.RegisterView<RedView, RedViewModel>();

(optional)If you need some especial configuration on the Navigation, like diferent colors, register a NavigationView for the VM:

SextantHelper.RegisterNavigation<BlueNavigationView, SecondModalViewModel>();

Set the initial page:

MainPage = SextantHelper.Initialize<HomeViewModel>();

After that all you have to do is call one of the methods inside your ViewModels:

/// <summary>
/// Pops the <see cref="IPageViewModel"/> off the stack.
/// </summary>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PopModal(bool animate = true);

/// <summary>
/// Pops the <see cref="IPageViewModel"/> off the stack.
/// </summary>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PopPage(bool animate = true);

/// <summary>
/// Pushes the <see cref="IPageViewModel"/> onto the stack.
/// </summary>
/// <param name="modal">The modal.</param>
/// <param name="contract">The contract.</param>
/// <returns></returns>
IObservable<Unit> PushModal(IPageViewModel modal, string contract = null);

/// <summary>
/// Pushes the <see cref="IPageViewModel"/> onto the stack.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="contract">The contract.</param>
/// <param name="resetStack">if set to <c>true</c> [reset stack].</param>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PushPage(IPageViewModel page, string contract = null, bool resetStack = false, bool animate = true);

For example:

OpenModal = ReactiveCommand
    .CreateFromObservable(() =>
        this.ViewStackService.PushModal(new FirstModalViewModel(ViewStackService)),
        outputScheduler: RxApp.MainThreadScheduler);

For more examples, look inside the sample folder in the solution.

Contribute

Sextant is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Because of our Open Collective model for funding and transparency, we are able to funnel support and funds through to our contributors and community. We ❤ the people who are involved in this project, and we’d love to have you on board, especially if you are just getting started or have never contributed to open-source before.

So here's to you, lovely person who wants to join us — this is how you can support us:

About

A ReactiveUI navigation library for Xamarin.Forms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 93.8%
  • PowerShell 5.0%
  • Shell 1.1%
  • Batchfile 0.1%