Skip to content

Commit

Permalink
Update Github scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
antranapp committed Jan 10, 2022
1 parent ca33612 commit 344d1d9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ final class GithubRepositoryDetailScenario: Scenario {

static var rootViewProvider: RootViewProviding {
let detailView = RepositoryDetailView(repository: .alamofire)
return BasicAppController(rootViewController: UIHostingController(rootView: detailView))
return NavigationAppController(withResetButton: true) { _ in
UIHostingController(rootView: detailView)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class GithubRepositoryListScenario: Scenario {
static var rootViewProvider: RootViewProviding {
let service = GithubService()
let githubView = RepositoryListView(viewModel: RepositoryListViewModel(githubService: service))
return BasicAppController(rootViewController: UIHostingController(rootView: githubView))
return NavigationAppController(withResetButton: true) { _ in
UIHostingController(rootView: githubView)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,71 @@ import Foundation
import Scenarios
import SwiftUI

final class RemoteImageViewScenario: Scenario {
static var name: String = "RemoteImage"
final class RemoteImageViewHappyCaseDefaultSzieScenario: Scenario {
static var name: String = "Happy Case - Default Size"
static var kind: ScenarioKind = .component
static var category: ScenarioCategory? = "RemoteImage"

static var rootViewProvider: RootViewProviding {
NavigationAppController(withResetButton: true) { _ in
UIHostingController(rootView: ContentView())
UIHostingController(rootView: HappyCaseDefaultSizeView())
}
}
}

private struct ContentView: View {

let correctURL = URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/736px-Google_2015_logo.svg.png")!
private struct HappyCaseDefaultSizeView: View {
let correctURL = URL(string: "https://avatars.githubusercontent.com/u/484656?v=4")!
var body: some View {
VStack {
RemoteImageContainer(url: correctURL)
Text("Happy Case - Default size")
}
.navigationTitle("Happy Case - Default Size")
}
}

final class RemoteImageViewHappyCaseCustomSizeScenario: Scenario {
static var name: String = "Happy Case - Custom Size"
static var kind: ScenarioKind = .component
static var category: ScenarioCategory? = "RemoteImage"

static var rootViewProvider: RootViewProviding {
NavigationAppController(withResetButton: true) { _ in
UIHostingController(rootView: HappyCaseCustomSizeView())
}
}
}

let wrongURL = URL(string: "https://something.png")!
private struct HappyCaseCustomSizeView: View {
let correctURL = URL(string: "https://avatars.githubusercontent.com/u/484656?v=4")!
var body: some View {
VStack {
RemoteImageContainer(url: correctURL, width: 200, height: 200)
Text("Happy Case - Size 200 x 200")
}
.navigationTitle("Happy Case - Custom size")
}
}

final class RemoteImageViewErrorCaseCustomSizeScenario: Scenario {
static var name: String = "Error Case"
static var kind: ScenarioKind = .component
static var category: ScenarioCategory? = "RemoteImage"

static var rootViewProvider: RootViewProviding {
NavigationAppController(withResetButton: true) { _ in
UIHostingController(rootView: UnhappyCaseView())
}
}
}

private struct UnhappyCaseView: View {
let wrongURL = URL(string: "https://invalid_url.png")!
var body: some View {
VStack(spacing: 32) {
VStack {
RemoteImageContainer(url: correctURL)
Text("Succeed: Default size")
}

Divider()

VStack {
RemoteImageContainer(url: correctURL, width: 200, height: 200)
Text("Succeed: 200 x 200")
}

Divider()

VStack {
RemoteImageContainer(url: wrongURL)
Text("Failed")
}
VStack {
RemoteImageContainer(url: wrongURL)
Text("Error Case")
}
.navigationTitle("Remote Image View")
.navigationTitle("Error Case")
}
}

0 comments on commit 344d1d9

Please sign in to comment.