Browse Source

Naming refactor

Arbnor Tefiki 3 years ago
parent
commit
4153a67523

+ 1 - 1
LiveLikeGiphyChallenge/APIManager.swift

@@ -11,7 +11,7 @@ class APIManager {
   private static let giphyApiKey = "krF6wnSax3bZYT1kAAEfLeB1UwN7ZsJM"
   typealias GiphyResponse = (_ response: GiphyModel?) -> Void
 
-  static func fetchTrendingGifs(request: GiphyRequest, completion: @escaping GiphyResponse) {
+  static func fetchGifs(request: GiphyRequest, completion: @escaping GiphyResponse) {
     var request = URLRequest(url: urlBuilder(request: request))
     request.httpMethod = "GET"
     URLSession.shared.dataTask(with: request) { (data, response, error) in

+ 1 - 1
LiveLikeGiphyChallenge/GiphyModel.swift

@@ -25,7 +25,7 @@ struct Gif: Decodable {
     case gifSources = "images"
   }
 
-  func getGifURL() -> String{
+  func getGifURL() -> String {
     return gifSources.fixedHeight.url
   }
 }

+ 2 - 2
LiveLikeGiphyChallenge/GiphyRequest.swift

@@ -15,12 +15,12 @@ struct GiphyRequest {
 
   let limit: Int = 20
   var searchTerm: String
-  var requestType: FetchType
+  var fetchType: FetchType
   var page: Int
   var offset: Int {
     return page * limit
   }
   var urlPath: String {
-    return requestType.rawValue
+    return fetchType.rawValue
   }
 }

+ 2 - 2
LiveLikeGiphyChallenge/GiphyViewModel.swift

@@ -29,8 +29,8 @@ class GiphyViewModel {
 
   func fetchGiphyImages(resetSearch: Bool = false) {
     isLoadingList = true
-    let request = GiphyRequest(searchTerm: searchTerm, requestType: fetchType, page: page)
-    APIManager.fetchTrendingGifs(request: request) { response in
+    let request = GiphyRequest(searchTerm: searchTerm, fetchType: fetchType, page: page)
+    APIManager.fetchGifs(request: request) { response in
       self.isLoadingList = false
       guard let response = response, response.meta?.msg == "OK" else {
         return

+ 1 - 1
LiveLikeGiphyChallenge/MainViewController.swift

@@ -24,6 +24,7 @@ class MainViewController: UIViewController {
     searchBar.searchTextField.placeholder = "Search the gifs you love from Giphy"
     searchBar.returnKeyType = .search
     searchBar.translatesAutoresizingMaskIntoConstraints = false
+    searchBar.heightAnchor.constraint(equalToConstant: 50).isActive = true
     return searchBar
   }()
 
@@ -67,7 +68,6 @@ class MainViewController: UIViewController {
 
   func setupSearchBar() {
     searchBar.delegate = self
-    searchBar.heightAnchor.constraint(equalToConstant: 50).isActive = true
   }
 
   func setupViewModel() {