mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 18:23:53 +01:00
Adds basic AppsViewController implementation
This commit is contained in:
52
AltStore/Apps/AppsViewController.swift
Normal file
52
AltStore/Apps/AppsViewController.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// AppsViewController.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/9/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Roxas
|
||||
|
||||
class AppsViewController: UITableViewController
|
||||
{
|
||||
private lazy var dataSource = self.makeDataSource()
|
||||
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
|
||||
self.tableView.dataSource = self.dataSource
|
||||
|
||||
// Hide trailing row separators.
|
||||
self.tableView.tableFooterView = UIView()
|
||||
}
|
||||
}
|
||||
|
||||
private extension AppsViewController
|
||||
{
|
||||
func makeDataSource() -> RSTArrayTableViewDataSource<App>
|
||||
{
|
||||
let appsFileURL = Bundle.main.url(forResource: "Apps", withExtension: "plist")!
|
||||
|
||||
do
|
||||
{
|
||||
let data = try Data(contentsOf: appsFileURL)
|
||||
let apps = try PropertyListDecoder().decode([App].self, from: data)
|
||||
|
||||
let dataSource = RSTArrayTableViewDataSource(items: apps)
|
||||
dataSource.cellConfigurationHandler = { (cell, app, indexPath) in
|
||||
let cell = cell as! AppTableViewCell
|
||||
cell.nameLabel.text = app.name
|
||||
cell.subtitleLabel.text = app.subtitle
|
||||
cell.appIconImageView.image = UIImage(named: app.iconName)
|
||||
}
|
||||
return dataSource
|
||||
}
|
||||
catch
|
||||
{
|
||||
fatalError("Failed to load apps. \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user