This file contains hidden or 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 ContentView2: View { | |
var model = Model() | |
var body: some View { | |
NavigationStack { | |
List { | |
ForEach(model.items.sorted(using: KeyPathComparator(\.createdDate, order: .reverse))) { item in | |
Cell(item: item) | |
} | |
} |
This file contains hidden or 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 Item: Identifiable { | |
var id: UUID = UUID() | |
var value: Int | |
var createdDate: Date | |
} | |
@Observable | |
class Model { | |
var items: [Item] = (0..<100).map { Item(value: $0, createdDate: .now.addingTimeInterval(Double($0 * 60 * 60 * 24))) } | |
var itemVisibility: [Item.ID: Bool] = [:] |
This file contains hidden or 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
@attached(member, names: named(RawValue), named(rawValue), named(`init`), arbitrary) | |
@attached(extension, conformances: OptionSet) | |
public macro OptionSet<RawType>() = #externalMacro(module: "SwiftMacros", type: "OptionSetMacro") | |
@OptionSet<UInt8> | |
struct Parameters { | |
enum Options: UInt8 { | |
case p0 = 0 | |
case p7 = 7 |
This file contains hidden or 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
// https://x.com/usagimaruma/status/1460083928358789123 | |
struct ContenteView: View { | |
var text = "プレゼンテーション" | |
var body: some View { | |
VStack { | |
Rectangle() | |
.fill(Color(.secondarySystemGroupedBackground)) | |
.frame(width: 300, height: 100) |
This file contains hidden or 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 { | |
let urls: [URL] = [ | |
.init(string: "https://webcg.ismcdn.jp/mwimgs/0/f/640wm/img_0f0ccf94fbdcfab41992550a42460808110746.jpg")!, | |
.init(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg/640px-Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg")!, | |
] | |
var body: some View { | |
ScrollView { | |
LazyVStack(spacing: 40) { | |
ForEach(urls, id: \.self) { url in |
This file contains hidden or 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
// 1. Add Person | |
// 2. Add Car | |
// 3. Delete Person(or Car) | |
import SwiftUI | |
import SwiftData | |
@main | |
struct Xcode17_SampleApp: App { | |
var body: some Scene { |
This file contains hidden or 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
// Previewだと動くがシミュレーターだと動かない | |
// 原因? Environment(\.openURL), NavigationLink | |
struct ContentView: View { | |
let urls: [URL] = [ | |
URL(string: "https://github.com")!, | |
URL(string: "https://github.com")!, | |
URL(string: "https://github.com")!, | |
] | |
This file contains hidden or 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 { | |
@State var text = "" | |
var body: some View { | |
NavigationStack { | |
List { | |
TextField("Text", text: $text) | |
} | |
//.padding(.top, 10) | |
.toolbarBackground(.visible, for: .navigationBar) |
NewerOlder