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
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
switch section { | |
case 0: | |
return tableView.dequeueCell(CELLID, for: indexPath) { (_ cell: MyTableViewCell) in | |
cell.configure(viewModel.config((for: indexPath.section)) | |
} | |
case 1: | |
... | |
} | |
} |
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 UITableView { | |
func dequeueCell<Cell:UITableViewCell>(_ id: String, for indexPath: IndexPath, configure: (_ cell: Cell) -> Void) -> UITableViewCell { | |
let cell = dequeueReusableCell(withIdentifier: id, for: indexPath) | |
if let cell = cell as? Cell { | |
configure(cell) | |
} | |
return cell | |
} | |
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): |
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 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 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 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 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 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
// | |
// Combine+Extensions.swift | |
// Common | |
// | |
// Created by Michael Long on 8/27/22. | |
// | |
import Foundation | |
import Combine |