Skip to content

Commit

Permalink
sheet 关闭按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Jun 3, 2024
1 parent 9abd0e9 commit 9390b17
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
14 changes: 8 additions & 6 deletions SwiftPamphletApp/InfoOrganizer/Info/EditInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import SMUI

struct EditInfoView: View {
@Environment(\.modelContext) var modelContext
@Environment(\.dismiss) var dismiss
@Bindable var info: IOInfo
@Query(IOCategory.all) var categories: [IOCategory]
@State private var showSheet = false
Expand Down Expand Up @@ -341,14 +342,15 @@ struct EditInfoView: View {
.padding(.leading, 1)
}
.padding(2)
Button(action: {
showSheet = false
}, label: {
Label("关闭", systemImage: "xmark.circle")
})
.padding(2)
}
.padding(20)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("关闭", systemImage: "xmark") {
showSheet = false
}
}
}
})
.keyboardShortcut(KeyEquivalent("s"), modifiers: .command)
}
Expand Down
13 changes: 7 additions & 6 deletions SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,13 @@ struct InfoListView: View {
.padding(.leading, 1)
}
.padding(2)
Button(action: {
showSheet = false
}, label: {
Label("关闭", systemImage: "xmark.circle")
})
.padding(2)
}
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("关闭", systemImage: "xmark") {
showSheet = false
}
}
}
.padding(20)
})
Expand Down
12 changes: 12 additions & 0 deletions SwiftPamphletApp/Resource/Guide/SwiftUI/浮层组件/Sheet(ap).md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ struct ShoppingCartDetailView: View {
}
```

## 添加工具栏按钮

```swift
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("关闭", systemImage: "xmark") {
showSheet = false
}
}
}
```


## 多 Sheet

Expand Down

0 comments on commit 9390b17

Please sign in to comment.