Skip to content

Instantly share code, notes, and snippets.

View scott-lydon's full-sized avatar

Scott scott-lydon

  • High Five
  • Burlingame
View GitHub Profile
// No Model in names
/*
throw an error when a class or struct is added that doesn't
use the word model in the name, and isn't a subclass of a
UIViewController, nor UIView, nor view, uiviewRepresentable,
codable or observer.
*/
import UIKit
@scott-lydon
scott-lydon / PullRequestChecklist.md
Created November 22, 2022 22:49
A checklist for pull requests. It is added to as I get feedback for prs.
  • Its better to use existing functions than to create your own
  • Its better to add functionality to existing types than to create new types.
  • Remove unused code.
  • Give ui tests a timeout, longer for ci
  • following conventions for teams.
@scott-lydon
scott-lydon / FindCellInUITest.swift
Last active November 11, 2022 22:33
It's hard to access elements in tableviews sometimes, even when they are on the screen.
class QRCodeTarotUITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
//
// WeirdIssue.swift
// QRCodeTarot
//
// Created by Scott Lydon on 9/24/22.
//
import SwiftUI
struct WeirdIssue: View {
struct TestText: View {
var body: some View {
HStack(alignment: .firstTextBaseline) {
Text("Hello world")
Spacer()
}
}
}
struct TestText: View {
var body: some View {
VStack(alignment: .leading) {
Text("Hello world")
}
}
}
struct TestText: View {
import UIKit
extension UINavigationController {
// - MARK: Extracted reusable methods so that implementation changes reflect wherever used.
func viewController() {
navigationController.pushViewController(ViewController.instantiate(), animated: false)
}
extension UINavigationController {
// - MARK: Extracted reusable methods so that implementation changes reflect wherever used.
func viewController() {
navigationController.pushViewController(ViewController.instantiate(), animated: false)
}
func buySubscription() {
navigationController.pushViewController(BuyViewController.instantiate(), animated: true)
@IBAction func buyTapped(_ sender: Any) {
coordinator?.buySubscription(payload: "payload here")
}
// -------------------------------
func buySubscription(payload: String) {
let vc = BuyViewController.instantiate()
vc.payload = payload
vc.coordinator = self
extension ViewController {
@IBAction func blueTapped(_ sender: Any) {
navigationController?.pushViewController(BlueViewController.instantiate(), animated: true)
}
}
class BlueViewController: UIViewController {}