Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LazyView #722

Closed
1 of 10 tasks
kphillpotts opened this issue Nov 2, 2022 · 4 comments
Closed
1 of 10 tasks

LazyView #722

kphillpotts opened this issue Nov 2, 2022 · 4 comments
Assignees

Comments

@kphillpotts
Copy link
Contributor

kphillpotts commented Nov 2, 2022

LazyView

  • Proposed
  • Prototype: Not Started
  • Implementation: Not Started
    • iOS Support
    • Android Support
    • macOS Support
    • Windows Support
  • Unit Tests: Not Started
  • Sample: Not Started
  • Documentation: Not Started

Summary

The LazyView control allows you to delay the initialization of a View. You need to provide the type of the View that you want to be rendered, using the x:TypeArguments XAML namespace attribute, and handle its initialization using the LoadViewAsync method. The IsLoaded property can be examined to determine when the LazyView is loaded.

Note: This proposal is a to port the existing LazyView functionality from the Xamarin Community Toolkit

Motivation

LazyView is one of the views that exist in the Xamarin Community Toolkit that has been requested as a missing piece in the migration of some big apps from Xamarin to MAUI.

Detailed Design

To provide a migration path forward from Xamarin Community Tookit, I see no reason to update the API surface area, as such it would be:

Properties:

Property Type Description
IsLoaded bool Gets the loaded status of the LazyView.

Methods:

Method Return Type Description
LoadViewAsync ValueTask Initialize the View.
Dispose void Cleans up the View, if required.

XAML Usage

     <StackLayout>
        <toolkit:LazyView x:TypeArguments="local:LazyTestView" IsLoaded = "{Binding IsLoaded}" />
    </StackLayout>

C# Implementation of a LazyView derived

/// <summary>
/// This a basic implementation of the LazyView based on <see cref="BaseLazyView"/> use this an exemple to create yours
/// </summary>
/// <typeparam name="TView">Any <see cref="View"/></typeparam>
public class LazyView<TView> : BaseLazyView where TView : View, new()
{
  /// <summary>
  /// This method initializes your <see cref="LazyView{TView}"/>.
  /// </summary>
  /// <returns><see cref="ValueTask"/></returns>
  public override ValueTask LoadViewAsync()
  {
    View view = new TView { BindingContext = BindingContext };
    
    Content = view;
    
    SetIsLoaded(true);
    return new ValueTask(Task.FromResult(true));
  }
}

Drawbacks

No drawbacks I'm aware of, other than potentially competing priorities

Unresolved Questions

  • Are there any complications with a straight port across due to MAUI changes?
  • Are there any feature requests, bugs that should be resolved at the time of porting
@kphillpotts kphillpotts added new proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail labels Nov 2, 2022
@kphillpotts kphillpotts added the needs discussion Discuss it on the next Monthly standup label Nov 2, 2022
@bijington
Copy link
Contributor

The usage of new TView requires a parameterless constructor which matches what we had in Xamarin however could/should we allow for more power through the magic of DI?

@kphillpotts kphillpotts self-assigned this Nov 2, 2022
@ghost ghost added champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature and removed new labels Nov 2, 2022
@ghost ghost added approved This Proposal has been approved and is ready to be added to the Toolkit help wanted This proposal has been approved and is ready to be implemented labels Nov 3, 2022
@VladislavAntonyuk VladislavAntonyuk removed the needs discussion Discuss it on the next Monthly standup label Nov 7, 2022
@bijington
Copy link
Contributor

Is this a duplicate of #112? Or vice-versa?

@bijington
Copy link
Contributor

@kphillpotts is this something you are looking at implementing or would you be willing for some help? I need to find something to get involved with now.

@VladislavAntonyuk
Copy link
Collaborator

Closing as duplicate of #112

@VladislavAntonyuk VladislavAntonyuk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@ghost ghost reopened this Jan 21, 2023
@VladislavAntonyuk VladislavAntonyuk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@ghost ghost reopened this Jan 21, 2023
@VladislavAntonyuk VladislavAntonyuk changed the title [Proposal] LazyView LazyView Jan 21, 2023
@VladislavAntonyuk VladislavAntonyuk removed help wanted This proposal has been approved and is ready to be implemented approved This Proposal has been approved and is ready to be added to the Toolkit proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature labels Jan 21, 2023
@VladislavAntonyuk VladislavAntonyuk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@ghost ghost reopened this Jan 21, 2023
@VladislavAntonyuk VladislavAntonyuk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@CommunityToolkit CommunityToolkit deleted a comment Jan 21, 2023
@CommunityToolkit CommunityToolkit deleted a comment Jan 21, 2023
@CommunityToolkit CommunityToolkit deleted a comment Jan 21, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants