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 Example12: View { | |
| @State private var flag = false | |
| var body: some View { | |
| VStack { | |
| Spacer() | |
| Color.clear.overlay(WaveText("The SwiftUI Lab", waveWidth: 6, pct: flag ? 1.0 : 0.0).foregroundColor(.blue)).frame(height: 40) | |
| Color.clear.overlay(WaveText("swiftui-lab.com", waveWidth: 6, pct: flag ? 0.0 : 1.0, size: 18).foregroundColor(.green)).frame(height: 30) | |
| Spacer() | |
| }.onAppear { |
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
| ForEach(viewModel.repos) { repo in | |
| RepositoryRow(repo: repo) | |
| .onAppear( | |
| ofViewRelatedTo: repo, | |
| from: viewModel.repos, | |
| inSuffixOfLength: 10, | |
| perform: viewModel.fetchNextPageIfPossible | |
| ) | |
| } |
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
| final class ComposedViewController: UIViewController { | |
| ... | |
| private let specialization: Specialization | |
| init(specialization: Specialization) { | |
| self.specialization = specialization | |
| } | |
| ... |
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
| extension ViewController { | |
| final class Builder { | |
| static func buildView(somethingTextField: UITextField, printButton: UIButton) -> UIView { | |
| let view = UIView().forAutoLayout() | |
| view.backgroundColor = .white | |
| let stackView = buildRootStackView(somethingTextField: somethingTextField, printButton: printButton) | |
| view.addSubview(stackView) | |
| stackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20.0).isActive = true |
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
| public final class LogInViewController: UIViewController { | |
| private let emailTextField: UITextField = Builder.buildEmailTextField() | |
| private let passwordTextField: UITextField = Builder.buildPasswordTextField() | |
| public override func loadView() { | |
| let logInButton: UIButton = Builder.buildLogInButton( | |
| target: self, | |
| action: #selector(didTapLogInButton) | |
| ) | |
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
| let peopleTableViewDataSource: UITableViewDataSource = HomogeneousTableViewDataSource<PersonCell, PersonCellState> { | |
| let person = people[$0.row] | |
| return PersonCellState(name: person.name, surname: person.surname) | |
| } |
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
| class HomogeneousTableViewDataSource<Cell, CellState>: NSObject, UITableViewDataSource where | |
| Cell: UITableViewCell & Identifiable & PreparableWithState, | |
| CellState == Cell.State { | |
| typealias ProvideCellStateAtIndexPath = (IndexPath) -> CellState | |
| let provideCellStateAtIndexPath: ProvideCellStateAtIndexPath | |
| init(withCellStateAtIndexPathProvider provideCellStateAtIndexPath: @escaping ProvideCellStateAtIndexPath) { | |
| self.provideCellStateAtIndexPath = provideCellStateAtIndexPath | |
| } |
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 PersonCellState { | |
| let name: String | |
| let surname: String | |
| } | |
| extension PersonCell: PreparableWithState { | |
| func prepare(with state: PersonCellState) { | |
| textLabel?.text = state.name | |
| detailTextLabel?.text = state.surname | |
| } |
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
| protocol PreparableWithState { | |
| associatedtype State | |
| func prepare(with state: State) | |
| } |
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
| protocol Identifiable { | |
| static var identifier: String { get } | |
| } |