Created
July 27, 2020 18:37
-
-
Save CastIrony/39831c7d0c711c1bf2e319b704d6312f to your computer and use it in GitHub Desktop.
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