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
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
struct A11yModifier: ViewModifier { | |
///A label that is visible to UI tests AND VoiceOver | |
let label: String? | |
///An identifier that is visible to UI tests NOT VoicOver | |
let identifier: String? | |
///The required function that returns our View with the necessary accessibility modifiers | |
func body(content: Content) -> some View { | |
content | |
.conditionalModifier(label != nil) { | |
$0.accessibility(label: Text(label!)) |
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
func simulateAnotherCall(_ param: String?) -> Result<String?, NWError> { | |
return makeAPICall() | |
} | |
func load() { | |
DispatchQueue.global(qos: .utility).async { | |
// make first api call and flatMap second and third api calls | |
let result = self.apiTest() | |
.flatMap { self.simulateAnotherCall($0) } | |
.flatMap { self.simulateAnotherCall($0) } |
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
func load() { | |
DispatchQueue.global(qos: .utility).async { | |
let result = self.makeAPICall() | |
DispatchQueue.main.async { | |
switch result { | |
case let .success(data): | |
print(data) | |
case let .failure(error): | |
print(error) |
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 'package:flutter/material.dart'; | |
import 'package:test_app/models/commodities_model.dart'; | |
class CommodityPicker extends StatelessWidget { | |
CommodityPicker(this.commodityMap, this.selected); | |
final Map<String, Commodity> commodityMap; // VM | |
final String selected; // VM | |
@override | |
Widget build(BuildContext context) { |
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 RxSwiftViewController: UIViewController { | |
@IBOutlet weak var firstNameLabel: UILabel! | |
@IBOutlet weak var lastNameLabel: UILabel! | |
@IBOutlet weak var addressLabel: UILabel! | |
@IBOutlet weak var cityLabel: UILabel! | |
@IBOutlet weak var stateLabel: UILabel! | |
@IBOutlet weak var zipLabel: UILabel! | |
private var viewModel = MyViewModel() |
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 MVVMViewController: UIViewController { | |
@IBOutlet weak var firstNameLabel: UILabel! | |
@IBOutlet weak var lastNameLabel: UILabel! | |
@IBOutlet weak var addressLabel: UILabel! | |
@IBOutlet weak var cityLabel: UILabel! | |
@IBOutlet weak var stateLabel: UILabel! | |
@IBOutlet weak var zipLabel: UILabel! | |
private var viewModel = MyViewModel() |