IslandDisplayView Custom Control - ChrispyPeaches/FocusFriends GitHub Wiki

IslandDisplayView

The IslandDisplayView class is a view control inheriting the Maui Grid class. It shows the island with a decor item and a pet on it.

Bindable Properties

Island

  • Type: FocusApp.Shared.Models.Island
  • Default Value: null
  • Description: Gets or sets the island which the view will display.

Pet

  • Type: FocusApp.Shared.Models.Pet
  • Default Value: null
  • Description: Gets or sets the pet which the view will display.

Decor

  • Type: FocusApp.Shared.Models.Furniture
  • Default Value: null
  • Description: Gets or sets the decor item which the view will display.

Constructor

IslandDisplayView()

  • Description: Initializes a new instance of the IslandDisplayView class. Sets up binding for the island, decor, and pet images displayed to be updated when the binded values are changed.

Remarks

  • The HeightRequest properties of the Pet and Decor classes correspond to the "device-independent" units of height that will be requested for displaying each item on this page
  • The pet and decor item each have a container to which they're constrained. If a width or height is requested outside of this range, the content of the picture will not exceed the size of the bounds, but it wont appear as sitting on the island as intended.
    • The image below depict the containers for each item.
    • The red area is the are that the entire control is taking up in this specific instance.
    • The teal area is the container for the pet and the yellow container for the decor item.
    • The green and blue boxes depict the actual area that the specific decor item and pet in the screenshot take up.

Examples

// Create an IslandDisplayView instance, directly setting the properties
new IslandDisplayView()
{
    Island = _authenticationService.SelectedIsland,
    Pet = _authenticationService.SelectedPet,
    Decor = _authenticationService.SelectedFurniture
};

// Create an IslandDisplayView instance and setup beinding for the island, pet, and decor properties
new IslandDisplayView()
{
    BindingContext = this,
    Island = _authenticationService.SelectedIsland,
    Pet = _authenticationService.SelectedPet,
    Decor = _authenticationService.SelectedFurniture
}
.Bind(
    IslandDisplayView.IslandProperty,
    getter: static (IAuthenticationService authService) => authService.SelectedIsland)
.Bind(
    IslandDisplayView.PetProperty,
    getter: static (IAuthenticationService authService) => authService.SelectedPet)
.Bind(
    IslandDisplayView.DecorProperty,
    getter: static (IAuthenticationService authService) => authService.SelectedFurniture),