From 9222c050042378d4367953e47107793eb6facecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=CC=82=20X?= Date: Thu, 28 Jan 2021 05:29:00 -0300 Subject: [PATCH] Adjust news detail news presentation to a webview --- NewsApp/Scenes/Base.lproj/Main.storyboard | 65 ++++++++++++------- .../NewsDetailTableViewController.swift | 13 ++-- NewsApp/Scenes/Login/LoginViewModel.swift | 3 +- NewsAppTests/NewsAppTests.swift | 12 ++-- Podfile | 4 +- README.md | 18 ++++- 6 files changed, 75 insertions(+), 40 deletions(-) diff --git a/NewsApp/Scenes/Base.lproj/Main.storyboard b/NewsApp/Scenes/Base.lproj/Main.storyboard index 18e7065..1f3a476 100644 --- a/NewsApp/Scenes/Base.lproj/Main.storyboard +++ b/NewsApp/Scenes/Base.lproj/Main.storyboard @@ -418,46 +418,61 @@ - - + + - - + + - - - + + - - - - + + + + - - + + - + - - - - + + + + + + + + - - - - + + + + @@ -476,10 +491,10 @@ - + - + diff --git a/NewsApp/Scenes/Logged Area/News Detail/NewsDetailTableViewController.swift b/NewsApp/Scenes/Logged Area/News Detail/NewsDetailTableViewController.swift index a8930c3..54758d0 100644 --- a/NewsApp/Scenes/Logged Area/News Detail/NewsDetailTableViewController.swift +++ b/NewsApp/Scenes/Logged Area/News Detail/NewsDetailTableViewController.swift @@ -10,6 +10,7 @@ import RxSwift import RxCocoa import markymark import SkeletonView +import WebKit class NewsDetailTableViewController: UITableViewController, ViewModelBased { @IBOutlet weak var imageBig: UIImageView! @@ -18,8 +19,8 @@ class NewsDetailTableViewController: UITableViewController, ViewModelBased { @IBOutlet weak var authorText: UILabel! @IBOutlet weak var originText: UILabel! @IBOutlet weak var dateTimeNews: UILabel! - @IBOutlet weak var imageSubtitleMarkdown: MarkDownTextView! - @IBOutlet weak var bodyMarkdown: MarkDownTextView! + @IBOutlet weak var linhaFina: UILabel! + @IBOutlet weak var bodyWeb: WKWebView! var viewModel: NewsDetailViewModel! @@ -76,8 +77,8 @@ class NewsDetailTableViewController: UITableViewController, ViewModelBased { self.authorText.text = document.creditoFormatted self.originText.text = document.source self.dateTimeNews.text = document.dataFormatted - self.imageSubtitleMarkdown.text = document.legendaImagem - self.bodyMarkdown.text = document.corpoformatado + self.linhaFina.text = document.linhafina + self.bodyWeb.loadHTMLString(document.corpoformatado ?? "", baseURL: nil) } @@ -88,7 +89,7 @@ class NewsDetailTableViewController: UITableViewController, ViewModelBased { self.authorText.showAnimatedGradientSkeleton() self.originText.showAnimatedGradientSkeleton() self.dateTimeNews.showAnimatedGradientSkeleton() - self.imageSubtitleMarkdown.showAnimatedGradientSkeleton() + self.linhaFina.showAnimatedGradientSkeleton() } @@ -99,6 +100,6 @@ class NewsDetailTableViewController: UITableViewController, ViewModelBased { self.authorText.hideSkeleton() self.originText.hideSkeleton() self.dateTimeNews.hideSkeleton() - self.imageSubtitleMarkdown.hideSkeleton() + self.linhaFina.hideSkeleton() } } diff --git a/NewsApp/Scenes/Login/LoginViewModel.swift b/NewsApp/Scenes/Login/LoginViewModel.swift index 94fd5b0..4dee4a0 100644 --- a/NewsApp/Scenes/Login/LoginViewModel.swift +++ b/NewsApp/Scenes/Login/LoginViewModel.swift @@ -90,8 +90,7 @@ class LoginViewModel: ViewModel { .filter { $0 } .withLatestFrom(input.username) .withLatestFrom(input.password, resultSelector: { (username, password) -> UserLogin in -// UserLogin(username: username, password: password) - UserLogin(username: "devmobile", password: "uC&+}H4wg?rYbF:") + UserLogin(username: username, password: password) }) .subscribe(onNext: { (user) in self.isLoading.onNext(true) diff --git a/NewsAppTests/NewsAppTests.swift b/NewsAppTests/NewsAppTests.swift index f0d9d5b..f20bd3d 100644 --- a/NewsAppTests/NewsAppTests.swift +++ b/NewsAppTests/NewsAppTests.swift @@ -6,12 +6,17 @@ // import XCTest +import RxSwift @testable import NewsApp class NewsAppTests: XCTestCase { - + let disposeBag = DisposeBag() + var viewmodel: LoginViewModel? + var loginInputs: LoginInputs? + override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. + viewmodel = LoginViewModel(NewsService(stub: true), disposeBag: disposeBag) +// loginInputs = LoginInputs(username: , password: , tapExecuteLogin: ) } override func tearDownWithError() throws { @@ -19,8 +24,7 @@ class NewsAppTests: XCTestCase { } func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. +// viewmodel?.setUp(with: LoginInputs) } func testPerformanceExample() throws { diff --git a/Podfile b/Podfile index 82138f2..8fcda85 100644 --- a/Podfile +++ b/Podfile @@ -12,11 +12,11 @@ target 'NewsApp' do pod 'Moya/RxSwift', '~> 14.0' pod 'ProgressHUD', '~> 13.4' pod 'SkeletonView', '~> 1.11.0' - pod "markymark", '~> 10.1.1' target 'NewsAppTests' do inherit! :search_paths - # Pods for testing + pod 'RxTest', '5.0.1' + pod 'RxBlocking', '5.0.1' end target 'NewsAppUITests' do diff --git a/README.md b/README.md index 675b5dd..f95c790 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # NewsApp -RxSwift app +iOS 14 Swift News. + +A simple News App that shows the a few articles and its detail. The app was created using RxSwift in the MVVM architecture. + +## Compatibility +This project is written in Swift 5 and requires Xcode 12.3+ & Cocoapods 1.9.3 to build and run. + +## Getting Started +Navigate to the directory and run pod install. Then open NewsApp.xcworkspace to run the project: +```sh +cd NewsApp +pod install +open . +``` + +## Contact Info +renefx@gmail.com