Skip to content

Commit

Permalink
Add previews for all the view controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkulman committed Feb 7, 2024
1 parent d2d9cf2 commit 34b7cf3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,12 @@ final class AboutViewController: UITableViewController {
return headerView
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct AboutViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: AboutViewController(viewModel: AboutViewModel())).asPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ final class LibrariesViewController: UITableViewController {
}.disposed(by: disposeBag)
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct LibrariesViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: LibrariesViewController(viewModel: LibrariesViewModel())).asPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,12 @@ final class DetailViewController: UIViewController {
}
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct DetailViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: DetailViewController(item: RssItem(title: "New post", description: "Some description", link: "http://www.github.com/igorkulman/iOSSampleApp", pubDate: Date()))).asPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,25 @@ final class FeedViewController: UIViewController, ToastCapable {
.disposed(by: disposeBag)
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
final class PreviewDataService: DataService {
func getFeed(source: RssSource, onCompletion: @escaping (RssResult) -> Void) {
onCompletion(.success([
RssItem(title: "Post 1", description: "Description", link: "", pubDate: Date()),
RssItem(title: "Post 2", description: "Description", link: "", pubDate: Date()),
RssItem(title: "Post 3", description: "Description", link: "", pubDate: Date())
]))
}
}
final class PreviewSettingsService: SettingsService {
var selectedSource: RssSource? = RssSource(title: "Website", url: "", rss: "", icon: "")
}

struct FeedViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: FeedViewController(viewModel: FeedViewModel(dataService: PreviewDataService(), settingsService: PreviewSettingsService()))).asPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,12 @@ final class CustomSourceViewController: UIViewController {
doneButton.rx.tap.withLatestFrom(viewModel.source.flatMap(ignoreNil)).withUnretained(self).bind { owner, source in owner.delegate?.userDidAddCustomSource(source: source) }.disposed(by: disposeBag)
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct CustomSourceViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: CustomSourceViewController(viewModel: CustomSourceViewModel())).asPreview()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,12 @@ final class SourceSelectionViewController: UIViewController {
.disposed(by: disposeBag)
}
}

#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct SourceSelectionViewControllerPreview: PreviewProvider {
static var previews: some View {
UINavigationController(rootViewController: SourceSelectionViewController(viewModel: SourceSelectionViewModel(settingsService: UserDefaultsSettingsService()))).asPreview()
}
}
#endif

0 comments on commit 34b7cf3

Please sign in to comment.