一个简单的应用程序,使用 Unsplash API 按键搜索照片

未飞溅应用程序

测试应用一个简单的应用程序,使用 Unsplash API 按关键字搜索照片。 在第一个标签栏VC – 搜索屏幕显示随机获取的图像。 在第二个标签栏VC - 收藏夹屏幕显示喜欢并保存在UserDefaults图像中

功能性

视图控制器

照片集视图控制器

The search screen at the beginning displayed random fetched images.

PhotosCollectionView

  • During scrolling, if scrolled down to the last element of collectionView, asynchronously start loading more images
  • Custom “waterFall” layout
  • Custom apearing alpha animation

SearchController

  • When text in searchBar begin changing the searchBar, requests are made to search for images by keyword
  • Since the API has a limit of 50 requests per hour, created Timer to avoid or minimize unnecessary requests, while user printing

FavoritesCollectionViewController

  • The favorites screen displayed liked and saved in UserDefaults images
  • Custom apearing alpha animation

DetailViewController

Appears after touching on selected cell. Present a large image and detailed information of this image in custom Bottom Sheet

InfoView

Represents detail info of Image \

Contains info:

  • Author name
  • Description
  • Location
  • Downloads number
  • Creation date

Buttons:

  • Like button -> save / remove from Favorites List
  • Action button -> UIActivityViewController()
  • Original size -> PhotoViewController()

PhotoViewController

Used to display the best quality image in the correct aspect ratio. Also here is saveBarButtonItem

Services

1. Network

1.1 NetworkService

       Serves to configuring URLS with parameters and REQUESTS for Unsplash API

1.2 NetworkManager

       Contains methods to decode JSON and fetching data

2. StorageManager

    Serves to work with UserDefaults for saving, fetching, remove favorites photo

3. AppUtility

    Serves to lock orientation and prevent screen rotation

Demonstration

Practice with: Unsplash API UserDefaults UrlSession SDWebImage

GitHub

点击跳转