Skip to content

Commit

Permalink
Merge branch 'epic/IOS-536-app-redesign-signup-staging' into epic/IOS…
Browse files Browse the repository at this point in the history
…-536-app-redesign-signup-staging-public-beta
  • Loading branch information
jurajhilje committed Aug 26, 2020
2 parents ec49d02 + d6de9b5 commit d5aa046
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 46 deletions.
24 changes: 12 additions & 12 deletions IVPNClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@
CODE_SIGN_ENTITLEMENTS = "today-extension/today-extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "today-extension/Info.plist";
Expand Down Expand Up @@ -2436,7 +2436,7 @@
CODE_SIGN_ENTITLEMENTS = "today-extension/today-extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "today-extension/Info.plist";
Expand Down Expand Up @@ -2464,7 +2464,7 @@
CODE_SIGN_ENTITLEMENTS = "today-extension/today-extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "today-extension/Info.plist";
Expand Down Expand Up @@ -2492,7 +2492,7 @@
CODE_SIGN_ENTITLEMENTS = "wireguard-tunnel-provider/wireguard_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2530,7 +2530,7 @@
CODE_SIGN_ENTITLEMENTS = "wireguard-tunnel-provider/wireguard_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2695,7 +2695,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = IVPNClient/IVPNClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -2767,7 +2767,7 @@
CODE_SIGN_ENTITLEMENTS = "openvpn-tunnel-provider/openvpn_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -2798,7 +2798,7 @@
CODE_SIGN_ENTITLEMENTS = "wireguard-tunnel-provider/wireguard_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2868,7 +2868,7 @@
CODE_SIGN_ENTITLEMENTS = "openvpn-tunnel-provider/openvpn_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -2909,7 +2909,7 @@
CODE_SIGN_ENTITLEMENTS = "openvpn-tunnel-provider/openvpn_tunnel_provider.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3055,7 +3055,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = IVPNClient/IVPNClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -3090,7 +3090,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = IVPNClient/IVPNClient.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = WQXXM75BYN;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
54 changes: 25 additions & 29 deletions IVPNClient/Scenes/ViewControllers/ServerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,25 @@ class ServerViewController: UITableViewController {
// MARK: - Properties -

var isExitServer = false
var collection = [VPNServer]()
var filteredCollection = [VPNServer]()
weak var serverDelegate: ServerViewControllerDelegate?

var collection:[VPNServer] {
var list = [VPNServer]()

if isSearchActive {
list = filteredCollection
} else {
list = Application.shared.serverList.servers
}

if !UserDefaults.shared.isMultiHop {
list = [VPNServer(gateway: "", countryCode: "", country: "", city: "", fastest: true)] + list
}

return list
}

var isSearchActive: Bool {
return !searchBar.text!.isEmpty
}
Expand All @@ -62,9 +77,8 @@ class ServerViewController: UITableViewController {
guard index > -1 else { return }

let sort = ServersSort.allCases[index]

UserDefaults.shared.set(sort.rawValue, forKey: UserDefaults.Key.serversSort)
self.initCollection()
Application.shared.serverList.sortServers()
self.filteredCollection = VPNServerList.sort(self.filteredCollection)
self.tableView.reloadData()
}
Expand All @@ -75,7 +89,7 @@ class ServerViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
initNavigationBar()
initCollection()
Application.shared.serverList.sortServers()
tableView.keyboardDismissMode = .onDrag
}

Expand Down Expand Up @@ -110,7 +124,8 @@ class ServerViewController: UITableViewController {
}

@objc func pingDidComplete() {
initCollection()
Application.shared.serverList.sortServers()
filteredCollection = VPNServerList.sort(self.filteredCollection)
tableView.reloadData()
}

Expand All @@ -132,16 +147,6 @@ class ServerViewController: UITableViewController {
searchBar.backgroundImage = UIImage()
}

private func initCollection() {
Application.shared.serverList.sortServers()

collection = [VPNServer(gateway: "", countryCode: "", country: "", city: "", fastest: true)] + Application.shared.serverList.servers

if UserDefaults.shared.isMultiHop {
collection = Application.shared.serverList.servers
}
}

private func enableRefreshControl() {
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(self.refresh), for: UIControl.Event.valueChanged)
Expand All @@ -160,20 +165,14 @@ class ServerViewController: UITableViewController {
extension ServerViewController {

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if isSearchActive {
return filteredCollection.count
} else {
return collection.count
}
return collection.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ServerTableViewCell", for: indexPath) as! ServerTableViewCell
let server = isSearchActive ? filteredCollection[indexPath.row] : collection[indexPath.row]

cell.isMultiHop = UserDefaults.shared.isMultiHop
cell.indexPath = indexPath
cell.viewModel = VPNServerViewModel(server: server)
cell.viewModel = VPNServerViewModel(server: collection[indexPath.row])
cell.serverToValidate = isExitServer ? Application.shared.settings.selectedServer : Application.shared.settings.selectedExitServer
cell.selectedServer = isExitServer ? Application.shared.settings.selectedExitServer : Application.shared.settings.selectedServer

Expand All @@ -189,7 +188,7 @@ extension ServerViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard indexPath.row < collection.count else { return }

let server = isSearchActive ? filteredCollection[indexPath.row] : collection[indexPath.row]
let server = collection[indexPath.row]
var secondServer = Application.shared.settings.selectedExitServer
var serverDifferentToSelectedServer = server !== Application.shared.settings.selectedServer

Expand Down Expand Up @@ -262,18 +261,15 @@ extension ServerViewController {
extension ServerViewController: UISearchBarDelegate {

func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
filteredCollection.removeAll(keepingCapacity: false)
let collection = Application.shared.serverList.servers

filteredCollection.removeAll(keepingCapacity: false)
filteredCollection = collection.filter { (server: VPNServer) -> Bool in
return server.city.lowercased().contains(searchBar.text!.lowercased())
}

filteredCollection = VPNServerList.sort(filteredCollection)

if !UserDefaults.shared.isMultiHop {
filteredCollection = [VPNServer(gateway: "", countryCode: "", country: "", city: "", fastest: true)] + filteredCollection
}

tableView.reloadData()
}

Expand Down
2 changes: 1 addition & 1 deletion UITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>26</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion UnitTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>26</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion openvpn-tunnel-provider/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>26</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion today-extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>26</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
Expand Down
2 changes: 1 addition & 1 deletion wireguard-tunnel-provider/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>26</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down

0 comments on commit d5aa046

Please sign in to comment.