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 {
|
|
|
|
|
2020-01-05 20:25:07 +00:00
|
|
|
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")
|
|
|
|
|
2020-01-05 20:25:07 +00:00
|
|
|
mastodonController.getOwnAccount { (account) in
|
2019-01-05 17:59:55 +00:00
|
|
|
self.accountID = account.id
|
|
|
|
|
2020-01-25 15:06:27 +00:00
|
|
|
_ = 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() {
|
2020-01-08 02:29:15 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|