Files
SideStore/Sources/SideStoreAppKit/Authentication/SelectTeamViewController.swift

72 lines
2.1 KiB
Swift
Raw Normal View History

//
// SelectTeamViewController.swift
// AltStore
//
// Created by Megarushing on 4/26/21.
// Copyright © 2021 Riley Testut. All rights reserved.
//
import Intents
import IntentsUI
2023-03-01 00:48:36 -05:00
import MessageUI
import SafariServices
import UIKit
2023-03-01 14:36:52 -05:00
import os.log
import AltSign
2023-03-01 00:48:36 -05:00
final class SelectTeamViewController: UITableViewController {
public var teams: [ALTTeam]?
2023-03-01 00:48:36 -05:00
public var completionHandler: ((Result<ALTTeam, Swift.Error>) -> Void)?
private var prototypeHeaderFooterView: SettingsHeaderFooterView!
2023-03-01 00:48:36 -05:00
override var preferredStatusBarStyle: UIStatusBarStyle {
2023-03-01 00:48:36 -05:00
.lightContent
}
2023-03-01 00:48:36 -05:00
override func numberOfSections(in _: UITableView) -> Int {
1
}
2023-03-01 00:48:36 -05:00
override func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
teams?.count ?? 0
}
2023-03-01 00:48:36 -05:00
override func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
2023-03-01 14:36:52 -05:00
precondition(completionHandler != nil)
precondition(teams != nil)
precondition(teams!.count <= indexPath.row)
guard let completionHandler = completionHandler else {
os_log("completionHandler was nil", type: .error)
return
}
guard let teams = teams, teams.count <= indexPath.row else {
os_log("teams nil or out of bounds", type: .error)
return
}
completionHandler(.success(teams[indexPath.row]))
}
2023-03-01 00:48:36 -05:00
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TeamCell", for: indexPath) as! InsetGroupTableViewCell
2023-03-01 00:48:36 -05:00
cell.textLabel?.text = teams?[indexPath.row].name
cell.detailTextLabel?.text = teams?[indexPath.row].type.localizedDescription
if indexPath.row == 0 {
cell.style = InsetGroupTableViewCell.Style.top
} else if indexPath.row == self.tableView(self.tableView, numberOfRowsInSection: indexPath.section) - 1 {
cell.style = InsetGroupTableViewCell.Style.bottom
} else {
cell.style = InsetGroupTableViewCell.Style.middle
}
return cell
}
2023-03-01 00:48:36 -05:00
override func tableView(_: UITableView, titleForHeaderInSection _: Int) -> String? {
"Teams"
}
}