Tusker/Tusker/Screens/Profile/MyProfileTableViewControlle...

50 lines
1.5 KiB
Swift

//
// MyProfileTableViewController.swift
// Tusker
//
// Created by Shadowfacts on 11/24/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
class MyProfileTableViewController: ProfileTableViewController {
init() {
super.init(accountID: nil)
title = "My Profile"
MastodonController.getOwnAccount { (account) in
self.accountID = account.id
ImageCache.avatars.get(account.avatar, completion: { (data) in
guard let data = data else { return }
var image = UIImage(data: data)!
image = UIGraphicsImageRenderer(size: CGSize(width: 30, height: 30)).image(actions: { (_) in
image.draw(in: CGRect(x: 0, y: 0, width: 30, height: 30))
})
image = image.withRenderingMode(.alwaysOriginal)
DispatchQueue.main.async {
self.tabBarItem.image = image
}
})
}
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Preferences", style: .plain, target: self, action: #selector(preferencesPressed))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
}
@objc func preferencesPressed() {
present(PreferencesTableViewController.create(), animated: true)
}
}