Skip to content

Instantly share code, notes, and snippets.

View tanmays's full-sized avatar

Tanmay tanmays

View GitHub Profile
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let btn = UIButton(type: .system)
btn.translatesAutoresizingMaskIntoConstraints = false
btn.setTitle("Show Sheet", for: .normal)
btn.addTarget(self, action: #selector(tap), for: .touchUpInside)
@lifeutilityapps
lifeutilityapps / ExportUserDataView.swift
Created December 8, 2024 14:24
A simple full screen cover view that allows the user to export their data.
//
// ExportUserDataView.swift
// DownPay for iOS
//
// Created by Life Utility Apps on 12/6/24.
//
import SwiftUI
enum EAppUserDataExportFileType: String, Identifiable, CaseIterable {
//
// DarkModeMasker.swift
// SwiftUI Demos
//
// Created by Morten Just on 1/22/23.
// https://twitter.com/joshguospace/status/1617101052192649216?s=12
import SwiftUI
import Charts
@beader
beader / InfiniteScrollChart.swift
Last active August 28, 2024 18:16
Infinite Scrollable Bar Chart using Swift Charts
//
// InfiniteScrollChart.swift
// ChartsGallery
//
// Created by beader on 2022/11/3.
//
import SwiftUI
import Charts
func scrollViewDidScroll(_ scrollView: UIScrollView) {
for (i, view) in scrollView.subviews.enumerated() {
var ty = 0.0
if scrollView.contentOffset.y < 0 {
// We're scrolling past the top of the scroll view.
// Translate each item in the scroll view by some amount based on its index and scroll offset.
ty = CGFloat(i) * abs(offsetY) / 8.0 * pow(1.12, CGFloat(i))
}
view.transform = CGAffineTransform(translationX: 0, y: ty)
}
JSON:
https://unpkg.com/[email protected]/emoji.json
class EmojiManager: ObservableObject {
@Published var emojis: [EmojiObject] = []
init() {
decodeJSON()
class FloatingPanel: NSPanel {
init(contentRect: NSRect, backing: NSWindow.BackingStoreType, defer flag: Bool) {
// Not sure if .titled does affect anything here. Kept it because I think it might help with accessibility but I did not test that.
super.init(contentRect: contentRect, styleMask: [.nonactivatingPanel, .resizable, .closable, .fullSizeContentView], backing: backing, defer: flag)
// Set this if you want the panel to remember its size/position
// self.setFrameAutosaveName("a unique name")
// Allow the pannel to be on top of almost all other windows
//
// ContentView.swift
// HonkHonk
//
// Created by Thomas Ricouard on 23/12/2020.
//
import SwiftUI
@Priva28
Priva28 / GradientEffect.swift
Last active December 1, 2023 04:43
Gradient effect to emulate Apple Music Lyrics/Now Playing screen.
//
// ContentView.swift
// GradientEffect
//
// Created by Christian Privitelli on 18/7/20.
//
import SwiftUI
struct ContentView: View {
@cyrilzakka
cyrilzakka / ContentView.swift
Created July 26, 2019 21:03
Simple Image Viewer using SwiftUI
//
// ContentView.swift
// Scribe
//
// Created by Cyril Zakka on 7/21/19.
// Copyright © 2019 Cyril Zakka. All rights reserved.
//
import SwiftUI
struct ContentView: View {