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 OSLog | |
struct LogScreen: View { | |
enum SearchScope: Hashable { | |
case all | |
case category(LogCategory) | |
} | |
@State private var allLogEntries: [LogEntry] = [] |
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 CoreData | |
import Combine | |
import Foundation | |
import Observation | |
@Observable | |
@MainActor | |
public final class CloudSyncState { | |
public enum SyncStatus { | |
case notStarted |
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 UIKit | |
struct Todo: Identifiable { | |
var id: UUID | |
var title: String | |
var done: Bool | |
} | |
final class TodoRepository { | |
private var todos: [Todo] = (1...30).map { i 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
// | |
// Topic006.swift | |
// SwiftUIWeeklyLayoutChallenge | |
// | |
// Created by treastrain on 2022/08/17. | |
// | |
import SwiftUI | |
fileprivate func +(left: CGSize, right: CGSize) -> CGSize { | |
.init(width: left.width + right.width, height: left.height + right.height) |
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 UIKit | |
import Combine | |
enum MessageViewControllerFactory { | |
static func createDefaultImplementation() -> MessageViewController<MessageRepository<APIClient>> { | |
return MessageViewController(viewState: MessageViewState()) | |
} | |
} | |
final class MessageViewController<Repository: MessageRepositoryProtocol>: UIViewController { |
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 | |
class Particle { | |
var position: CGPoint | |
var velocity: CGPoint | |
var color: Color | |
var size: CGFloat | |
init(position: CGPoint, velocity: CGPoint, color: Color, size: CGFloat) { | |
self.position = position |
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 | |
extension CGPoint { | |
func distance(to other: CGPoint) -> CGFloat { | |
let dx = self.x - other.x | |
let dy = self.y - other.y | |
return sqrt(dx * dx + dy * dy) | |
} | |
} |
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 isImageViewerPresented: Bool = false | |
var body: some View { | |
VStack { | |
Button(action: { | |
withAnimation { | |
isImageViewerPresented = true |
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 WidgetKit | |
import SwiftUI | |
struct RandomNumberWidgetProvider: IntentTimelineProvider { | |
func placeholder(in context: Context) -> RandomNumberWidgetEntry { | |
RandomNumberWidgetEntry(date: Date(), number: 42) | |
} | |
func getSnapshot(for configuration: RandomNumberIntent, in context: Context, completion: @escaping (RandomNumberWidgetEntry) -> ()) { | |
let entry = RandomNumberWidgetEntry(date: Date(), number: getRandomNumber(configuration: configuration)) |
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 WidgetKit | |
import SwiftUI | |
struct RandomNumberWidgetProvider: TimelineProvider { | |
func placeholder(in context: Context) -> RandomNumberWidgetEntry { | |
RandomNumberWidgetEntry(date: Date(), number: 42) | |
} | |
func getSnapshot(in context: Context, completion: @escaping (RandomNumberWidgetEntry) -> ()) { | |
let entry = RandomNumberWidgetEntry(date: Date(), number: getRandomNumber()) |
NewerOlder