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
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 / network.swift
Created January 6, 2023 18:48
Network Layer
import Foundation
import Apollo
class Network {
static let shared = Network()
let apollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
"x-api-key": "<YOUR-API-KEY>"
]
@navsing
navsing / ShimmerEffect.swift
Created January 5, 2023 23:51
Shimmer Effect Sample
import SwiftUI
struct Shimmer: View {
@State var loading = true
var body: some View {
Group {
if self.loading {
ScrollView(.vertical, showsIndicators: false) {
VStack{
HStack {
@navsing
navsing / CardShimmerSample.swift
Created January 5, 2023 23:50
Card Shimmer Sample
struct CardShimmer : View {
@State var show = false
var center = (UIScreen.main.bounds.width / 2) + 110 //removing padding with this hack
var body : some View{
ZStack{
Color.black.opacity(0.08)
.frame(height: 250)
.cornerRadius(20)
Color.white
.frame(height: 250)
@navsing
navsing / TextShimmerSample.swift
Created January 5, 2023 23:48
Text Shimmer Sample
struct TextShimmer : View {
@State var show = false
var body : some View{
ZStack{
Text("Shimmer").fontWeight(.heavy).font(.largeTitle).foregroundColor(Color(UIColor.systemOrange)).redacted(reason: .placeholder)
Text("Shimmer").fontWeight(.heavy).font(.largeTitle).foregroundColor(.white)
.mask(
Capsule()
.fill(LinearGradient(gradient: .init(colors: [.clear,.white,.clear]), startPoint: .top, endPoint: .bottom))
.rotationEffect(.init(degrees: 60)) //just to tilt the shimmer a little to prettify it
@navsing
navsing / ShimmerSampleView.swift
Created January 5, 2023 23:45
Shimmer Sample View
ScrollView(.vertical, showsIndicators: false) {
VStack {
HStack {
VStack (alignment: .leading) {
Text("Shimmer").fontWeight(.heavy).font(.largeTitle).foregroundColor(Color(UIColor.systemOrange))
}
Spacer()
}
ForEach(0..<4){_ in
ZStack {
@navsing
navsing / clubhouse.swift
Created February 11, 2021 21:22
Recreating ClubHouse in SwiftUI with Dark Mode
//
// Clubhouse.swift
// Playground
//
// Created by Nav Singh on 2/11/21.
//
import SwiftUI
struct Clubhouse: View {
import SwiftUI
struct PaymentRing: View {
@State var frameSize = UIScreen.main.bounds.width - 120
@State var current: CGFloat = 0
@State var value: Double = 0
var body: some View {
VStack {
ZStack {
Circle().stroke(Color.secondary, style: StrokeStyle(lineWidth: 40, lineCap: .butt, lineJoin: .round)).frame(width: frameSize, height: frameSize)
import SwiftUI
import PlaygroundSupport
struct Screen: View {
@State var show = false
@State var items: [Any] = []
var body: some View {
VStack {
Button(action: {
self.items.removeAll()
@navsing
navsing / applemusicanimate.swift
Last active November 17, 2024 05:05
Recreating Apple Music Animation Using SwiftUI and Xcode
import SwiftUI
struct AppleMusicAnimation: View {
@State var show = false
@Namespace var namespace
var body: some View {
VStack {
Spacer()
VStack (spacing: 15) {