Skip to content

Instantly share code, notes, and snippets.

@jordansinger
Created June 27, 2020 02:09
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jordansinger/364c448013e35f5477701817689764d2 to your computer and use it in GitHub Desktop.
Save jordansinger/364c448013e35f5477701817689764d2 to your computer and use it in GitHub Desktop.
import SwiftUI
import PlaygroundSupport
struct Content: View {
@State var isExpanded = false
@State var wifiEnabled = true
@State var spacing: CGFloat = 12
var body: some View {
VStack(spacing: self.spacing) {
HStack(spacing: self.spacing) {
VStack {
Ellipse()
.foregroundColor(Color(UIColor.tertiarySystemGroupedBackground))
.overlay(Image(systemName: "airplane"))
.frame(width: 52, height: 52)
if self.isExpanded {
Text("Airplane").font(.caption).fontWeight(.semibold)
}
}
Button(action: {
withAnimation(.easeInOut(duration: 0.15)) {
self.wifiEnabled.toggle()
}
}) {
VStack {
Ellipse()
.foregroundColor(Color(self.wifiEnabled ? UIColor.systemBlue : UIColor.tertiarySystemGroupedBackground))
.overlay(Image(systemName: "wifi"))
.frame(width: 52, height: 52)
if self.isExpanded {
Text("WiFi").font(.caption).fontWeight(.semibold)
}
}
}
.buttonStyle(PlainButtonStyle())
}
HStack(spacing: self.spacing) {
VStack {
Ellipse()
.foregroundColor(Color(UIColor.tertiarySystemGroupedBackground))
.overlay(Image(systemName: "bell.fill"))
.frame(width: 52, height: 52)
if self.isExpanded {
Text("Notifs").font(.caption).fontWeight(.semibold)
}
}
VStack {
Ellipse()
.foregroundColor(Color(UIColor.tertiarySystemGroupedBackground))
.overlay(Image(systemName: "moon.fill"))
.frame(width: 52, height: 52)
if self.isExpanded {
Text("DND").font(.caption).fontWeight(.semibold)
}
}
}
}
.padding(self.spacing)
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(24)
.onTapGesture {
withAnimation(.easeInOut(duration: 0.25)) {
self.isExpanded.toggle()
if self.isExpanded {
self.spacing = 24
} else {
self.spacing = 12
}
}
}
}
}
PlaygroundPage.current.setLiveView(Content())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment