SweetMeSoft.Mobile.Base 1.11.130

dotnet add package SweetMeSoft.Mobile.Base --version 1.11.130
                    
NuGet\Install-Package SweetMeSoft.Mobile.Base -Version 1.11.130
                    
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.130" />
                    
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.130" />
                    
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.130
                    
#r "nuget: SweetMeSoft.Mobile.Base, 1.11.130"
                    
#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.130
                    
#: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.130
                    
Install as a Cake Addin
#tool nuget:?package=SweetMeSoft.Mobile.Base&version=1.11.130
                    
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.130 164 10/21/2025
1.11.129 307 9/17/2025
1.11.128 219 4/19/2025
1.11.127 235 4/19/2025
1.11.126 240 4/19/2025
1.11.125 154 4/19/2025
1.11.124 147 4/19/2025
1.11.123 213 4/4/2025
1.11.122 209 7/23/2024
1.11.121 192 6/26/2024
1.11.120 172 6/24/2024
1.11.119 190 6/21/2024
1.11.118 187 6/21/2024
1.11.117 181 5/31/2024
1.11.116 188 5/31/2024
1.11.115 198 4/14/2024
1.11.114 208 4/13/2024
1.11.112 192 4/3/2024
1.11.111 167 4/2/2024
1.11.110 190 3/16/2024
1.11.109 188 3/4/2024
1.11.108 200 3/3/2024
1.11.107 210 3/2/2024
1.11.106 187 2/23/2024
1.11.105 182 2/19/2024
1.11.104 196 2/16/2024
1.11.103 184 2/15/2024
1.11.102 206 2/12/2024
1.11.101 193 2/12/2024