Skip to content

Instantly share code, notes, and snippets.

@wb-softwares
Created June 18, 2020 21:29
Show Gist options
  • Save wb-softwares/47d551b76a626e1b761c47781a1202f3 to your computer and use it in GitHub Desktop.
Save wb-softwares/47d551b76a626e1b761c47781a1202f3 to your computer and use it in GitHub Desktop.
Recreating the Reminders app using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.systemBlue]
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor.systemBlue]
}
@State var tasks = ["Meal Prep", "Call Family", "Do Laundry"]
var body: some View {
NavigationView {
VStack (alignment: .leading) {
List {
ForEach(self.tasks, id: \.self) { task in
HStack {
Image(systemName: "circle").resizable().frame(width: 20, height: 20)
Text(task)
}
}.onDelete { indexSet in
self.tasks.remove(atOffsets: indexSet)
}
}
Button(action:{}) {
HStack {
Image(systemName: "plus.circle.fill").resizable().frame(width: 20, height: 20)
Text("New Reminder").foregroundColor(.blue)
}
}.padding()
}.navigationBarTitle("Reminders").navigationBarItems(trailing: Button(action: {}) {
Image(systemName: "ellipsis.circle")
})
}
}
}
PlaygroundPage.current.setLiveView(Screen())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment