-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add content title and button to Details view (#60) * Added strings for 'Contents' on details view * Change simulated delay to 1.0 to be more noticable * Clarify presenting VM vs presented VM in comments * Added content list title and button to detail view * Add some breathing room to stackViews * Fix unit test timeout * Add Content model and list display (#63) * Abstract centered label, remove unnecessary button boilerplate, and add spacing view * No longer excluding colors.txt from project in Xcode * Add alternate body text color * Adding content / food enum for testing * Display contents in detail view * Further abstract contents list creation and add unit test * Refactor contents list to be more reactive * Changes per PR review * Remove centeredLabel extension in favor of UILabelStyle additions * Use container stackView instead of spacingView * Add Basic Food Table View (#66) * Add FoodTable class cluster * Populate basic tableView * Add tests for FoodTable * Per Swift4 convention, use AnyObject instead of class for protocol constraints * Per PR review, fix FoodVCFactoryProtocol conformance * Per PR review, rename FoodTable to FoodInfo * Per PR review, streamline DetailVM factory protocol parameter * Per PR review, make cell identifier local var * Per PR review, update foods dependency structure * PR cleanup * Per PR review, cleanup where Food is located
- Loading branch information
Showing
44 changed files
with
561 additions
and
85 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import UIKit | ||
import Presentations | ||
import RxSwift | ||
import Action | ||
import Core | ||
|
||
class FoodInfoViewController: UITableViewController, ViewController { | ||
|
||
let viewModel: FoodInfoViewModel | ||
|
||
let themeProvider: ThemeProvider | ||
|
||
required init(viewModel: FoodInfoViewModel, themeProvider: ThemeProvider) { | ||
self.viewModel = viewModel | ||
self.themeProvider = themeProvider | ||
|
||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
let cellIdentifier = "FoodCell" | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier) | ||
|
||
viewModel.foods | ||
.bind(to: tableView.rx.items(cellIdentifier: cellIdentifier)) { _, food, cell in | ||
cell.textLabel?.text = food.name | ||
} | ||
.disposed(by: disposeBag) | ||
|
||
rx.isAppeared | ||
.bind(to: viewModel.isActive) | ||
.disposed(by: disposeBag) | ||
|
||
themeProvider.bindToStyleable(self) { FoodInfoViewControllerStyle(theme: $0) } | ||
} | ||
|
||
@available(*, unavailable) | ||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { fatalError("\(#function) not implemented.") } | ||
|
||
@available(*, unavailable) | ||
required init?(coder aDecoder: NSCoder) { fatalError("\(#function) not implemented.") } | ||
|
||
private let disposeBag = DisposeBag() | ||
|
||
} | ||
|
||
protocol FoodInfoViewControllerFactoryProtocol { | ||
var themeProvider: ThemeProvider { get } | ||
|
||
func makeFoodInfoViewController(viewModel: FoodInfoViewModel) -> FoodInfoViewController | ||
} | ||
|
||
extension FoodInfoViewControllerFactoryProtocol { | ||
|
||
func makeFoodInfoViewController(viewModel: FoodInfoViewModel) -> FoodInfoViewController { | ||
return FoodInfoViewController(viewModel: viewModel, themeProvider: themeProvider) | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
Application/Source/Food Info/FoodInfoViewControllerStyle.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Themer | ||
import UIKit | ||
import Core | ||
|
||
struct FoodInfoViewControllerStyle: Style { | ||
|
||
let theme: Theme | ||
|
||
init(theme: Theme) { | ||
self.theme = theme | ||
} | ||
|
||
func apply(to styleable: FoodInfoViewController) { | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import RxSwift | ||
import RxCocoa | ||
import RxExtensions | ||
import Presentations | ||
import Action | ||
|
||
class FoodInfoViewModel: ViewModel { | ||
|
||
let isActive = BehaviorRelay(value: false) | ||
let foods: Property<[Food]> | ||
|
||
init(with foods: Property<[Food]>) { | ||
self.foods = foods | ||
foods | ||
.asObservable() | ||
.logValue(.info, .application) { "FOODS: \($0)" } | ||
.subscribe() | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
private let disposeBag = DisposeBag() | ||
|
||
} | ||
|
||
protocol FoodInfoViewModelFactoryProtocol { | ||
var foods: Property<[Food]> { get } | ||
|
||
func makeFoodInfoViewModel() -> FoodInfoViewModel | ||
} | ||
|
||
extension FoodInfoViewModelFactoryProtocol { | ||
|
||
func makeFoodInfoViewModel() -> FoodInfoViewModel { | ||
return FoodInfoViewModel(with: foods) | ||
} | ||
|
||
} |
Oops, something went wrong.