Skip to content

Instantly share code, notes, and snippets.

View jordibruin's full-sized avatar

Jordi Bruin jordibruin

View GitHub Profile
//
// Store.swift
// Posture Pal
//
// Created by Jordi Bruin on 28/02/2022.
//
import Foundation
import Foundation
@jordibruin
jordibruin / gist:3ed5dede27a390c49415d55dc3c77944
Created November 14, 2022 23:03
Interact with background while presenting sheet
@available(iOS 16.0, *)
extension View {
func presentationDetents(
undimmed detents: Set<PresentationDetent>
) -> some View {
self.presentationDetents(detents)
.background(UndimmedDetentView())
}
import SwiftUI
@main
struct MenuBarApp: App {
@NSApplicationDelegateAdaptor(StatusBarDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
@jordibruin
jordibruin / gist:7d0c24d0268bd7aadc5a0203f33583ae
Created July 1, 2022 12:35
BookCover generator for Paper app
//
// ContentView.swift
// BookCover
//
// Created by Jordi Bruin on 01/07/2022.
//
import SwiftUI
struct ContentView: View {
@jordibruin
jordibruin / CGSPrivate.h
Created April 24, 2022 09:54 — forked from rjw57/CGSPrivate.h
CGSPrivate.h - undocumented APIs for OSX. Re-licensed under MIT licence.
/* CGSPrivate.h -- Header file for undocumented CoreGraphics stuff. */
/* This file is a relicensed portion of DesktopManager and was originally released under
* the terms of the GNU General Public Licence. Original licence text follows the new terms.
* The contents of this file has been re-released by the original author under the following terms:
*
* Copyright (C) 2003, 2004, 2013 Richard J Wareham <richwareham@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
JSON:
https://unpkg.com/emoji.json@13.1.0/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
enum ThemeMode: CaseIterable {
case light
case dark
case system
var text: String {
switch self {
case .light:
return "Light"
case .dark:
//
// ContentView.swift
// constraint test
//
// Created by Jordi Bruin on 01/04/2021.
//
import SwiftUI
// 1. Click the "Open Detail View" button
@jordibruin
jordibruin / ReviewTabView.swift
Created October 14, 2020 23:23
Simple App Store Review showcase in SwiftUI
struct ReviewTabView: View {
var reviews: [Review] = [
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."),
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."),
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."),
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."),
]
@State var selectedIndex = 0
@State var timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect()