Skip to content

Instantly share code, notes, and snippets.

View krzyzanowskim's full-sized avatar

Marcin Krzyzanowski krzyzanowskim

View GitHub Profile
@krzyzanowskim
krzyzanowskim / reversible-formatstyle.swift
Last active July 21, 2023 14:21
ReversibleFormatStyle - like FormatStyle but reversible, more like Formatter
import Foundation
// like FormatStyle but reversible, more like Formatter
protocol ReversibleFormatStyle<FormatOutput>: FormatStyle {
func format(_ value: FormatOutput) -> FormatInput
}
// Implementation
struct ReversibleNumFormatStyle: ReversibleFormatStyle {
@krzyzanowskim
krzyzanowskim / box.swift
Created June 3, 2023 10:36
A SwiftUI wrapper around NSBox
/// A SwiftUI wrapper around `NSBox`.
public struct Box<Content>: View where Content: View {
private let title: String?
private let content: () -> Content
public init(_ title: String? = nil, @ViewBuilder content: @escaping () -> Content) {
self.title = title
self.content = content
}
@krzyzanowskim
krzyzanowskim / blogpost.txt
Last active June 28, 2024 07:03
Designing a Stunning macOS Icon for Your Text Editor: A Step-by-Step Guide https://twitter.com/krzyzanowskim/status/1653742801014726658
Title: Designing a Stunning macOS Icon for Your Text Editor: A Step-by-Step Guide
Introduction:
In the world of macOS applications, an eye-catching icon plays a crucial role in attracting users and conveying the essence of your software. When it comes to a text editor, your macOS icon should reflect the simplicity, elegance, and functionality of your application. In this blog post, we will explore the art of designing a stunning macOS icon for your text editor, step by step. Let's dive in!
Step 1: Understand Your Brand and Target Audience:
Before starting the icon design process, it's important to have a clear understanding of your brand and target audience. Ask yourself questions like: What are the unique features of your text editor? What emotions or feelings do you want your icon to evoke? Understanding your brand and target audience will help you create an icon that resonates with your users.
Step 2: Research and Inspiration:
Take some time to research existing macOS icons, especially those in the text
@krzyzanowskim
krzyzanowskim / pitch.md
Last active March 17, 2023 18:13
Swift Studio Investment Pitch

Dear [Name] Investments,

I am excited to introduce Swift Studio, a cutting-edge platform for Swift development, specifically tailored to Swift on Server. As you know, Swift is quickly gaining popularity as a language for developing server-side applications, and Swift Studio is the perfect tool for developers looking to take advantage of this trend.

Swift Studio is a comprehensive development environment that streamlines the development process by providing an intuitive user interface and powerful features. With Swift Studio, developers can easily create, test, and deploy Swift applications for the server, all in one place.

One of the key features of Swift Studio is its real-time collaboration functionality, which allows multiple developers to work on the same project simultaneously. This feature enhances productivity and promotes teamwork, making Swift Studio an ideal solution for larger development teams.

Additionally, Swift Studio integrates seamlessly with other popular development tools and technologi

/// NavigationSplitView default a List in left view to Sidebar style, and then swipeActions modifier stop working. It's a multi level regression. The swipeActions has been broken for a while, but in macOS 12 it didn't work in .sidebar list style neither
NavigationSplitView {
List {
ForEach(list, id: \.self) { item in
HStack {
Text(item.title)
}
.contentShape(Rectangle())
}
/// This code defines an init method for the Binding type. This method accepts three parameters:
///
/// An object of any type T
/// A key path to a property of type Value on that object
/// An optional UndoManager object
///
/// The init method sets the Binding value to the value of the property specified by the key path. It also sets the set value of the Binding to a closure that updates the value of the property at the key path and registers an undo operation with the provided UndoManager, if one is given.
///
/// This allows the Binding object to be used to access and update the value of the specified property on the provided object, and to register undo operations for those updates with the UndoManager.
// Backport SwiftUI.Toggle.init(_:sources:isOn:)
// https://developer.apple.com/documentation/swiftui/toggle/init(_:ison:)-8qx3l
@available(iOS, deprecated: 16.0)
@available(macOS, deprecated: 13.0)
@available(tvOS, deprecated: 16.0)
@available(watchOS, deprecated: 9.0)
private extension SwiftUI.Toggle where Label == SwiftUI.Text {
init<C>(_ titleKey: LocalizedStringKey, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where C : RandomAccessCollection {
@krzyzanowskim
krzyzanowskim / swiftformat-github-action.yml
Last active September 27, 2022 19:17
Check if PR is missing formatting
name: auto-format
on: pull_request
jobs:
format:
# Check if the PR is not from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
@krzyzanowskim
krzyzanowskim / PastelColor.swift
Last active February 10, 2024 10:27
Random pastel colors
struct ContentView: View {
@State var color: Color = .Pastel.random()
var body: some View {
Rectangle()
.foregroundColor(color)
.onTapGesture {
color = .Pastel.random()
}
}
// Usage
@MainActor
final class AppSettings: ObservableObject {
static let standard = AppSettings()
@Published(preferenceKey: AppSettingsKey.editorHighlightSelectedLine)
var editorHighlightSelectedLine: Bool = true
}