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

Question: CollectionView items are not displayed on iOS (XF 5.0 bug) #33

Open
gaelian opened this issue Feb 16, 2023 · 2 comments
Open

Comments

@gaelian
Copy link

gaelian commented Feb 16, 2023

Maintaining a Xamarin Forms (5.0.0.2545) Fabulous 1.1.0 app and I think I've been hit with this XF bug. A workaround is mentioned, add await Task.Delay(50) before setting items in the CollectionView. I'm having trouble translating this in a way that works, in the context of a Fabulous 1.1.0 XF app. A simplified example of the page:

View.ContentPage(
    title = "Content Page"
    content = 
        View.ScrollView(
            View.CollectionView(
                items = // ???
            )
        )
)

What might be the best approach here?

@TimLariviere
Copy link
Member

@gaelian You could trigger a Cmd that would wait those 50ms before adding the items.
eg.

type Model = { Items: string list; ShouldAddItems: bool }

type Msg = | AllowItems

let delayItemsCmd () =
    Cmd.ofAsyncMsg(
        async {
            do! Async.Sleep 50
            return AllowItems
        }
    )

let init () =
    { Items = [ "A"; "B"; "C" ]; ShouldAddItems = false }, delayItemsCmd()

let update msg model =
    match  msg with
    | AllowItems -> { model with ShouldAddItems = true }, Cmd.none

let view model dispatch =
    View.ContentPage(
        title = "Content Page",
        content =
            View.ScrollView(
                View.CollectionView(
                    items = if model.ShouldAddItems then model.Items else []
                )
           )
   )

@gaelian
Copy link
Author

gaelian commented Feb 16, 2023

Appreciate the help, @TimLariviere. I'll give that a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants