79584377

Date: 2025-04-21 09:57:34
Score: 0.5
Natty:
Report link

As Benzy Neez said, adding chart to Section .header and using .listRowInsets to snap to edges works fine.

              List {
            Section {
            } header: {
                ZStack {
                    Color.white
                    
                    BasicHealthRangeCharts(samples: viewModel.healthData.compactMap(ChartHealthSample.init(from:)))
                        .padding(.horizontal)
                }
                   
            }
            .listRowInsets(EdgeInsets(top: 0, leading: -32, bottom: 0, trailing: -32))

            
            Section {
                Button {
                    viewModel.onPinButton()
                } label: {
                    Text(viewModel.isPinned ? "Unpin from summary" : "Pin in summary")
                        .foregroundColor(.primary)
                        .padding()
                }
                
            } header: {
                Text("Options")
                    .padding(.vertical, 16)
            }
            .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 16))
            .headerProminence(.increased)
            
            Section {
                NavigationLink {
                    PetHealthAllDataView(dataType: viewModel.type, data: viewModel.healthData)
                } label: {
                    Text("Show all data")
                }
            }
        }

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Wojciech Konury