-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New version update alert, Enhanced light mode UI, Improved search
- Loading branch information
1 parent
41dc853
commit 6a0ee13
Showing
10 changed files
with
196 additions
and
54 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
50 changes: 50 additions & 0 deletions
50
COVIDtracker/Assets.xcassets/cellBgColor.colorset/Contents.json
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,50 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal", | ||
"color" : { | ||
"color-space" : "gray-gamma-22", | ||
"components" : { | ||
"white" : "0.333", | ||
"alpha" : "1.000" | ||
} | ||
} | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "light" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "gray-gamma-22", | ||
"components" : { | ||
"white" : "0.850", | ||
"alpha" : "1.000" | ||
} | ||
} | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "gray-gamma-22", | ||
"components" : { | ||
"white" : "0.333", | ||
"alpha" : "1.000" | ||
} | ||
} | ||
} | ||
] | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,69 @@ | ||
// | ||
// VersionUpdate.swift | ||
// COVIDtracker | ||
// | ||
// Created by Prakhar Prakash Bhardwaj on 02/05/20. | ||
// Copyright © 2020 Prakhar Prakash Bhardwaj. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
struct UpdateResult: Codable { | ||
let status: Bool | ||
let message: String | ||
let url: String | ||
} | ||
|
||
class VersionUpdate: UITableViewController { | ||
|
||
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "" | ||
|
||
func generateAPISession() { | ||
getVersionApi { (res) in | ||
switch res { | ||
case .success(let jsonResult): | ||
DispatchQueue.main.async { | ||
let data = jsonResult as! UpdateResult | ||
|
||
if(!data.status){ | ||
let ac = UIAlertController(title: "New Version Available", message: data.message, preferredStyle: .alert) | ||
ac.addAction(UIAlertAction(title: "No, Thanks", style: .default, handler: nil)) | ||
ac.addAction(UIAlertAction(title: "Update Now", style: .default) { (_) in | ||
let urlStr = data.url | ||
|
||
UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil) | ||
}) | ||
self.present(ac, animated: true, completion: nil) | ||
}else{ | ||
print("Latest app version") | ||
} | ||
} | ||
case .failure(let err): | ||
print("err:", err.localizedDescription) | ||
} | ||
} | ||
} | ||
|
||
func getVersionApi(completion: @escaping (Result<Any, Error>) -> Void) { | ||
|
||
let urlString = "https://prakhar-covid19-api.herokuapp.com/covid19/ios/update?version=\(appVersion)" | ||
let urlPath = URL(string: urlString)! | ||
let urlRequest = URLRequest(url: urlPath) | ||
|
||
let task = URLSession.shared.dataTask(with: urlRequest) { (data, _, err) in | ||
if let err = err { | ||
completion(.failure(err)) | ||
return | ||
} | ||
guard let data = data else { return } | ||
do { | ||
let result = try JSONDecoder().decode(UpdateResult.self, from: data) | ||
completion(.success(result)) | ||
} catch let jsonError { | ||
completion(.failure(jsonError)) | ||
} } | ||
task.resume() | ||
} | ||
} | ||
|
Oops, something went wrong.