GithubHelp home page GithubHelp logo

Comments (8)

vmanot avatar vmanot commented on May 2, 2024 1

@MatteCarra I'm currently struggling to fix content offset correction myself - UITableView is just fucked in terms of how/when it updates contentSize. I'm thinking about ditching it altogether and switching to UICollectionView (a port that I'm working on).

from swiftuix.

MatteCarra avatar MatteCarra commented on May 2, 2024 1

I'm not in a rush, by I'm actively trying to find a solution to the problem.
I'm actually playing around with swift for the first time and I've on my back 3 days experience of practice and only a few hours on uikit.

I'm looking forward on collaborating to this great project.

from swiftuix.

MatteCarra avatar MatteCarra commented on May 2, 2024

I have done more tests in a simpler project and was not able to reproduce the multiple calls to the observeValue.
I will perform more tests on the other project, but why was the condition oldContentSize.maximumDimensionLength < newContentSize.maximumDimensionLength imposed?

from swiftuix.

MatteCarra avatar MatteCarra commented on May 2, 2024

I was able to reproduce the issue in a demo project by adding a vertical padding:

import SwiftUI
import SwiftUIX

struct Item: Codable, Equatable, Identifiable {
    let id = UUID()
}

struct ContentView: View {
    @State var items: [Item] = []
    
    var body: some View {
        VStack {
            CocoaList(items) { item in
                Text("Hello, World \(item.id)")
                    .padding(.vertical, 30)
            }.initialContentAlignment(.bottom)
            
            Button(action: {
                self.items.append(Item())
            }) {
                Text("Add")
            }
        }
    }
}

You can use this code to reproduce the bug.

from swiftuix.

MatteCarra avatar MatteCarra commented on May 2, 2024

Thanks for the confirmation.
I was not aware of this issue with UITableView before.
I'm looking forward to your UICollectionView port.
Thanks

from swiftuix.

vmanot avatar vmanot commented on May 2, 2024

@MatteCarra if you need this functionality ASAP - I'd recommend you try raising a workaround/patch PR (you seem to have understood the issue exactly). I'm available if you need any assistance in understanding the code - which I understand is under-documented currently.

from swiftuix.

MatteCarra avatar MatteCarra commented on May 2, 2024

I was able to perform some working tests with CocoaList, but I have some questions for the desired implementation.

What is initialContentAlignment designed to do?

I think that a common use case of initialContentAlignment could be for a logs/chat view: messages start filling from top until all the view is filled and then the list is automatically scrolled to the last element whenever a new item is added.

I would also need to know why you imposed the condition oldContentSize.maximumDimensionLength < newContentSize.maximumDimensionLength.

Please let me know.

from swiftuix.

vmanot avatar vmanot commented on May 2, 2024

@MatteCarra the purpose of initialContentAlignment is to describe the initial content offset for the scroll view (be it a basic scroll view, a table view or a collection view). This is useful when, yes, you're developing a chat application and the scroll view must be scrolled to the very bottom at the start.

The reason I'd imposed that condition is because UITableView has this weird behavior where when reloadData() is called after new items are added, the contentSize decreases and then increases. I fear this condition is more harmful than good, so feel free to remove it.

from swiftuix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.