Instantly share code, notes, and snippets.
-
Turo
- San Francisco
nickm01
/ swiftui4.navigationstack.testing.swift
Created
July 27, 2022 21:11
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 NavigationFlowTests: XCTestCase { | |
| func test_navigates_whenTapNext() throws { | |
| let sut = FlowVM() | |
| XCTAssertEqual(sut.navigationPath.count, 0) | |
| let screen1VM = sut.makeScreen1VM() | |
| screen1VM.didTapNext() | |
| XCTAssertEqual(sut.navigationPath.count, 1) | |
| } | |
| } |
nickm01
/ swiftui4.navigationstack.vm.swift
Last active
July 27, 2022 21:06
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 FlowVM: ObservableObject { | |
| var subscription = Set<AnyCancellable>() | |
| func makeScreen1VM() -> Screen1PhoneVM { | |
| let vm = Screen1VM(phoneNumber: model.phoneNumber) | |
| vm.didComplete | |
| .sink(receiveValue: didComplete1) | |
| .store(in: &subscription) | |
| return vm |
nickm01
/ swiftui4.navigationstack.swift
Last active
July 27, 2022 20:10
SwiftUI Basic NavigationStack
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 FlowVM: ObservableObject { | |
| @Published var navigationPath = NavigationPath() | |
| func navigateTo2() { | |
| navigationPath.append(2) | |
| } | |
| func navigateTo3() { | |
| navigationPath.append("1") | |
| } |