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
import SwiftUI | |
struct EnumPicker<Enum>: View where Enum: CaseIterable & Hashable, Enum.AllCases: RandomAccessCollection { | |
typealias Element = Enum.AllCases.Element | |
private var enumType: Enum.Type | |
@Binding private var selection: Element | |
init(_ enumType: Enum.Type, selection: Binding<Element>) { | |
self.enumType = enumType |
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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
OpacityIcons(content: OpacityIcon1.init) | |
OpacityIcons(content: OpacityIcon2.init) | |
} | |
.padding() | |
} |
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
import SwiftUI | |
import Algorithms | |
struct ContentView: View { | |
@State var angle: Double = 0 | |
var body: some View { | |
TimelineView(.animation()) { time in | |
Waraiotoko(angle: angle) | |
.onChange(of: time.date) { _, _ in |
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
# ----------------------------------------------------------------------------- | |
# SwiftGen によるローカライズを剥がすスクリプト。 | |
# ----------------------------------------------------------------------------- | |
class String | |
# シンボル変換 | |
def symbol | |
# e.g. | |
# - OK → Ok | |
# - FAQ → Faq |
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
// ==UserScript== | |
// @name Golden Apple | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description When source code is copied and pasted from Apple documentation, unnecessary line breaks should no longer be inserted. | |
// @author @tobi462 | |
// @match https://developer.apple.com/documentation/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net | |
// @grant none | |
// ==/UserScript== |
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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
NavigationView { | |
PureList { | |
Text("Apple") | |
.border(.red) | |
Color.clear |
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
import SwiftUI | |
struct ContentView: View { | |
@State private var selectedTab: Tab = .first | |
var body: some View { | |
TabContainer(selection: $selectedTab) { tabTappedTwices in | |
ForEach(Tab.allCases) { tab in | |
SampleView( | |
title: tab.title, |
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
extension Binding { | |
func willSet(_ handler: @escaping (Value) -> ()) -> Binding<Value> { | |
.init( | |
get: { wrappedValue }, | |
set: { newValue in | |
handler(newValue) | |
wrappedValue = newValue | |
} | |
) | |
} |
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
import SwiftUI | |
import Algorithms | |
struct ForEachIndex<Data: RandomAccessCollection, ID: Hashable, Content: View>: View { | |
typealias Element = IndexedCollection<Data>.Element | |
private var data: Data | |
private var id: KeyPath<Element, ID> | |
@ViewBuilder private var content: (Element) -> Content |
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
struct ContentView: View { | |
var body: some View { | |
VStack(spacing: 50) { | |
// minWidth / minHeight | |
Color.blue.opacity(0.3) | |
.frame(minWidth: 100, minHeight: 200) | |
.frame(width: 150, height: 150) | |
.border(.black) | |
.overlay { |
NewerOlder