Skip to content

Instantly share code, notes, and snippets.

Avatar
👓
Trying to do something

Robert Vojta zrzka

👓
Trying to do something
View GitHub Profile
View ViewController.swift
class ClipView: NSClipView {
var isScrollAnimationEnabled: Bool = true
override func scroll(to newOrigin: NSPoint) {
if isScrollAnimationEnabled {
super.scroll(to: newOrigin)
} else {
setBoundsOrigin(newOrigin)
}
}
View ViewController2.swift
// Finder like two levels
import Cocoa
class ViewController: NSViewController {
@IBOutlet var outlineView: NSOutlineView?
let data = [
Node(1, "Group A", true, [
Node(11, "A 1"),
@zrzka
zrzka / colors-blue.txt
Last active Jun 16, 2020
macOS Catalina colors
View colors-blue.txt
ColorList: Apple
0.000000 0.000000 0.000000 1.000000 Black
0.016804 0.198351 1.000000 1.000000 Blue
0.667998 0.475121 0.258601 1.000000 Brown
0.000000 0.991439 1.000000 1.000000 Cyan
0.000000 0.976805 0.000000 1.000000 Green
1.000000 0.252792 1.000000 1.000000 Magenta
1.000000 0.576372 0.000000 1.000000 Orange
0.579194 0.128014 0.572686 1.000000 Purple
1.000000 0.149131 0.000000 1.000000 Red
View AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)monitorMouseLocationNSEvent {
void (^printMouseLocation)(NSString *, NSEvent *) = ^(NSString *type, NSEvent *event) {
View ViewController.m
//
// Copyright © 2020 Robert Vojta. All rights reserved.
//
#import "ViewController.h"
@interface UIView(ColorAtPoint)
- (UIColor *)colorAt:(CGPoint)point;
@zrzka
zrzka / ContentView.swift
Created May 19, 2020
TrackPadView with touches
View ContentView.swift
import SwiftUI
import AppKit
protocol AppKitTouchesViewDelegate: AnyObject {
// Provides `.touching` touches only.
func touchesView(_ view: AppKitTouchesView, didUpdateTouchingTouches touches: Set<NSTouch>)
}
final class AppKitTouchesView: NSView {
weak var delegate: AppKitTouchesViewDelegate?
@zrzka
zrzka / !IMPORTANT.md
Last active Mar 2, 2020 — forked from chockenberry/tot.sh
A shell script for Tot
View !IMPORTANT.md
@zrzka
zrzka / DeepLink.swift
Last active Feb 25, 2020
SwiftUI - NavigationView - Deep Link
View DeepLink.swift
View SignalStrengthIndicator.swift
import SwiftUI
struct SignalStrengthIndicator: View {
/// Spacing between individual bars.
@State var barSpacing: CGFloat = 2
/// Minimal height of a bar (`0.1` means 10% of the actual height).
@State var minBarHeight: CGFloat = 0.1
/// Individual bar corner radius.
@State var barCornerRadius: CGFloat = 8.0
@zrzka
zrzka / View+KeyboardAdapter.swift
Last active Feb 12, 2020
SwiftUI Keyboard Adapter
View View+KeyboardAdapter.swift
import Combine
import SwiftUI
import UIKit
private struct KeyboardInfo {
let height: CGFloat
let eventuallyVisible: Bool
private let animationDuration: Double