Declaration
import { EditButton } from 'swiftui-react-native';nonisolated struct EditButtonInitializers
One SwiftUI initializer backs <EditButton>.
<EditButton />nonisolated init()Takes no props.
Also takes the common view props: modifiers, style and testID.
Overview
An edit button toggles the environment's EnvironmentValues.editMode
value for content within a container that supports edit mode.
In the following example, an edit button placed inside a NavigationView
supports editing of a List:
@State private var fruits = [
"Apple",
"Banana",
"Papaya",
"Mango"
]
var body: some View {
NavigationView {
List {
ForEach(fruits, id: \.self) { fruit in
Text(fruit)
}
.onDelete { fruits.remove(atOffsets: $0) }
.onMove { fruits.move(fromOffsets: $0, toOffset: $1) }
}
.navigationTitle("Fruits")
.toolbar {
EditButton()
}
}
}Because the ForEach in the above example defines behaviors for
DynamicViewContent.onDelete(perform:) and
DynamicViewContent.onMove(perform:), the editable list displays the
delete and move UI when the user taps Edit. Notice that the Edit button
displays the title "Done" while edit mode is active:
You can also create custom views that react to changes in the edit mode
state, as described in EditMode.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Views.
- ArrangementViewA view that arranges primary and secondary content using an adaptive layout that responds to the environment.
- ControlGroupA container view that displays semantically-related controls in a visually-appropriate manner for the context
- DividerA visual element that can be used to separate other content.
- EmptyViewA view that doesn't contain any content.
- GaugeA view that shows a value within a range.
- GroupA type that collects multiple instances of a content type --- like views, scenes, or commands --- into a single unit.
- GroupBoxA stylized view, with an optional label, that visually collects a logical grouping of content.
- RenameButtonA button that triggers a standard rename action.
- SwipeActionsSwipe actions of a list row (SwiftUI swipeActions(edge:allowsFullSwipe:content:)). Place it inside a List.
- TimelineViewA view that updates according to a schedule that you provide.
- ViewThatFitsA view that adapts to the available space by providing the first child view that fits.