Skip to content

Instantly share code, notes, and snippets.

View rudrankriyam's full-sized avatar
🎵
Living.

Rudrank Riyam rudrankriyam

🎵
Living.
View GitHub Profile
@rudrankriyam
rudrankriyam / HomeViewModel.swift
Created September 13, 2021 23:04
HomeViewModel ShazamKit experiment
import Combine
import ShazamKit
import AVKit
@MainActor
class HomeViewModel: NSObject, ObservableObject {
// 1
@Published private(set) var mediaItems: [SHMediaItem] = []
// 2
@rudrankriyam
rudrankriyam / githubaction.yaml
Created September 7, 2021 12:20
Github actiona yaml example
name: Swift
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
@rudrankriyam
rudrankriyam / codemagic.yaml
Created September 7, 2021 12:19
Codemagic yaml file example
workflows:
ios-workflow:
name: iOS Workflow
environment:
vars:
XCODE_PROJECT: "CICDExample.xcodeproj"
XCODE_SCHEME: "CICDExample"
BUNDLE_ID: "com.rudrankriyam.cicdexample"
APP_STORE_CONNECT_ISSUER_ID: Encrypted(...)
APP_STORE_CONNECT_KEY_IDENTIFIER: Encrypted(...)
struct RGBView: View {
@State var targetRed = random()
@State var targetGreen = random()
@State var targetBlue = random()
@State var yourRed = rgbColor
@State var yourGreen = rgbColor
@State var yourBlue = rgbColor
// rest of the thousands of lines of code
class RGBViewModel: ObservableObject {
@Published var targetColor: RGBColorProtocol
@Published var userColor: RGBColorProtocol
init(targetColor: RGBColorProtocol, userColor: RGBColorProtocol) {
self.targetColor = targetColor
self.userColor = userColor
}
}
class RGBRandomColor: RGBColorProtocol {
var red: Double = Constants.random
var green: Double = Constants.random
var blue: Double = Constants.random
}
class RGBUserColor: RGBColorProtocol {
static let initial: Double = 188/255
var red: Double = RGBInitialColor.initial
protocol GradientProtocol {
var startColor: ColorProtocol { get set }
var endColor: ColorProtocol { get set }
func new() -> Gradient
}
extension GradientProtocol {
func new() -> Gradient {
Gradient(colors: [startColor.new(), endColor.new()])
@rudrankriyam
rudrankriyam / ColorKitProtocols.swift
Created July 8, 2021 20:21
Protocols for my app
protocol RGBColorProtocol: ColorProtocol {
var red: Double { get set }
var green: Double { get set }
var blue: Double { get set }
}
extension RGBColorProtocol {
func new() -> Color {
Color(red: red, green: green, blue: blue)
}
MusicRowView(song: song)
.swipeActions(edge: .leading) {
Button {
withAnimation {
// Mark the song favorite
}
} label: {
Label("Favorite", systemImage: "star")
}
.tint(.brand)
Button(action: login) {
Text("Log in")
.bold()
.frame(maxWidth: .infinity)
}
.buttonStyle(.bordered)
.tint(.brand)
.controlSize(.large)
.controlProminence(.increased)
.padding([.horizontal, .bottom])