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
let tableViewDataSource = users | |
.filter { $0.age > 21 && $0.name != "Simon" && $0.phone.contains("iPhone") } | |
.map { ViewModel(cellTitle: $0.name, cellSubtitle: $0.phone) } |
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
class RingEditViewModel: ObservableObject { | |
@NestedObservableObject var ring: RingData | |
private let isEditing: Bool | |
private let temporaryContext: NSManagedObjectContext | |
init(context: NSManagedObjectContext, ring: RingData? = nil) { | |
self.temporaryContext = context.child() | |
if let ring = temporaryContext.copy(of: ring) { |
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
// | |
// Combine+Extensions.swift | |
// Common | |
// | |
// Created by Michael Long on 8/27/22. | |
// | |
import Foundation | |
import Combine |
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 ToDo: Codable, Identifiable { | |
let id: Int | |
let userId: Int | |
var title: String | |
var completed: Bool | |
} | |
class SelectionManager<Item: Identifiable>: ObservableObject { | |
@Published var status: [Item.ID:Bool] = [:] | |
func isSelected(_ item: Item) -> Bool { |
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 ToDoStore: Codable { | |
let userId: Int | |
let id: Int | |
var title: String | |
var completed: Bool | |
} | |
struct ToDo { | |
private var toDo: ToDoStore |
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 NameValueView: ViewBuilder { | |
let name: String? | |
let value: String? | |
var body: View { | |
HStackView { | |
LabelView(name) | |
.color(.secondaryLabel) | |
SpacerView() |
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 LabeledPhotoView: ViewBuilder { | |
let photo: Observable<UIImage?> | |
let name: String | |
var body: View { | |
ZStackView { | |
ImageView(photo) | |
.contentMode(.scaleAspectFill) | |
.clipsToBounds(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
struct DetailCardView: ViewBuilder { | |
@Injected var viewModel: DetailViewModel | |
init(user: User) { | |
viewModel.configure(user) | |
} | |
var body: View { | |
StandardCardView { |
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 Colors { | |
let primary: Color | |
} | |
struct Fonts { | |
let body: Font | |
} | |
class Theme: ObservableObject { | |
let color: Colors |
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 LoadingView: View { | |
@StateObject var viewModel = ViewModel() | |
var body: some View { | |
switch viewModel.state { | |
case .initial, .loading: | |
ProgressView() | |
.onAppear(perform: viewModel.load) | |
case .empty(let message): |