Skip to content

nalu-development/nalu

Repository files navigation

Banner

Nalu GitHub Actions Status

🍕 Buy me a pizza

Nalu.Maui provides a set of classes to help you with everyday challenges encountered while working with .NET MAUI.

Core Nalu.Maui.Core NuGet Package Nalu.Maui NuGet Package Downloads

The core library is intended to provide a set of common use utilities.

Have you ever noticed that when the user backgrounds the app on iOS, the app is suspended, and the network requests will fail due to The network connection was lost?

This is really annoying: it forces us to implement complex retry logic, especially considering that the request may have already hit the server.

To solve this issue, we provide a NSUrlBackgroundSessionHttpMessageHandler to be used in your HttpClient to allow http request to continue even when the app is in the background.

#if IOS
    HttpClient client = DeviceInfo.DeviceType == DeviceType.Virtual
        ? new() // iOS Simulator doesn't support background sessions
        : new(new NSUrlBackgroundSessionHttpMessageHandler());
#else
    HttpClient client = new();
#endif

To make this work, you need to change your AppDelegate as follows:

[Export("application:handleEventsForBackgroundURLSession:completionHandler:")]
public virtual void HandleEventsForBackgroundUrl(UIApplication application, string sessionIdentifier, Action completionHandler)
    => NSUrlBackgroundSessionHttpMessageHandler.HandleEventsForBackgroundUrl(application, sessionIdentifier, completionHandler);

Find out more at Nalu Website.

Navigation Nalu.Maui.Navigation NuGet Package Nalu.Maui NuGet Package Downloads

The MVVM navigation service offers a straightforward and robust method for navigating between pages and passing parameters.

The navigation system utilizes Shell under the hood, allowing you to easily define the flyout menu, tabs, and root pages.

We use a fluent API instead of strings to define navigations, supporting both Relative and Absolute navigation, including navigation guards to prompt the user before leaving a page.

// Push the page registered with the DetailPageModel
await _navigationService.GoToAsync(Navigation.Relative().Push<DetailPageModel>());
// Navigate to the `SettingsPageModel` root page
await _navigationService.GoToAsync(Navigation.Absolute().ShellContent<SettingsPageModel>());

Passing parameters is simple and type-safe.

// Pop the page and pass a parameter to the previous page model
await _navigationService.GoToAsync(Navigation.Relative().Pop().WithIntent(new MyPopIntent()));
// which should implement `IAppearingAware<MyPopIntent>`
Task OnAppearingAsync(MyPopIntent intent) { ... }

You can also define navigation guards to prevent navigation from occurring.

ValueTask<bool> CanLeaveAsync() => { ... ask the user };

There is an embedded leak-detector to help you identify memory leaks in your application.

Find out more at Nalu Website.

Layouts Nalu.Maui.Layouts NuGet Package Nalu.Maui NuGet Package Downloads

Cross-platform layouts and utilities for MAUI applications simplify dealing with templates and BindinginContext in XAML.

  • Have you ever dreamed of having an if statement in XAML?
      <nalu:ToggleTemplate Value="{Binding HasPermission}"
                           WhenTrue="{StaticResource AdminFormTemplate}"
                           WhenFalse="{StaticResource PermissionRequestTemplate}" />
  • Do you want to scope the binding context of a content?
      <nalu:ViewBox ContentBindingContext="{Binding SelectedAnimal}"
                    IsVisible="{Binding IsSelected}">
          <views:AnimalView x:DataType="models:Animal" />
      </nalu:ViewBox>
  • And what about rendering a TemplateSelector directly like we do on a CollectionView?
      <nalu:TemplateBox ContentTemplateSelector="{StaticResource AnimalTemplateSelector}"
                        ContentBindingContext="{Binding CurrentAnimal}" />

Find out more at Nalu Website.