fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 122 forks source link

Strange map control behaviour in collection view #751

Closed vshapenko closed 4 years ago

vshapenko commented 4 years ago

Hello! Here is a sample app shows strange behavior of Map control in CollectionView. Control behaves strange only if hasZoomEnabled = false, hasScrollEnabled = false

If i put those values to true, behavior is ok, it shows location, otherwise it just show a generic map with coords (0,0) as far as i understand Do not know whether this one is XF or Fabulous related issue.

module App = 
    type Model = 
      {

        Items:(float*float) list
        }

    type Msg = 
        | Next 

    let random = Random(DateTime.UtcNow.Ticks|>int)

    let initModel () = {Items = [] }

    let init () = initModel () , []

    let update msg model =
        match msg with
        | Next ->
            let newItems = [
                            yield! model.Items
                            for i in 0..50 do
                                let lat= random.Next(90)
                                let lon = random.Next(180)
                                yield (float lat,float lon)

                           ]
            {model with Items= newItems}
            ,Cmd.none

    let drawItem (lat,lon)  =
        let span = MapSpan.FromCenterAndRadius(Position(lat,lon),Distance.FromKilometers(100.))
        View.ContentView(
            margin=Thickness 20.,
            content= View.Map(
                                 requestedRegion = span,
                                 height=200.,
                                 width=200.,
                                 hasZoomEnabled = false,
                                 hasScrollEnabled = false

                             )
            )

    let view (model: Model) dispatch =

        View.ContentPage(
          content=View.StackLayout(
            children = [
                View.CollectionView(
                                       itemSizingStrategy =ItemSizingStrategy.MeasureAllItems,
                                       items = (model.Items|>List.map drawItem)
                                   ) |> verticalOptions LayoutOptions.StartAndExpand

                View.Button(text ="Next", command = (fun()->dispatch Next))

              ]
            )

            )

    let program = 
        Program.mkProgram init update view
TimLariviere commented 4 years ago

Which version do you use? Is it happening on 0.55-preview3 or 0.54.1?

vshapenko commented 4 years ago

Sample is for 0.54.1. 0.55 is not production ready yet. It has some issues with CollectionView.

TimLariviere commented 4 years ago

It is an issue in Xamarin.Forms. I also reproduced it in C#/XAML. Opened a ticket on the XF GitHub: https://github.com/xamarin/Xamarin.Forms/issues/11115

TimLariviere commented 4 years ago

Closing. Please refer to the Xamarin.Forms issue instead.