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 / MeshGradient.swift
Created July 19, 2024 10:45
MeshGradient on watchOS 11
import SwiftUI
import WatchConnectivity
struct CurrentSongView: View {
@EnvironmentObject var songInfoReceiver: SongInfoReceiver
@State var t: Float = 0.0
@State var timer: Timer?
var body: some View {
NavigationStack {
@rudrankriyam
rudrankriyam / md-toc.rb
Created July 18, 2024 12:00 — forked from JenniferMack/md-toc.rb
Create a table of contents for Ulysses markdown
#!/usr/bin/env ruby
toc = "# Table of Contents\n"
newmd = ""
ARGF.each_line do |line|
newmd << line
next if !line.start_with?("#")
heading = line.gsub("#", "").strip
@rudrankriyam
rudrankriyam / AnimatedMeshView.swift
Created June 12, 2024 22:54
Creating animated music background using SwiftUI's new MeshGradient
//
// AnimatedMeshView.swift
// Fussion
//
// Created by Rudrank Riyam on 11/06/24.
//
import Foundation
import MusicKit
import ColorKit
[
{ "name": "Burj Khalifa", "city": "Dubai", "country": "United Arab Emirates", "height": 828, "yearBuilt": 2010, "latitude": 25.186016587, "longitude": 55.275198221 },
{ "name": "Shanghai Tower", "city": "Shanghai", "country": "China", "height": 632, "yearBuilt": 2015, "latitude": 31.226676271, "longitude": 121.501873778 }
]
@rudrankriyam
rudrankriyam / ContentView.swift
Created September 13, 2021 23:12
ContentView
import SwiftUI
struct ContentView: View {
@StateObject private var viewModel = HomeViewModel()
@Environment(\.openURL) var openURL
var body: some View {
NavigationView {
VStack {
List {
@rudrankriyam
rudrankriyam / HomeButtonsView.swift
Created September 13, 2021 23:12
HomeButtonsView
extension Image {
func imageButton(with size: CGFloat, color: Color) -> some View {
self
.resizable()
.scaledToFit()
.frame(width: size, height: size)
.foregroundColor(color)
}
}
@rudrankriyam
rudrankriyam / ArtworkImage.swift
Created September 13, 2021 23:11
ArtworkImage
struct ArtworkImage<Content>: View where Content: View {
private let url: URL?
private var content: (_ image: Image) -> Content
public init(url: URL?, @ViewBuilder content: @escaping (_ image: Image) -> Content) {
self.url = url
self.content = content
}
var body: some View {
@rudrankriyam
rudrankriyam / ShazamMusicRow.swift
Created September 13, 2021 23:10
ShazamMusicRow
import SwiftUI
struct ShazamMusicRow: View {
var item: SHMediaItem
var body: some View {
ZStack {
ArtworkImage(url: item.artworkURL) { image in
image
.scaledToFill()
@rudrankriyam
rudrankriyam / ShazamMusicCard.swift
Created September 13, 2021 23:09
ShazamMusicCard
import SwiftUI
struct ShazamMusicCard: View {
var item: SHMediaItem
var body: some View {
HStack {
ArtworkImage(url: url) { image in
image
.scaledToFit()
@rudrankriyam
rudrankriyam / HomeViewModel.swift
Created September 13, 2021 23:08
HomeViewModel addToShazamLibrary
public func addToShazamLibrary() {
SHMediaLibrary.default.add(mediaItems) { error in
if let error = error {
print(error)
} else {
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)
}
}
}