In iTerm2, in the menu bar go to Scripts > Manage > New Python Script
Select Basic. Select Long-Running Daemon
Give the script a decent name (I chose auto_dark_mode.py
)
Save and open the script in your editor of choice.
import SwiftUI | |
public struct FormattedTextField<Formatter: TextFieldFormatter>: View { | |
public init(_ title: String, | |
value: Binding<Formatter.Value>, | |
formatter: Formatter) { | |
self.title = title | |
self.value = value | |
self.formatter = formatter | |
} |
// | |
// KeyboardResponder.swift | |
// MoveMAD | |
// | |
// Created by Adolfo Vera Blasco on 19/11/2019. | |
// Copyright © 2019 desappstre {eStudio}. All rights reserved. | |
// | |
import SwiftUI |
// Run any SwiftUI view as a Mac app. | |
import Cocoa | |
import SwiftUI | |
NSApplication.shared.run { | |
VStack { | |
Text("Hello, World") | |
.padding() | |
.background(Capsule().fill(Color.blue)) |
import SwiftUI | |
extension View { | |
/// https://stackoverflow.com/a/61985678/3393964 | |
public func cursor(_ cursor: NSCursor) -> some View { | |
self.onHover { inside in | |
if inside { | |
cursor.push() | |
} else { | |
NSCursor.pop() |
struct Colors { | |
let primary: Color | |
} | |
struct Fonts { | |
let body: Font | |
} | |
class Theme: ObservableObject { | |
let color: Colors |
According to the docs, the non-DI way to associate an view model with an @Composable
is via the viewModel()
function from androidx.lifecycle.viewmodel.compose.viewModel
, like this:
@Composable
fun ProfileScreen(val viewModel: ProfileViewModel = viewModel() {
...
But if your view model requires dependencies, you have to pass a subclass of ViewModelProvider.Factory
that holds the dependency and knows how to construct the view model for you. Like this:
SDKROOT=`/usr/bin/xcrun --show-sdk-path -sdk macosx` | |
as test.s -o test.o | |
ld test.o -lSystem -L $(SDKROOT)/usr/lib -o test |
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
use scripting additions | |
-- # This script formats the currently open and focussed Swift file | |
-- # using SwiftFormat. It does so *without* resetting the editor's | |
-- # undo history. | |
-- # | |
-- # Version 2022-12-30.01 | |
-- # | |
-- # Author: Carlo Zottmann |