Browse Source

Fix the avatar UIBarButtonItem

master
Dwayne Harris 6 years ago
parent
commit
7ce49ca074
  1. 2
      elpha-ios/AlertManager.swift
  2. 16
      elpha-ios/AlertView.swift
  3. 47
      elpha-ios/Base.lproj/Main.storyboard
  4. 108
      elpha-ios/TimelineTableViewController.swift

2
elpha-ios/AlertManager.swift

@ -9,7 +9,7 @@
import UIKit
enum AlertCategory {
case normal, newStatuses, favorited, boosted, noConnection, error
case normal, newStatuses, favorited, boosted, toot, noConnection, error
}
class Alert {

16
elpha-ios/AlertView.swift

@ -34,14 +34,14 @@ import UIKit
public func setAlert(_ alert: Alert) {
switch alert.category {
case .newStatuses:
alertImageView.image = UIImage(named: "Comments")
case .favorited:
alertImageView.image = UIImage(named: "Star Filled")
case .boosted:
alertImageView.image = UIImage(named: "Boost Bold")
default:
alertImageView.image = UIImage(named: "Alert")
case .newStatuses, .toot:
alertImageView.image = UIImage(named: "Comments")
case .favorited:
alertImageView.image = UIImage(named: "Star Filled")
case .boosted:
alertImageView.image = UIImage(named: "Boost Bold")
default:
alertImageView.image = UIImage(named: "Alert")
}
alertLabel.text = alert.message

47
elpha-ios/Base.lproj/Main.storyboard

@ -116,7 +116,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="aNa-IN-5Hu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="1048"/>
<point key="canvasLocation" x="-1" y="1195"/>
</scene>
<!--Instances-->
<scene sceneID="24Q-ad-dey">
@ -250,7 +250,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pnx-Ji-ouu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1973.913043478261" y="1047.9910714285713"/>
<point key="canvasLocation" x="1922" y="1195"/>
</scene>
<!--Instance View Controller-->
<scene sceneID="u4y-73-40c">
@ -473,21 +473,21 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2br-gN-kxb" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2702.898550724638" y="1047.3214285714284"/>
<point key="canvasLocation" x="2703" y="1193"/>
</scene>
<!--Account-->
<scene sceneID="mCa-NC-tD9">
<objects>
<tableViewController storyboardIdentifier="AccountTableViewController" id="X5f-Me-0D2" customClass="AccountTableViewController" customModule="elpha_ios" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="BA3-TV-fdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="900"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="ygB-F6-Moa">
<rect key="frame" x="0.0" y="0.0" width="375" height="524"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="545"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0jO-Rb-lcz">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0jO-Rb-lcz">
<rect key="frame" x="0.0" y="0.0" width="375" height="150"/>
<constraints>
<constraint firstAttribute="height" constant="150" id="HWQ-9W-TLG"/>
@ -513,7 +513,7 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="D5v-MR-CuQ">
<rect key="frame" x="20" y="416" width="105" height="60"/>
<rect key="frame" x="20" y="427" width="105" height="60"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Toots" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kTz-EN-Zgx">
<rect key="frame" x="8" y="10" width="89" height="14.333333333333336"/>
@ -539,7 +539,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TkS-vn-sW3">
<rect key="frame" x="135" y="416" width="105" height="60"/>
<rect key="frame" x="135" y="427" width="105" height="60"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Following" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FxQ-nq-jYw">
<rect key="frame" x="8" y="10" width="89" height="14.333333333333336"/>
@ -565,7 +565,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rqF-sG-ZE7">
<rect key="frame" x="250" y="416" width="105" height="60"/>
<rect key="frame" x="250" y="427" width="105" height="60"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Followers" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="piT-tX-tUe">
<rect key="frame" x="8" y="10" width="89" height="14.333333333333336"/>
@ -591,7 +591,7 @@
</constraints>
</view>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="lwU-IL-uAN">
<rect key="frame" x="10" y="486" width="355" height="29"/>
<rect key="frame" x="10" y="497" width="355" height="29"/>
<segments>
<segment title="Toots"/>
<segment title="Toots &amp; Replies"/>
@ -603,10 +603,10 @@
</connections>
</segmentedControl>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="deT-ms-U3E">
<rect key="frame" x="0.0" y="254" width="375" height="147"/>
<rect key="frame" x="0.0" y="254" width="375" height="158"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="Note" textAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="7EZ-R5-qfQ" customClass="UITextViewFixed" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="35.333333333333336"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="46.333333333333336"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" name="Secondary"/>
<color key="textColor" name="Text"/>
@ -615,7 +615,7 @@
<dataDetectorType key="dataDetectorTypes" phoneNumber="YES" link="YES" address="YES" calendarEvent="YES" shipmentTrackingNumber="YES" flightNumber="YES" lookupSuggestion="YES"/>
</textView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="40" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="LkG-MC-taI">
<rect key="frame" x="0.0" y="35.333333333333321" width="375" height="111.66666666666669"/>
<rect key="frame" x="0.0" y="46.333333333333321" width="375" height="111.66666666666669"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<inset key="separatorInset" minX="5" minY="0.0" maxX="0.0" maxY="0.0"/>
<prototypes>
@ -676,7 +676,7 @@
<constraint firstItem="deT-ms-U3E" firstAttribute="top" secondItem="XET-LP-bGO" secondAttribute="bottom" constant="8" id="SkL-f3-Xpd"/>
<constraint firstItem="lwU-IL-uAN" firstAttribute="top" secondItem="rqF-sG-ZE7" secondAttribute="bottom" constant="10" id="WTw-4o-oN0"/>
<constraint firstItem="D5v-MR-CuQ" firstAttribute="width" secondItem="TkS-vn-sW3" secondAttribute="width" id="Wh6-R2-fsh"/>
<constraint firstAttribute="bottom" secondItem="lwU-IL-uAN" secondAttribute="bottom" constant="10" id="YQf-Cp-ypH"/>
<constraint firstAttribute="bottom" secondItem="lwU-IL-uAN" secondAttribute="bottom" constant="20" id="YQf-Cp-ypH"/>
<constraint firstItem="0jO-Rb-lcz" firstAttribute="top" secondItem="ygB-F6-Moa" secondAttribute="top" id="avA-XU-Hlb"/>
<constraint firstItem="lwU-IL-uAN" firstAttribute="leading" secondItem="ygB-F6-Moa" secondAttribute="leading" constant="10" id="dkb-zx-jFp"/>
<constraint firstItem="d7X-u9-Seq" firstAttribute="centerX" secondItem="ygB-F6-Moa" secondAttribute="centerX" id="e6Y-Fv-aMf"/>
@ -696,7 +696,7 @@
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AccountTableViewCell" id="nLQ-4Q-SwI" customClass="AccountTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="552" width="375" height="44"/>
<rect key="frame" x="0.0" y="573" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="nLQ-4Q-SwI" id="y0d-Ka-W2g">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -725,6 +725,7 @@
</connections>
</tableView>
<navigationItem key="navigationItem" title="Account" id="5hW-Ep-t5f"/>
<size key="freeformSize" width="375" height="900"/>
<refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="fRb-ea-Rvd">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
@ -747,7 +748,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dWu-5e-ce7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1634.4000000000001" y="359.11330049261085"/>
<point key="canvasLocation" x="1710" y="391"/>
</scene>
<!--Main Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
@ -793,7 +794,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lyd-tU-mSo" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="749.60000000000002" y="-320.68965517241384"/>
<point key="canvasLocation" x="801" y="-321"/>
</scene>
<!--Settings Table View Controller-->
<scene sceneID="F39-u9-uN2">
@ -990,7 +991,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SUU-jm-HDm" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="748" y="-1095.0738916256157"/>
<point key="canvasLocation" x="1710" y="-1039"/>
</scene>
<!--Timelines View Controller-->
<scene sceneID="utN-zB-UGT">
@ -1090,7 +1091,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Ao-Vi-HOQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1632.8" y="-1094.3349753694581"/>
<point key="canvasLocation" x="2702" y="-850"/>
</scene>
<!--Compose View Controller-->
<scene sceneID="K94-uj-No4">
@ -1290,7 +1291,7 @@
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="2702" y="-828"/>
<point key="canvasLocation" x="3614" y="-850"/>
</scene>
<!--Timeline-->
<scene sceneID="jGL-v8-K0I">
@ -1343,7 +1344,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="KTy-Tn-EdD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1634.7826086956522" y="-321.42857142857139"/>
<point key="canvasLocation" x="1710" y="-321"/>
</scene>
<!--Status Table View Controller-->
<scene sceneID="E93-GN-Ar4">
@ -1879,7 +1880,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pTB-k2-GBg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1034.7826086956522" y="1047.9910714285713"/>
<point key="canvasLocation" x="1017" y="1194"/>
</scene>
<!--Account-->
<scene sceneID="7xU-Ns-Wf3">
@ -1905,7 +1906,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="afp-al-BvF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="749.27536231884062" y="359.59821428571428"/>
<point key="canvasLocation" x="802" y="359"/>
</scene>
</scenes>
<resources>

108
elpha-ios/TimelineTableViewController.swift

@ -21,16 +21,16 @@ class TimelineTableViewController: AbstractStatusTableViewController {
}
switch TimelineCategory(rawValue: categoryString)! {
case .home:
return "timeline:home"
case .local:
return "timeline:local"
case .federated:
return "timeline:federated"
case .tag:
return "timeline:tag:\(timeline.subcategory!)"
case .favorites:
return "timeline:favorites"
case .home:
return "timeline:home"
case .local:
return "timeline:local"
case .federated:
return "timeline:federated"
case .tag:
return "timeline:tag:\(timeline.subcategory!)"
case .favorites:
return "timeline:favorites"
}
}
}
@ -41,18 +41,32 @@ class TimelineTableViewController: AbstractStatusTableViewController {
feedbackGenerator = UINotificationFeedbackGenerator()
initializeFetchedResultsController()
let scale = UIScreen.main.scale
let avatarButtonSize: CGFloat = 30
let avatarButtonScaledSize = avatarButtonSize * scale
let moreButtonItem = UIBarButtonItem(image: UIImage(named: "More"), style: .plain, target: self, action: #selector(more))
let composeButtonItem = UIBarButtonItem(image: UIImage(named: "Compose"), style: .plain, target: self, action: #selector(compose))
let avatarButtonItem = UIBarButtonItem(image: UIImage(named: "Account"), style: .plain, target: self, action: #selector(self.openSettings))
let avatarButton = UIButton()
avatarButton.setBackgroundImage(UIImage(named: "Account"), for: .normal)
avatarButton.addTarget(self, action: #selector(self.openSettings), for: .touchUpInside)
NSLayoutConstraint.activate([
avatarButton.widthAnchor.constraint(equalToConstant: avatarButtonSize),
avatarButton.heightAnchor.constraint(equalToConstant: avatarButtonSize)
])
let avatarButtonItem = UIBarButtonItem(customView: avatarButton)
navigationItem.leftBarButtonItems = [avatarButtonItem, moreButtonItem]
navigationItem.rightBarButtonItems = [composeButtonItem]
if let account = AuthenticationManager.session?.account {
let processor = ResizingImageProcessor(referenceSize: CGSize(width: 30, height: 30), mode: .aspectFill) >> RoundCornerImageProcessor(cornerRadius: 10)
let processor = ResizingImageProcessor(referenceSize: CGSize(width: avatarButtonScaledSize, height: avatarButtonScaledSize), mode: .aspectFill) >> RoundCornerImageProcessor(cornerRadius: avatarButtonScaledSize / 2)
ImageDownloader.default.downloadImage(with: account.avatarURL!, retrieveImageTask: nil, options: [.processor(processor)], progressBlock: nil) { image, error, url, data in
if let image = image {
avatarButtonItem.image = image.withRenderingMode(.alwaysOriginal)
avatarButton.setBackgroundImage(image.withRenderingMode(.alwaysOriginal), for: .normal)
}
}
}
@ -252,40 +266,40 @@ class TimelineTableViewController: AbstractStatusTableViewController {
loading = true
switch TimelineCategory(rawValue: timeline.category!)! {
case .home:
MastodonAPI.homeTimeline(
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .local:
MastodonAPI.publicTimeline(
local: true,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .federated:
MastodonAPI.publicTimeline(
local: false,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .tag:
MastodonAPI.tagTimeline(
tag: timeline.subcategory!,
local: false,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .favorites:
MastodonAPI.favorites(
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .home:
MastodonAPI.homeTimeline(
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .local:
MastodonAPI.publicTimeline(
local: true,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .federated:
MastodonAPI.publicTimeline(
local: false,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .tag:
MastodonAPI.tagTimeline(
tag: timeline.subcategory!,
local: false,
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
case .favorites:
MastodonAPI.favorites(
limit: fetchLimit,
pagination: pagination,
completion: requestCompletion
)
}
}
}

Loading…
Cancel
Save