CopyPastor

Detecting plagiarism made easy.

Score: 0.8146079182624817; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2020-07-25
by Asperi

Original Post

Original - Posted on 2019-11-16
by Anton



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Use `PlainButtonStyle` (or any custom one), because default button style is detected by List automatically to highlight entire row.
Here is a simplified (from your code) demo:
``` struct DemoListWithButtons: View { var body: some View { List { ForEach(0..<5, id: \.self) { item in HStack { Spacer() Button(action: { print("Button One tapped!") }) { Text("First") }.buttonStyle(PlainButtonStyle()) // << here !! Spacer() Button(action: { print("Button Two tapped!") }) { Text("Second") }.buttonStyle(PlainButtonStyle()) // << here !! } } } } } ```
Set the button style to something different from the default, e.g., BorderlessButtonStyle()
struct Test: View { var body: some View { NavigationView { List { ForEach([ "Line 1", "Line 2", ], id: \.self) { item in HStack { Text("\(item)") Spacer() Button(action: { print("\(item) 1")}) { Text("Button 1") } Button(action: { print("\(item) 2")}) { Text("Button 2") } } } .onDelete { _ in } .buttonStyle(BorderlessButtonStyle()) } .navigationBarItems(trailing: EditButton()) } .accentColor(.red) } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;