class TunnelEditTableViewController: UITableViewController {
- let interfaceEditFieldsBySection: [[TunnelViewModel.InterfaceField]] = [
+ let interfaceFieldsBySection: [[TunnelViewModel.InterfaceField]] = [
[.name],
[.privateKey, .publicKey, .generateKeyPair],
[.addresses, .listenPort, .mtu, .dns]
]
- let peerEditFieldsBySection: [[TunnelViewModel.PeerField]] = [
+ let peerFieldsBySection: [[TunnelViewModel.PeerField]] = [
[.publicKey, .preSharedKey, .endpoint,
.allowedIPs, .excludePrivateIPs,
.persistentKeepAlive,
extension TunnelEditTableViewController {
override func numberOfSections(in tableView: UITableView) -> Int {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
let numberOfPeers = tunnelViewModel.peersData.count
return numberOfInterfaceSections + (numberOfPeers * numberOfPeerSections) + 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
let numberOfPeers = tunnelViewModel.peersData.count
if (section < numberOfInterfaceSections) {
// Interface
- return interfaceEditFieldsBySection[section].count
+ return interfaceFieldsBySection[section].count
} else if ((numberOfPeers > 0) && (section < (numberOfInterfaceSections + numberOfPeers * numberOfPeerSections))) {
// Peer
let fieldIndex = (section - numberOfInterfaceSections) % numberOfPeerSections
- return peerEditFieldsBySection[fieldIndex].count
+ return peerFieldsBySection[fieldIndex].count
} else {
// Add peer
return 1
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
let numberOfPeers = tunnelViewModel.peersData.count
if (section < numberOfInterfaceSections) {
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
let numberOfPeers = tunnelViewModel.peersData.count
let section = indexPath.section
if (section < numberOfInterfaceSections) {
// Interface
let interfaceData = tunnelViewModel.interfaceData
- let field = interfaceEditFieldsBySection[section][row]
+ let field = interfaceFieldsBySection[section][row]
if (field == .generateKeyPair) {
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelsEditTableViewButtonCell.id, for: indexPath) as! TunnelsEditTableViewButtonCell
cell.buttonText = field.rawValue
let peerIndex = Int((section - numberOfInterfaceSections) / numberOfPeerSections)
let peerSectionIndex = (section - numberOfInterfaceSections) % numberOfPeerSections
let peerData = tunnelViewModel.peersData[peerIndex]
- let field = peerEditFieldsBySection[peerSectionIndex][row]
+ let field = peerFieldsBySection[peerSectionIndex][row]
if (field == .deletePeer) {
let cell = tableView.dequeueReusableCell(withIdentifier: TunnelsEditTableViewButtonCell.id, for: indexPath) as! TunnelsEditTableViewButtonCell
cell.buttonText = field.rawValue
}
func appendEmptyPeer() -> IndexSet {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
tunnelViewModel.appendEmptyPeer()
let addedPeerIndex = tunnelViewModel.peersData.count - 1
}
func deletePeer(peer: TunnelViewModel.PeerData) -> IndexSet {
- let numberOfInterfaceSections = interfaceEditFieldsBySection.count
- let numberOfPeerSections = peerEditFieldsBySection.count
+ let numberOfInterfaceSections = interfaceFieldsBySection.count
+ let numberOfPeerSections = peerFieldsBySection.count
assert(peer.index < tunnelViewModel.peersData.count)
tunnelViewModel.deletePeer(peer: peer)