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 ShadowBorderModifier: ViewModifier { | |
func body(content: Content) -> some View { | |
content | |
.border(Color.black, width: 1) | |
.shadow(radius: 5) | |
} | |
} | |
extension View { | |
func dropShadow() -> some View { |
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 CustomView<Content: View>: View { | |
let content: () -> Content | |
init(@ViewBuilder content: @escaping () -> Content) { | |
self.content = content | |
} | |
var body: some View { | |
content() | |
} |
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 WrapperView<Content: View>: View { | |
let content: () -> Content | |
init(@ViewBuilder content: @escaping () -> Content) { | |
self.content = content | |
} | |
var body: some View { | |
VStack(alignment: .center) { | |
content() |
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 HeaderView: View { | |
let title: String | |
let subtitle: String | |
@ViewBuilder | |
var body: some View { | |
VStack(alignment: .leading) { | |
Text(title) | |
.font(.largeTitle) |
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 VStack<Content: View>: View { | |
let content: () -> Content | |
init(@ViewBuilder content: @escaping () -> Content) { | |
self.content = content | |
} | |
var body: some View { | |
// Create and arrange the subviews in a vertical stack. | |
content() |
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 MyViewTests: XCTestCase { | |
func testMyView() throws { | |
let dataFetcher = MockDataFetcher() | |
let viewModel = MyViewModel(dataFetcher: dataFetcher) | |
let view = MyView(viewModel: viewModel) | |
let window = UIWindow() | |
window.rootViewController = UIHostingController(rootView: view) | |
window.makeKeyAndVisible() |
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 MyViewModelTests: XCTestCase { | |
func testFetchData() { | |
let dataFetcher = MockDataFetcher() | |
let viewModel = MyViewModel(dataFetcher: dataFetcher) | |
let expectation = XCTestExpectation(description: "Fetch data") | |
dataFetcher.fetchDataResult = "test data" | |
viewModel.fetchData() | |
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
let expectedOutput = "Hello, World!" | |
let publisher = SomePublisher<String, Error>() | |
let cancellable = publisher | |
.sink(receiveCompletion: { completion in | |
switch completion { | |
case .finished: | |
break | |
case .failure(let error): | |
XCTFail("Publisher failed with error: \(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 Foundation | |
import SwiftUI | |
import Combine | |
import Resolver | |
// MARK: - Presentation Layer | |
struct MyView: View { | |
@ObservedObject 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
import Foundation | |
import SwiftUI | |
import Combine | |
// MARK: - Presentation Layer | |
struct MyView: View { | |
@ObservedObject var viewModel: MyViewModel | |
var body: some View { |
NewerOlder