Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 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. ZStack {
  18.  
  19. Rectangle()
  20. .foregroundColor(Color.white)
  21.  
  22. VStack(spacing: 50) {
  23.  
  24. HStack {
  25. Image(systemName: "desktopcomputer")
  26. .padding()
  27. .background(Color.white)
  28. .mask(Circle())
  29.  
  30. Text("Mouse Stocks")
  31. .font(.largeTitle)
  32. .color(Color.white)
  33. }.padding() // HStack
  34.  
  35. VStack(spacing: 0) {
  36. Stepper(value: $mouseState.corded,
  37. in: 0 ... .max,
  38. step: 1,
  39. label: { return Text("Corded (\(mouseState.corded))").font(.body) })
  40.  
  41. Stepper(value: $mouseState.cordless,
  42. in: 0 ... .max,
  43. step: 1,
  44. label: { return Text("Cordless (\(mouseState.cordless))").font(.body) })
  45.  
  46. Stepper(value: $mouseState.magic,
  47. in: 0 ... .max,
  48. step: 1,
  49. label: { return Text("Magic (\(mouseState.magic))").font(.body) })
  50. }
  51. .padding()
  52. .background(Color.white.cornerRadius(8)) // VStack
  53.  
  54. HStack {
  55. Text("Total Mice in Inventory:")
  56. Text("\(mouseState.total)")
  57. }
  58. .font(.headline).padding() // HStack
  59. }
  60. .padding()
  61. .background(Color.blue.opacity(0.5).cornerRadius(16)) // VStack
  62.  
  63. }.background(Color.white) // ZStack
  64. }
  65. }
  66.  
  67. PlaygroundPage.current.liveView = UIHostingController(rootView: LiveView())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement