Skip to content

Instantly share code, notes, and snippets.

View navsing's full-sized avatar
🏠
Working from home

Navdeep Singh navsing

🏠
Working from home
View GitHub Profile
final class SignInWithAppleCoordinator: NSObject {
func getApppleRequest() {
let appleIdProvider = ASAuthorizationAppleIDProvider()
let request = appleIdProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let authController = ASAuthorizationController(authorizationRequests: [request])
authController.delegate = self
authController.performRequests()
}
final class AppleViewModel: ObservableObject {
var signInWithApple = SignInWithAppleCoordinator()
@Published var user: User?
func getRequest() {
signInWithApple.getApppleRequest()
}
func getUserInfo() {
struct Login: View {
@ObservedObject var appleView = AppleViewModel()
var body: some View {
VStack {
if appleView.user != nil {
//User Logged In
} else {
Button(action: {
self.appleView.getRequest()
}){
@navsing
navsing / reminder.swift
Created May 18, 2020 16:58
Let’s recreate the Reminder app in less than 5 minutes 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 {
@navsing
navsing / Tinder.swift
Created May 21, 2020 23:18
Let’s recreate the Tinder Home Screen in less than 5 minutes using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
struct Tinder: View {
var body: some View {
ZStack {
Color.init(red: 242/255, green: 242/255, blue: 242/255).edgesIgnoringSafeArea(.all)
VStack {
HStack {
Image(systemName: "person.fill").resizable().frame(width: 35, height: 35).foregroundColor(.gray)
Spacer()
//
// LandingPage.swift
// Swiftlycode
//
// Created by Navdeep Singh on 5/19/20.
// Copyright © 2020 Navdeep Singh. All rights reserved.
//
import SwiftUI
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)
}
}
@navsing
navsing / MessagesPart-I.swift
Last active August 26, 2024 02:14
Recreating the Messages App Part I using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
var body: some View {
NavigationView {
VStack {
ScrollView (.vertical, showsIndicators: false) {
SearchBar()
Pins()
@navsing
navsing / MessagesPart-II.swift
Last active February 24, 2025 20:45
Recreating the Messages App Part II (Conversation View) using SwiftUI and Swift Playgrounds on iPad
import SwiftUI
import PlaygroundSupport
struct Screen: View {
var body: some View {
VStack {
ChatTopView()
ConversationView()
ChatBottomBar().padding(.bottom, 10)
}