Skip to content

Commit

Permalink
Make sheets responsive for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Oct 26, 2024
1 parent f912d98 commit b20362d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ extension DetailList {
.padding(.vertical, 24) // Applies vertical padding of 24 points to the VStack to ensure consistent spacing around the content.
.sheet(isPresented: $isSheetPresented) {
// Content of the sheet goes here
Button("Dismiss") {
let button = Button("Dismiss") {
isSheetPresented.toggle() // Toggles the state of `isSheetDetailPresented` to show or hide the detail sheet.
}
.buttonStyle(ActionButtonStyle()) // Applies the `ActionButtonStyle` to the button for a consistent toggle effect.
#if os(macOS) // Sheets needs some sizng for macOS. These are just fixed sizes.
// Makes sheet sizing for macOS. Dynamic / Responsive
let screenSize = NSApplication.shared.windows.first?.frame.size ?? CGSize(width: 600, height: 400)
button.frame(width: screenSize.width * 0.6, height: screenSize.height * 0.6)
#else
button // no sizing needed for iPad
#endif
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ These are some of the resources that was founds when solving edge cases for the


## Todo:
- Complete comment doc etc (Format the description comments to be 80 character wide) 👈
- Use copilot to write missing doc in the kit 👈
- Test to see if macOS works out of the box

## Future improvements:
Expand Down

0 comments on commit b20362d

Please sign in to comment.