SweetMeSoft.Mobile.Base 1.11.129

dotnet add package SweetMeSoft.Mobile.Base --version 1.11.129
                    
NuGet\Install-Package SweetMeSoft.Mobile.Base -Version 1.11.129
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SweetMeSoft.Mobile.Base" Version="1.11.129" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SweetMeSoft.Mobile.Base" Version="1.11.129" />
                    
Directory.Packages.props
<PackageReference Include="SweetMeSoft.Mobile.Base" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SweetMeSoft.Mobile.Base --version 1.11.129
                    
#r "nuget: SweetMeSoft.Mobile.Base, 1.11.129"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SweetMeSoft.Mobile.Base@1.11.129
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SweetMeSoft.Mobile.Base&version=1.11.129
                    
Install as a Cake Addin
#tool nuget:?package=SweetMeSoft.Mobile.Base&version=1.11.129
                    
Install as a Cake Tool

SweetMeSoft.Mobile.Base

Base library with a set of utilities, base classes and services to accelerate .NET MAUI application development.

Description

SweetMeSoft.Mobile.Base is a library for .NET MAUI that provides a robust base architecture for mobile applications, following the MVVM pattern. It includes a base ViewModel with integrated functionalities, a popup service, and extensions for simple initial configuration.

Features

  • Simple Configuration (AppHostBuilderExtensions):
    • An extension method UseSweetMeSoftBase for MauiAppBuilder that initializes necessary dependencies like CommunityToolkit.Maui and UserDialogs.
  • Base ViewModel (AppBaseViewModel):
    • Navigation: Inherits from NavigationViewModel (not included but implicit) for simple navigation management.
    • API Wrapper: Get and Post methods that integrate with SweetMeSoft.Connectivity to perform HTTP requests. They automatically manage connectivity, authentication tokens and loading indicators.
    • Dialogs and Popups: Integrates with Acr.UserDialogs for alerts and confirmations, and uses its own PopupsService to show a "loading" popup.
    • Permission Management: Helpers to verify and request device permissions using MAUI APIs.
    • Hardware Access: Functions to get GPS location.
    • Session Management: A Logout method to clear user preferences and restart navigation.
  • Popup Service (PopupsService):
    • A singleton service to show and hide a loading popup (LoadingPopup) consistently throughout the application.

Dependencies

Installation

dotnet add package SweetMeSoft.Mobile.Base

Usage

1. Configuration in MauiProgram.cs

In your MauiProgram.cs file, use the UseSweetMeSoftBase method to register the library and its dependencies.

using SweetMeSoft.Mobile.Base;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            // Call the extension method and pass your API base URL
            .UseSweetMeSoftBase("https://api.yourdomain.com") 
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });

        // ... Register your own views and viewmodels
        // builder.Services.AddSingleton<MyPage>();
        // builder.Services.AddSingleton<MyViewModel>();

        return builder.Build();
    }
}

2. Inherit from AppBaseViewModel

Create your ViewModels inheriting from AppBaseViewModel to access all the integrated functionality.

using SweetMeSoft.Mobile.Base.ViewModels;
using CommunityToolkit.Mvvm.Input; // Required for [RelayCommand]
using System.Threading.Tasks;

public partial class MyViewModel : AppBaseViewModel
{
    // Observable properties can be defined with CommunityToolkit.Mvvm
    // [ObservableProperty]
    // private string myData;

    public MyViewModel()
    {
        // AppBaseViewModel handles navigation through Shell or NavigationPage
    }

    [RelayCommand]
    private async Task LoadDataAsync()
    {
        // The 'true' in showLoading is the default value, which
        // will automatically activate PopupsService.ShowLoading/HideLoading.
        var result = await Get<MyDataModel>("/my-api/endpoint", showLoading: true);
        
        if (result != null)
        {
            // ... process the result
            // MyData = result.SomeProperty;
        }
    }

    [RelayCommand]
    private async Task GoToDetailsAsync()
    {
        // Navigate to another page registered in the DI Container
        await GoToAsync<DetailsPage>();
    }
}

3. Usage in View (XAML)

Bind your ViewModel commands to your view controls.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:vm="clr-namespace:MyProject.ViewModels"
             x:Class="MyProject.MyPage"
             x:DataType="vm:MyViewModel">

    <VerticalStackLayout>
        <Button Text="Load Data" Command="{Binding LoadDataCommand}" />
        <Button Text="View Details" Command="{Binding GoToDetailsCommand}" />
    </VerticalStackLayout>
    
</ContentPage>

License

This project is under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net9.0-android35.0 is compatible.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst18.0 is compatible.  net9.0-windows10.0.19041 is compatible.  net10.0-android was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.11.129 281 9/17/2025
1.11.128 194 4/19/2025
1.11.127 207 4/19/2025
1.11.126 205 4/19/2025
1.11.125 125 4/19/2025
1.11.124 121 4/19/2025
1.11.123 189 4/4/2025
1.11.122 180 7/23/2024
1.11.121 168 6/26/2024
1.11.120 154 6/24/2024
1.11.119 165 6/21/2024
1.11.118 164 6/21/2024
1.11.117 153 5/31/2024
1.11.116 160 5/31/2024
1.11.115 169 4/14/2024
1.11.114 181 4/13/2024
1.11.112 168 4/3/2024
1.11.111 151 4/2/2024
1.11.110 165 3/16/2024
1.11.109 164 3/4/2024
1.11.108 171 3/3/2024
1.11.107 188 3/2/2024
1.11.106 165 2/23/2024
1.11.105 163 2/19/2024
1.11.104 163 2/16/2024
1.11.103 163 2/15/2024
1.11.102 184 2/12/2024
1.11.101 166 2/12/2024