Skip to content

Commit

Permalink
Changes for v1.4
Browse files Browse the repository at this point in the history
New version update alert, Enhanced light mode UI, Improved search
  • Loading branch information
prakharbhardwaj committed May 3, 2020
1 parent 41dc853 commit 6a0ee13
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 54 deletions.
6 changes: 6 additions & 0 deletions COVIDtracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
F5EE0503237EBDAD00CF73F2 /* PetitionTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5EE0502237EBDAD00CF73F2 /* PetitionTableViewController.swift */; };
F5EE0505237EBDC200CF73F2 /* PetitionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5EE0504237EBDC200CF73F2 /* PetitionModel.swift */; };
F5EE0507237EC65C00CF73F2 /* PetitionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5EE0506237EC65C00CF73F2 /* PetitionTableViewCell.swift */; };
F5F3F602245DBC8E00C9FEA4 /* VersionUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5F3F601245DBC8E00C9FEA4 /* VersionUpdate.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -56,6 +57,7 @@
F5EE0502237EBDAD00CF73F2 /* PetitionTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PetitionTableViewController.swift; sourceTree = "<group>"; };
F5EE0504237EBDC200CF73F2 /* PetitionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PetitionModel.swift; sourceTree = "<group>"; };
F5EE0506237EC65C00CF73F2 /* PetitionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PetitionTableViewCell.swift; sourceTree = "<group>"; };
F5F3F601245DBC8E00C9FEA4 /* VersionUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionUpdate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -134,6 +136,7 @@
isa = PBXGroup;
children = (
F5C8F0162458584B000BCDEA /* Extension.swift */,
F5F3F601245DBC8E00C9FEA4 /* VersionUpdate.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -300,6 +303,7 @@
F53B87ED24445B3800330305 /* StateData.swift in Sources */,
F55AB7A42430C488000291D8 /* CountryData.swift in Sources */,
F5EE04F1237EBD0E00CF73F2 /* SceneDelegate.swift in Sources */,
F5F3F602245DBC8E00C9FEA4 /* VersionUpdate.swift in Sources */,
F5EE0503237EBDAD00CF73F2 /* PetitionTableViewController.swift in Sources */,
F5C8F0172458584B000BCDEA /* Extension.swift in Sources */,
F5EE0505237EBDC200CF73F2 /* PetitionModel.swift in Sources */,
Expand Down Expand Up @@ -457,6 +461,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.PrakharPrakashBhardwaj.COVIDtracker;
PRODUCT_NAME = "COVID Tracker";
SWIFT_VERSION = 5.0;
Expand All @@ -476,6 +481,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.PrakharPrakashBhardwaj.COVIDtracker;
PRODUCT_NAME = "COVID Tracker";
SWIFT_VERSION = 5.0;
Expand Down
50 changes: 50 additions & 0 deletions COVIDtracker/Assets.xcassets/cellBgColor.colorset/Contents.json
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"
}
}
}
]
}
2 changes: 1 addition & 1 deletion COVIDtracker/Controller/CountryTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CountryTableViewController: UITableViewController {

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 6
return 7
}

}
3 changes: 2 additions & 1 deletion COVIDtracker/Controller/PetitionTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class PetitionTableViewController: UITableViewController {
class PetitionTableViewController: VersionUpdate {

var lastUpdate = Int(Date().timeIntervalSince1970)
var now = Int(Date().timeIntervalSince1970)
Expand Down Expand Up @@ -36,6 +36,7 @@ class PetitionTableViewController: UITableViewController {
navigationItem.leftBarButtonItems = [sortBtn]
navigationItem.rightBarButtonItems = [refreshBtn]

self.generateAPISession()
self.generateSession()
self.registerNib()

Expand Down
8 changes: 7 additions & 1 deletion COVIDtracker/Custom Cell/IndiaDetailCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -110,7 +111,7 @@
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" name="cellBgColor"/>
<constraints>
<constraint firstItem="OBl-Ys-zCz" firstAttribute="trailing" secondItem="ix1-i2-JXO" secondAttribute="trailing" id="GW3-fo-gpk"/>
<constraint firstItem="ix1-i2-JXO" firstAttribute="centerX" secondItem="Fbh-hV-XOr" secondAttribute="centerX" id="Hma-Qu-u4z"/>
Expand Down Expand Up @@ -153,4 +154,9 @@
<point key="canvasLocation" x="-649.27536231884062" y="343.19196428571428"/>
</tableViewCell>
</objects>
<resources>
<namedColor name="cellBgColor">
<color white="0.85000003576278682" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
</resources>
</document>
8 changes: 7 additions & 1 deletion COVIDtracker/Custom Cell/PetitionTableViewCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -110,7 +111,7 @@
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" name="cellBgColor"/>
<constraints>
<constraint firstItem="YTE-cq-hCK" firstAttribute="leading" secondItem="3ba-OA-0Zi" secondAttribute="leading" id="0lB-8m-ItC"/>
<constraint firstItem="YTE-cq-hCK" firstAttribute="top" secondItem="oA3-a1-VWX" secondAttribute="top" constant="10" id="E8F-OM-3KA"/>
Expand Down Expand Up @@ -153,4 +154,9 @@
<point key="canvasLocation" x="-723" y="515"/>
</tableViewCell>
</objects>
<resources>
<namedColor name="cellBgColor">
<color white="0.85000003576278682" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
</resources>
</document>
2 changes: 1 addition & 1 deletion COVIDtracker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion COVIDtracker/Model/Countries.swift

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions COVIDtracker/Utils/VersionUpdate.swift
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()
}
}

Loading

0 comments on commit 6a0ee13

Please sign in to comment.