带有两个视图控制器的选项卡栏,一个用于列出用户,另一个用于使用 TableView 列出动物

关于本项目

范围

该项目包含一个带有两个视图控制器的选项卡栏,一个用于列出用户,另一个用于列出使用TableView的动物。项目从两个远程 API 获取用户和动物的列表。下拉刷新可用于更新列表。如果某个项目在任何列表中被点击,则分别显示详细信息屏幕。

What’s interesting?

Interesting part in this project is it’s Ploymorphic and reuseable code to illustrate separation of concerns and reuseability.

How ?

If you review the code you’ll find only single being used to show Users and Animals data without any boolean or if/else condition to know which list is currently showing, which object’s data to render in cell, which API to call on Pull to referesh and which ViewController to navigate by cell tap. All the logic and dependencies being injected from out side at the time of composition so it is fully independent and can be reused with any ViewController to show list with same kind of cell.UITableViewController

Other noticeable thing is the data layer where data being consumed in Ploymorphic way and doen’t know from where it is loading the data, data can be loaded from the remote source or from the local source without changing the code in ViewModel as ViewModel is also independent from specific context. This approach makes the code more maintainable and extendable.ListViewModel

GitHub

点击跳转