Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import PlaygroundSupport
  2. import SwiftUI
  3.  
  4. struct MouseState {
  5. var corded = 0
  6. var cordless = 0
  7. var magic = 0
  8. var total: Int {
  9. return corded + cordless + magic
  10. }
  11. }
  12.  
  13. struct LiveView: View {
  14. @State var mouseState = MouseState()
  15. var body: some View {
  16.  
  17. VStack(spacing: 50) {
  18.  
  19. HStack {
  20. Image(systemName: "desktopcomputer")
  21. .padding()
  22. .background(Color.white)
  23. .mask(Circle())
  24.  
  25. Text("Mouse Stocks")
  26. .font(.largeTitle)
  27. .color(Color.white)
  28. }.padding()
  29.  
  30. VStack(spacing: 0) {
  31. Stepper(value: $mouseState.corded,
  32. in: 0 ... .max,
  33. step: 1,
  34. label: { return Text("Corded (\(mouseState.corded))").font(.body) })
  35.  
  36. Stepper(value: $mouseState.cordless,
  37. in: 0 ... .max,
  38. step: 1,
  39. label: { return Text("Cordless (\(mouseState.cordless))").font(.body) })
  40.  
  41. Stepper(value: $mouseState.magic,
  42. in: 0 ... .max,
  43. step: 1,
  44. label: { return Text("Magic (\(mouseState.magic))").font(.body) })
  45. }
  46. .padding()
  47. .background(Color.white)
  48.  
  49. HStack {
  50. Text("Total Mice in Inventory:")
  51. Text("\(mouseState.total)")
  52. }
  53. .font(.headline).padding()
  54. }.padding()
  55. .background(Color.blue.opacity(0.5))
  56. // .cornerRadius(32) // uncomment to destroy interactivity
  57. }
  58. }
  59.  
  60. PlaygroundPage.current.liveView = UIHostingController(rootView: LiveView())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement