This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: cyan; icon-glyph: apple-alt; | |
const TITLE = "WWDC22" | |
const PAST_EVENT_TEXT = "Have a great Dub Dub!" | |
const DATE = "2022-06-06T17:00:00Z" | |
const BG_IMG_URL = "https://i.ibb.co/9t9CbxX/wwdc22.png" | |
const LINK = "https://developer.apple.com/wwdc22/" | |
let widget = await createWidget() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This file shows how we can tie all of the above together. | |
*/ | |
import SwiftUI | |
// This view can have any orientation- | |
struct SettingsView: View { | |
@State private var isPortraitOnlyViewPresented = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: brown; icon-glyph: hand-holding-usd; | |
// To use this script, you must create a personal access token on GitHub with the `read:org// scope. | |
// Follow the instructions on the link below to create your personal access token. | |
// | |
// https://github.com/settings/tokens | |
// | |
// Run the script when you ahve created your personal access token. It'll prompt you to enter the token and store it securely in the keychain on the device. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sample code made in response to this tweet: | |
// https://twitter.com/stroughtonsmith/status/1485719749673820163 | |
final class MainView: UIView { | |
private let textView: UITextView = { | |
let this = UITextView() | |
this.translatesAutoresizingMaskIntoConstraints = false | |
this.text = "I'm a text view" | |
this.font = .preferredFont(forTextStyle: .body) | |
this.textColor = .label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: blue; icon-glyph: apple-alt; | |
const TITLE = "" | |
const DATE = "2021-10-18T17:00:00Z" | |
const BG_IMG_URL = "https://i.ibb.co/YQ09XTW/background.png" | |
const TITLE_IMG_URL = "https://i.ibb.co/qYH3Y9w/text.png" | |
const TITLE_IMG_SIZE = new Size(155, 25) | |
const LINK = "https://www.youtube.com/watch?v=exM1uajp--A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ToolbarController, NSObject, NSToolbarDelegate { | |
var isBackButtonEnabled = false { | |
didSet { | |
if isBackButtonEnabled != oldValue { | |
reloadBackItem() | |
} | |
} | |
} | |
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: yellow; icon-glyph: bicycle; | |
let stages = await loadStages() | |
let stage = findStage(stages) | |
if (stage == null) { | |
let widget = createTournamentOverWidget() | |
await widget.presentMedium() | |
} else { | |
let stageDetails = await loadStageDetails(stage.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-green; icon-glyph: tree; | |
const STATION_VIBORG = "49" | |
const STATION_CPH = "48" | |
const IDS = { | |
BIRCH: "7", | |
MUGWORT: "31", | |
ALDER: "1", | |
ELM: "4", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We'll store a UIViewController as an associated object and don't want to store a strong reference to it. | |
private final class WeakBoxedValue<T: AnyObject>: NSObject { | |
private(set) weak var value: T? | |
init(_ value: T?) { | |
self.value = value | |
} | |
} | |
// Use associated objects to a UIViewController that should determine the status bar appearance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I needed a property wrapper that fulfilled the following four requirements: | |
* | |
* 1. Values are stored in UserDefaults. | |
* 2. Properties using the property wrapper can be used with SwiftUI. | |
* 3. The property wrapper exposes a Publisher to be used with Combine. | |
* 4. The publisher is only called when the value is updated and not | |
* when_any_ value stored in UserDefaults is updated. | |
* | |
* First I tried using SwiftUI's builtin @AppStorage property wrapper |