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
@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()
@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 {
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()
}){
final class AppleViewModel: ObservableObject {
var signInWithApple = SignInWithAppleCoordinator()
@Published var user: User?
func getRequest() {
signInWithApple.getApppleRequest()
}
func getUserInfo() {
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()
}
struct AppleIdButton: UIViewRepresentable {
func makeUIView(context: Context) -> ASAuthorizationAppleIDButton {
ASAuthorizationAppleIDButton()
}
func updateUIView(_ uiView: ASAuthorizationAppleIDButton, context: Context) {
}
}
@navsing
navsing / breathe.swift
Created May 14, 2020 19:18
let’s recreate the breathe app in less than 3 minutes 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)
@navsing
navsing / AppStoreHome.swift
Last active August 6, 2023 09:10
Let’s recreate the iOS app store home screen in less than 5 minutes 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)
func scheduleNotifications() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
if success {
print("Success")
//To add badgeNumber
//UIApplication.shared.applicationIconBadgeNumber = badgeNumber (Integer Value)
} else if let error = error {
print(error.localizedDescription)
}
ForEach(self.tasks, id: \.id) { task in
VStack {
Text(task.title)
Button(action: {
if self.favorites.contains(task) {
self.favorites.remove(task)
} else {
self.favorites.add(task)
}
}) {