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
#!/bin/bash | |
TARGET_DIR=$1 | |
echo "やるお" | |
for file in $(find "$TARGET_DIR" -name "*.swift"); do | |
# struct User: * { の場合。ただし、View適応は除く | |
sed -i '' -E '/struct [A-Za-z0-9_]+: [^{]*View[^{]*\{/!s/(struct [A-Za-z0-9_]+: [^{]*)\{/\1, Sendable {/g' "$file" | |
sed -i '' -E '/enum [A-Za-z0-9_]+: [^{]*View[^{]*\{/!s/(enum [A-Za-z0-9_]+: [^{]*)\{/\1, Sendable {/g' "$file" |
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 AsyncAction<Content: View>: View { | |
@State var isLoading = false | |
@State var task: @Sendable @MainActor () async -> Void | |
@ViewBuilder let content: (Bool, @escaping () -> Void) -> Content | |
var body: some View { | |
content(isLoading, { | |
if isLoading { |
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
[ | |
{ | |
"word": "Asshole", | |
"kana": "アスホール", | |
"meaning": "いやな奴(Ass=お尻、Hole=穴)", | |
"notice": "「うざい野郎」「ろくでなし」" | |
}, | |
{ | |
"word": "あばずれ", | |
"kana": "あばずれ", |
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 Item: Identifiable { | |
let id = UUID() | |
var text = "" | |
var color: Color = .clear | |
} | |
struct CarouselView: View { | |
var items: [Item] = [ |
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
#!/bin/zsh | |
TARGET_DIR=$1 | |
SCRIPT_DIR="$(cd `dirname $0` && pwd -P)" | |
REPOSITORY_ROOT_DIR="$(cd $SCRIPT_DIR && cd .. && pwd -P)" | |
find "$REPOSITORY_ROOT_DIR/$TARGET_DIR" -name "*.swift" -exec sed -i '' '/var body: some View {/a\ | |
let _ = Self._printChanges() | |
' {} \; |
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 json | |
import os | |
import openai | |
openai.organization = os.environ.get("OPENAI_ORGANIZATION") | |
openai.api_key = os.environ.get("OPENAI_API_KEY") | |
langs = ['fr'] |
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 AVKit | |
struct ContentView: View { | |
@State var soundLabelIsShows = false | |
var body: some View { | |
ZStack(alignment: .center) { | |
Image("kane") | |
.resizable() |
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 Combine | |
struct SearchView: View { | |
@StateObject var observer = SearchTextObserver() | |
var body: some View { | |
VStack { | |
TextField("TextField", text: $observer.searchText) | |
.onChange(of: observer.throttleText) { text in | |
print("Call API with \(text)") |
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 SearchView: View { | |
@State var text: String | |
@FocusState var focused: Bool | |
@Async<[Item]> var async | |
var body: some View { | |
VStack { | |
TextField("Placeholder", text: $text) | |
.focused($focused) | |
.onSubmit { |
NewerOlder