Created
July 27, 2020 18:37
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ListTestView: View { | |
@State private var users = ["Paul", "Taylor", "Adele"] | |
var body: some View { | |
NavigationView { | |
List { | |
ForEach(users, id: \.self) { user in | |
Text(user) | |
} | |
.onMove(perform: move) | |
} | |
.navigationBarItems(trailing: EditButton()) | |
} | |
} | |
func move(from source: IndexSet, to destination: Int) { | |
users.move(fromOffsets: source, toOffset: destination) | |
} | |
} | |
struct ListTestView_Previews: PreviewProvider { | |
static var previews: some View { | |
ListTestView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment