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

52 lines
1.8 KiB
Swift
Raw Normal View History

2019-01-05 17:59:55 +00:00
//
// MyProfileTableViewController.swift
// Tusker
//
// Created by Shadowfacts on 11/24/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
2019-06-14 00:53:17 +00:00
import SwiftUI
2019-01-05 17:59:55 +00:00
class MyProfileTableViewController: ProfileTableViewController {
init(mastodonController: MastodonController) {
super.init(accountID: nil, mastodonController: mastodonController)
2019-01-05 17:59:55 +00:00
title = "My Profile"
2019-06-11 17:21:22 +00:00
tabBarItem.image = UIImage(systemName: "person.fill")
mastodonController.getOwnAccount { (account) in
2019-01-05 17:59:55 +00:00
self.accountID = account.id
_ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in
guard let self = self, let data = data, let image = UIImage(data: data) else { return }
2019-06-04 17:31:05 +00:00
DispatchQueue.main.async {
2019-06-11 17:21:22 +00:00
let size = CGSize(width: 30, height: 30)
let tabBarImage = UIGraphicsImageRenderer(size: size).image { (_) in
image.draw(in: CGRect(origin: .zero, size: size))
}
let alwaysOriginalImage = tabBarImage.withRenderingMode(.alwaysOriginal)
self.tabBarItem.image = alwaysOriginalImage
2019-06-04 17:31:05 +00:00
}
2019-01-05 17:59:55 +00:00
})
}
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Preferences", style: .plain, target: self, action: #selector(preferencesPressed))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func preferencesPressed() {
present(PreferencesNavigationController(mastodonController: mastodonController), animated: true)
2019-06-14 00:53:17 +00:00
}
@objc func closePreferences() {
dismiss(animated: true)
2019-01-05 17:59:55 +00:00
}
}