La Cripta is an app created for Nostratech iOS Technical Challenge. The app has two main features:
- Get at least 50 cryptocurrency ticker data and display them in a
UITableViewController
.
- Data retrieved from CryptoCompare Toplists API
- User can refresh the list by pulling from the top.
- Ticker color turns green when the price increases and red for the opposite, or it will turns yellow if no change happens (which is rarely happens).
- Display news related to the currency selected upon tapping a cell from the toplists.
- Data retrieved from News API.
Besides the main features, there are several additional features to make the app even more powerful and easy to use.
- Show live price update from a cryptocurrency. User can swipe a cell from right to show the live update page. Data retrieved from CryptoCompare WebSocket API
- Change the price change duration. User can choose either by day, hour, and the last 24 hours.
- Sort news by the latest, oldest, or in a random order.
- Read the news detail by tapping the news cell.
- Share news to friends or colleagues just by tapping the share button.
La Cripta started small, so it uses MVC as its design pattern.
- Alamofire used for networking, mainly fetching data from APIs.
- Kingfisher used for image downloading and caching.
UIView
:fadeIn()
andfadeOut()
function. Their names are self-explanatory.addSubviews(_ views: UIView...)
is likeaddSubview(_ : UIView)
but can accept multiple views.String
:convertToDateInterval()
converts an en_US_POSIX formatted date string to a string representing the interval between a date and now. (e.g.: "2 hours ago", "5 days ago")Double
:convertToCurrency()
converts aDouble
to accounting currency. (e.g.: $19.45)NSMutableAttributedString
:addLineSpacing(_ spacing: CGFloat)
function. Also a self-explanatory name.
ToplistsTableViewCell
is aUITableViewCell
used inToplistsViewController
andLiveUpdateViewController
. Showing a crypto's name, full name, price, price change, and price change percentage.NewsTableViewCell
is aUITableViewCell
used inNewsViewController
. Showing an article image, title, content, author & source, and share button.
- After loading the
ToplistsViewController
,ToplistsAPI
will fetch data from the API. If it successfully get the data, it will decode the data toLCToplistsDataResponse
, assign thetoplists
let to the view controller's toplists array, and reload the table view. The number of cell returned equals to number of toplists, and each cell filled by a toplist.
- Selecting a cell will present the
NewsViewController
.NewsAPI
query is the crypto's full name, so the news shown will be related to the crypto. Fetching the news data shares the same idea as fetching the toplists data. Dismissing the news page will clear the Kingfisher cache to free up memory.
- Swiping a cell to the left will show the present
LiveUpdateViewController
option (or swiping it all the way to the end left will automatically present it).
- Live update will start automatically after entering the live update page, thanks to the
connectToSocket
,sendSubscription
, andreceiveMessage
methods called inviewDidLoad
. Some internet provider may block your connection to the live update view. If this happens, try using another network or connect to a VPN
LiveUpdateViewController
will refresh its cell contents every time the web socket receives data. Dismissing the view will automatically disconnect web socket connection.