MVC.ViewManagerPro 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package MVC.ViewManagerPro --version 0.0.2                
NuGet\Install-Package MVC.ViewManagerPro -Version 0.0.2                
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="MVC.ViewManagerPro" Version="0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MVC.ViewManagerPro --version 0.0.2                
#r "nuget: MVC.ViewManagerPro, 0.0.2"                
#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.
// Install MVC.ViewManagerPro as a Cake Addin
#addin nuget:?package=MVC.ViewManagerPro&version=0.0.2

// Install MVC.ViewManagerPro as a Cake Tool
#tool nuget:?package=MVC.ViewManagerPro&version=0.0.2                

ViewManagerPro

ViewManagerPro is a lightweight and efficient Unity module that simplifies the creation of dynamic content views, lists, and optimized recycle views. With built-in support for API integration and data-driven UI instantiation, ViewManagerPro eliminates the need for manual setup and accelerates your development workflow.


Features

  • ContentView
    Display a single data object or fetch and render content directly from an API endpoint.

  • ListView
    Easily create lists for moderate-sized datasets. Automatically instantiates UI elements for each data entry.

  • RecycleListView
    Optimized for large datasets, rendering only the visible items in the viewport to ensure smooth performance.

  • No Manual Setup
    Forget about adding ScrollRects, layouts, or content size fitters manually. ViewManagerPro handles everything for you.

  • API Integration
    Seamlessly fetch and display data from APIs like https://jsonplaceholder.typicode.com/posts.


Installation

  1. Open your Unity project.
  2. Go to NuGet Package Manager and search for MVC.ViewManagerPro.
  3. Install the package.
  4. Add the namespace in your script:
    using MVC.ViewManagerPro;
    

Quick Start

1. Define Your Model Class

First, create your model class that represents the data you want to display in your UI. For example, here's a model for a post:

public class PostData
{
    public int userId;
    public int id;
    public string title;
    public string body;
}

2. Create Your View Class

Next, create a view class that inherits from ViewItem and defines how each item in your view will be initialized. This is where you specify how to map your model data to UI elements like TextMeshProUGUI components. Here's an example of a view for displaying PostData:

using TMPro; // For TextMeshProUGUI

public class TestViewItem : ViewItem
{
    public TextMeshProUGUI id;
    public TextMeshProUGUI title;
    public TextMeshProUGUI body;
    internal PostData post;

    public override void Initialize<T>(T postData)
    {
        post = postData as PostData;
        id.text = post.id.ToString();
        title.text = post.title;
        body.text = post.body;
    }
}

3. Make API Calls and Display Data

ContentView

To display a single object fetched from an API, use ContentView. Here's an example of calling ContentView with a PostData model:

_ = new ContentView<PostData>()
    .Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts/1"), viewItem, parent)
    .Show();

In this example, ContentView fetches the data from https://jsonplaceholder.typicode.com/posts/1, passes it to the TestViewItem, and displays it in the UI.

ListView

To display a list of items, use ListView. This works for moderate datasets, automatically instantiating UI elements for each data entry:

_ = new ListView<PostData>()
    .Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts"), viewItem, parent, scrollViewConfig)
    .Show();

Here, ListView fetches data from https://jsonplaceholder.typicode.com/posts and displays each post in a list.

RecycleListView

For large datasets, use RecycleListView to optimize performance by rendering only visible items in the viewport:

_ = new RecycleListView<PostData>()
    .Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts"), viewItem, parent, scrollViewConfig)
    .Show();

ScrollViewConfig

public class ScrollViewConfig
{
    public DirectionType Direction;
    public bool isGrid = false;
    public int column = 1;
    public int row = 1;
    public Sprite backgroundImage;
    public Color backgroundColor = new Color(1, 1, 1, 1f);
    public MovementType movementType = MovementType.Elastic;
    public float scrollSensitivity = 1;
    public Vector2 spacing;
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.0.3 66 11/21/2024
0.0.2 43 11/20/2024
0.0.1 36 11/20/2024

- Initial release of ViewManagerPro with ContentView, ListView, and RecycleListView.
     - Added API integration for displaying posts from `https://jsonplaceholder.typicode.com/posts`.
     - Fixed performance issues with RecycleListView.