Adds basic MyAppsViewController implementation

This commit is contained in:
Riley Testut
2019-05-20 21:26:01 +02:00
parent c3a8abf8dc
commit 42734f2004
9 changed files with 263 additions and 45 deletions

View File

@@ -48,6 +48,8 @@ class AppDetailViewController: UITableViewController
self.tableView.delegate = self
self.screenshotsCollectionView.dataSource = self.screenshotsDataSource
self.downloadButton.activityIndicatorView.style = .white
self.update()
}
@@ -95,6 +97,39 @@ private extension AppDetailViewController
}
}
private extension AppDetailViewController
{
@IBAction func downloadApp(_ sender: UIButton)
{
guard self.app.installedApp == nil else { return }
sender.isIndicatingActivity = true
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
let app = context.object(with: self.app.objectID) as! App
_ = InstalledApp(app: app,
bundleIdentifier: app.identifier,
signedDate: Date(),
expirationDate: Date().addingTimeInterval(60 * 60 * 24 * 7),
context: context)
do
{
try context.save()
}
catch
{
print("Failed to download app.", error)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
sender.isIndicatingActivity = false
}
}
}
}
extension AppDetailViewController
{
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat