Skip to content

Instantly share code, notes, and snippets.

View emin-grbo's full-sized avatar
💻
Getting Schwifty

emin emin-grbo

💻
Getting Schwifty
View GitHub Profile
@emin-grbo
emin-grbo / decodeOrReport.swift
Created February 13, 2024 10:39
DecodeOrReport
// Used to detect specific issue with JSON decoding
func decodeOrReport(data: Data) {
do {
let _ = try JSONDecoder().decode(WidgetResponse.self, from: data)
print("\n\n👍ALL GOOD\n\n")
} catch DecodingError.keyNotFound( let key, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
print("could not find key \(key) in JSON: \(context.debugDescription)")
} catch DecodingError.valueNotFound( let type, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
struct AnimationWithReduceMotion<V: Equatable>: ViewModifier {
@Environment(\.accessibilityReduceMotion)
private var reduceMotion
var animation: Animation?
let value: V
func body(content: Content) -> some View {
content
@emin-grbo
emin-grbo / MaterialView.swift
Created August 24, 2022 07:06
MaterialView
struct MaterialView: View {
var foregroundColor: Color = Color.purple
let text: String
var body: some View {
Text(text)
.padding()
.background(.quaternary)
.foregroundStyle(foregroundColor)
import SwiftUI
import CoreMotion
struct CMMotionManagerTest: View {
@StateObject var motion = MotionManager()
var body: some View {
ZStack {
Color.purple
@emin-grbo
emin-grbo / 1. App.swift
Last active May 22, 2022 06:45
Voodo Arch Template
@main
struct mainApp: App {
init() {
// custom init if needed. Analytics setup and similar
}
var body: some Scene {
WindowGroup {
MainView(mainObservableObject: MainObservableObject())
@emin-grbo
emin-grbo / severance.swift
Last active April 20, 2022 08:33
Severance screentest
import SwiftUI
struct ContentView: View {
let rows = Array(repeating: GridItem(), count: 10)
@State var change: Bool = false {
didSet {
toggle()
}
@emin-grbo
emin-grbo / UnsafeRing.swift
Last active November 16, 2021 09:48
Example of a ring designed in swiftUI for un:safe app (unsafe.undeadpixel.dev)
import SwiftUI
struct Ring: View {
var body: some View {
HStack {
Spacer()
ZStack(alignment: .trailing) {
Circle()
.strokeBorder(Color.circleGradientColor, lineWidth: 50)
Circle()
@emin-grbo
emin-grbo / colors.swift
Last active November 14, 2021 19:08
Water Colors
extension Color {
// MARK: Gradients
static var backgroundGradient = LinearGradient(colors: [Color(hex: "#50A7F7"), Color(hex: "#2566F6")], startPoint: .top, endPoint: .bottom)
static var topWaterColor = Color(hex: "#739BF7")
static var midWaterColor = Color(hex: "#5989F5")
static var backWaterColor = Color(hex: "#4979E7")
static var buttonGradient = LinearGradient(colors: [Color(hex: "#F4F8FA"), Color(hex: "#B6CCF7")], startPoint: .top, endPoint: .bottom)
}
@emin-grbo
emin-grbo / haptictTest
Created August 19, 2021 20:03
Watch Haptics preview
import SwiftUI
struct ContentViewWatch: View {
@State var selection = 0
var body: some View {
VStack {
Picker("Haptic Type", selection: $selection) {
Text("notification").tag(0)
@emin-grbo
emin-grbo / BlendModes.swift
Created July 14, 2021 17:13
SwiftUI Blend modes Preview
import SwiftUI
struct Blender: Identifiable {
let id = UUID()
let mode: BlendMode
let name: String
}
struct BlendModes: View {