Skip to content

Instantly share code, notes, and snippets.

@wb-softwares
wb-softwares / tinder.swift
Last active April 15, 2024 13:53
Recreating the Tinder home screen using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
@State var size: CGSize = .zero
var body: some View {
//Lets Start with our Tinder Home Screen Recreate
//First, we need entire background to be gray-ish color. ZStack puts different views on top of each other.
ZStack {
@wb-softwares
wb-softwares / Breathe.swift
Created June 18, 2020 21:43
Recreating the Breathe app using SwiftUI and Swift Playgrounds on iPad
struct Breathe: View {
@State var scale = false
@State var rotate = false
var body: some View {
ZStack {
Group {
ZStack {
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: -42)
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: 42)
@wb-softwares
wb-softwares / iOSHomeScreen.swift
Created June 18, 2020 21:36
Recreating the iOS App Store home screen using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
var body: some View {
ScrollView {
HStack {
VStack (alignment: .leading) {
Text("TUESDAY, MAY 12").foregroundColor(.secondary).bold().font(.footnote)
Text("Today").font(.largeTitle).bold()
@wb-softwares
wb-softwares / Reminders.swift
Created June 18, 2020 21:29
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 {
struct ImageContentView : View {
@State var url = "https://link-to-image"
var body: some View {
VStack {
ImageView(url: url)
}
}
import Combine
import SwiftUI
struct ImageViewController: View {
@ObservedObject var url: LoadUrlImage
init(imageUrl: String) {
url = LoadUrlImage(imageURL: imageUrl)
}
var body: some View {
class RemoteImageModel: ObservableObject {
@Published var displayImage: UIImage?
var imageUrl: String?
var cachedImage = CachedImage.getCachedImage()
init(imageUrl: String?) {
self.imageUrl = imageUrl
if imageFromCache() {
return
}
struct ImageUrlView: View {
@ObservedObject var remoteImageModel: RemoteImageModel
init(url: String?) {
remoteImageModel = RemoteImageModel(imageUrl: imageUrl)
}
var body: some View {
Image(uiImage: remoteImageModel.image ?? UIImage(named: "default-image-here")!)
.resizable()
Network.shared.apollo.perform(mutation: CreatePersonMutation(input: personInput)) { result in
switch result {
case .success(let graphQLResult):
print(graphQLResult)
case .failure(let error):
print("Failure! Error: \(error)")
}
}
Network.shared.apollo.fetch(query: ListPersonQuery) { result in
switch result {
case .success(let graphQLResult):
if let items = graphQLResult.data?.listPerson?.items {
for conf in items {
if let curPerson = conf {
//Do whatever here with your Graphql Result
print(curPerson)
}
}