ios – SwiftUI: How to Move a Circle View Outside and Left of a List?


I am working on a SwiftUI project and have encountered a design challenge. In my current setup, I have a List that displays posts. Each post in the list has a small green dot (Circle) aligned to the left within an HStack. Here’s the relevant snippet of my code:

screenshot

List {
    Section(header: Text("New")) {
        ForEach(viewModel.posts.filter { !$0.isReposted }) { post in
            HStack(alignment: .center, spacing: 5) {
                Circle()
                    .fill(Color.green)
                    .frame(width: 5, height: 5)
                    .cornerRadius(10)
                    .padding(.leading, -16)
                PostView(post: post)
                // ... Other views
            }
        }
        // ... Other sections and views
    }
}

I would like to move this green dot so that it is positioned outside and to the left of the List, rather than within each list item. My goal is to have the dot aligned with each post but not be part of the list row itself.

Is it even possible?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img