Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode9.3
osx_image: xcode11.3

before_install:
- openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d
Expand Down
2 changes: 1 addition & 1 deletion application/AccountListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class AccountListViewController: UITableViewController {
}
}

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
if names.indices ~= indexPath.row {

Expand Down
2 changes: 1 addition & 1 deletion application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ImageCache {
var session: Session?
var window: UIWindow?

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// handle redirect URL from reddit.com
return OAuth2Authorizer.sharedInstance.receiveRedirect(url as URL, completion: {(result) -> Void in
switch result {
Expand Down
4 changes: 2 additions & 2 deletions application/BaseCommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class BaseCommentCell: UITableViewCell {

prepareToggleButton()

topInformationView.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "H:|-space-[authorButton]-space-[voteLabel]-space-[dateLabel]-(>=0)-[childlenLabel]-space-[toggleButton]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views)
topInformationView.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-space-[authorButton]-space-[voteLabel]-space-[dateLabel]-(>=0)-[childlenLabel]-space-[toggleButton]-space-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views)
)

voteLabel.text = "+100"
Expand Down
10 changes: 5 additions & 5 deletions application/CloseCommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

class CloseCommentCell: BaseCommentCell {

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
prepareSubviews()
}
Expand Down Expand Up @@ -42,16 +42,16 @@ class CloseCommentCell: BaseCommentCell {
"toolbarTopSpace": CommentCell.toolbarTopSpace
]

self.contentView.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views)
self.contentView.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views)
)

let topInformationViewHeight = NSLayoutConstraint(item: topInformationView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.informationViewHeight)
topInformationView.addConstraint(topInformationViewHeight)
self.topInformationViewHeight = topInformationViewHeight

self.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)
self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)
)

let varticalBarWidth = NSLayoutConstraint(item: verticalBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.verticalBarWidth)
Expand Down
28 changes: 14 additions & 14 deletions application/CommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {

func targetImageView(thumbnail: Thumbnail) -> UIImageView? {
if let commentContainer = commentContainer {
if let index = commentContainer.thumbnails.index(where: {$0.url == thumbnail.url}) {
if let index = commentContainer.thumbnails.firstIndex(where: {$0.url == thumbnail.url}) {
if 0..<thumbnailView.imageViews.count ~= index {
return thumbnailView.imageViews[index]
}
Expand Down Expand Up @@ -76,8 +76,8 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
"space": CommentCell.iconHorizontalSpace
]

toolbar.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "H:|-(>=0)-[upVote]-space-[downVote]-space-[save]-space-[reply]-space-[action]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views)
toolbar.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-(>=0)-[upVote]-space-[downVote]-space-[save]-space-[reply]-space-[action]-space-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views)
)

upVoteButton.addTarget(self, action: #selector(tapUpVoteButton(sender:)), for: .touchUpInside)
Expand Down Expand Up @@ -121,8 +121,8 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
"toolbarTopSpace": CommentCell.toolbarTopSpace
]

self.contentView.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-[textView]-toolbarTopSpace-[thumbnailView]-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views)
self.contentView.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-[textView]-toolbarTopSpace-[thumbnailView]-0-[toolbar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views)
)

let topInformationViewHeight = NSLayoutConstraint(item: topInformationView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.informationViewHeight)
Expand All @@ -137,15 +137,15 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
toolbar.addConstraint(toolbarHeight)
self.toolbarHeight = toolbarHeight

self.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)
self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)
)

self.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[thumbnailView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)
self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[thumbnailView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)
)
self.addConstraints (
NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)
self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[toolbar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)
)

let varticalBarWidth = NSLayoutConstraint(item: verticalBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.verticalBarWidth)
Expand All @@ -170,7 +170,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
}
prepareToolbar()
prepareInformationView()
self.contentView.bringSubview(toFront: thumbnailView)
self.contentView.bringSubviewToFront(thumbnailView)
childlenLabel.isHidden = true
}

Expand All @@ -186,7 +186,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
print("init - \(numberOfThumbnails) - \(self.reuseIdentifier!)")
}

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
self.numberOfThumbnails = 0
super.init(style: .default, reuseIdentifier: CommentThumbnailView.identifier(numberOfThumbnails: 0))
prepareSubviews()
Expand Down Expand Up @@ -275,7 +275,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator {
func urlAt(_ location: CGPoint, peekView: UIView) -> (URL, CGRect)? {
let tappedLocation = peekView.convert(location, to: textView)
if let attr = textView.attributes(at: tappedLocation) {
if let url = attr[NSAttributedStringKey.link] as? URL, let rect = attr[UZTextViewClickedRect] as? CGRect {
if let url = attr[NSAttributedString.Key.link] as? URL, let rect = attr[UZTextViewClickedRect] as? CGRect {
let tappedLocation = textView.convert(rect, to: peekView)
return (url, tappedLocation)
}
Expand Down
4 changes: 2 additions & 2 deletions application/CommentContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private func prepareHTML(html: String, constrainedBy width: CGFloat, fontSize: C
if isAA {
let font = UIFont(name: "Mona", size: fontSize)!
let output = NSMutableAttributedString(string: attr.string)
output.addAttribute(NSAttributedStringKey.font, value: font, range: attr.string.fullRange)
output.addAttribute(NSAttributedString.Key.font, value: font, range: attr.string.fullRange)
let bodySize = UZTextView.size(for: output, withBoundWidth: CGFloat.greatestFiniteMagnitude, margin: UIEdgeInsets.zero)
print("--------------------------------")
print("boundWidth=\(width)")
Expand Down Expand Up @@ -119,7 +119,7 @@ class CommentContainer: CommentContainable {

func extractURLsFromBody() -> [ImageURLContainer] {
var list: [ImageURLContainer] = []
body.enumerateAttribute(NSAttributedStringKey.link, in: NSRange(location: 0, length: body.length), options: NSAttributedString.EnumerationOptions(), using: { (value: Any?, _, _) -> Void in
body.enumerateAttribute(NSAttributedString.Key.link, in: NSRange(location: 0, length: body.length), options: NSAttributedString.EnumerationOptions(), using: { (value: Any?, _, _) -> Void in
if let url = value as? URL {
if url.isImageURL {
list.append(ImageURLInComment(sourceURL: url, parentID: self.thing.id))
Expand Down
8 changes: 4 additions & 4 deletions application/CommentContainerCellar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CommentContainerCellar {

func appendNewComment(_ newComment: Comment, to parentComment: Comment?, width: CGFloat) -> IndexPath? {
if let parentComment = parentComment {
if let index = containers.index(where: {$0.thing.name == parentComment.name}) {
if let index = containers.firstIndex(where: {$0.thing.name == parentComment.name}) {
let contaier = containers[index]
do {
let newContainer = try CommentContainable.createContainer(with: newComment, depth: contaier.depth + 1, width: width)
Expand Down Expand Up @@ -127,7 +127,7 @@ class CommentContainerCellar {
self.prefetch(containers: temp)

DispatchQueue.main.async(execute: { () -> Void in
if let targetIndex = self.containers.index(where: {$0 === moreContainer}) {
if let targetIndex = self.containers.firstIndex(where: {$0 === moreContainer}) {
self.containers.remove(at: targetIndex)
self.containers.insert(contentsOf: temp, at: targetIndex)

Expand Down Expand Up @@ -181,7 +181,7 @@ class CommentContainerCellar {
self.prefetch(containers: temp)

DispatchQueue.main.async(execute: { () -> Void in
if let targetIndex = self.containers.index(where: {$0 === commentContainer}) {
if let targetIndex = self.containers.firstIndex(where: {$0 === commentContainer}) {
self.containers.remove(at: targetIndex)
self.containers.insert(contentsOf: temp, at: targetIndex)

Expand Down Expand Up @@ -360,7 +360,7 @@ class CommentContainerCellar {
commentContainer.urlContainer[i] = new

DispatchQueue.main.async(execute: { () -> Void in
if let targetIndex = self.containers.index(where: {$0 === commentContainer}) {
if let targetIndex = self.containers.firstIndex(where: {$0 === commentContainer}) {
let reloadIndices = [IndexPath(row: targetIndex, section: 0)]
NotificationCenter.default.post(name: CommentContainerCellarDidLoadCommentsName, object: nil, userInfo: [CommentContainerCellar.reloadIndicesKey: reloadIndices])
}
Expand Down
4 changes: 2 additions & 2 deletions application/CommentThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CommentThumbnailView: UIView, ImageDownloadable {
for i in 0 ..< numberOfRows {
var temp: [UIImageView] = []
for _ in 0 ..< CommentThumbnailView.numberOfColumns {
let ac = UIActivityIndicatorView(activityIndicatorStyle: .gray)
let ac = UIActivityIndicatorView(style: .gray)
let iv = UIImageView(frame: CGRect.zero)
iv.clipsToBounds = true
iv.image = UIImage(named: "account")
Expand Down Expand Up @@ -199,7 +199,7 @@ extension CommentThumbnailView {

@objc func didFinishDownloading(notification: NSNotification) {
if let userInfo = notification.userInfo, let _ = userInfo[ImageDownloadableSenderKey], let url = userInfo[ImageDownloadableUrlKey] as? URL {
if let _ = thumbnails.index(where: {$0.thumbnailURL == url}) {
if let _ = thumbnails.firstIndex(where: {$0.thumbnailURL == url}) {
do {
if let _ = userInfo[ImageDownloadableErrorKey] as? NSError {
try setErrorImage(of: url)
Expand Down
8 changes: 4 additions & 4 deletions application/CommentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe

@objc func didChangeThumbnailPage(notification: Notification) {
if let userInfo = notification.userInfo, let thumbnail = userInfo["thumbnail"] as? Thumbnail {
if let index = cellar.containers.index(where: { $0.thing.id == thumbnail.parentID }) {
if let index = cellar.containers.firstIndex(where: { $0.thing.id == thumbnail.parentID }) {
let rect = tableView.rectForRow(at: IndexPath(row: index, section: 0))
tableView.scrollRectToVisible(rect, animated: false)
if let cell = tableView.cellForRow(at: IndexPath(row: index, section: 0)) as? ImageViewAnimator {
Expand All @@ -58,7 +58,7 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe

@objc func didUpdateCommentContainer(notification: Notification) {
if let userInfo = notification.userInfo, let commentContainer = userInfo["contents"] as? CommentContainer {
if let index = self.cellar.containers.index(where: {commentContainer.thing.id == $0.thing.id}) {
if let index = self.cellar.containers.firstIndex(where: {commentContainer.thing.id == $0.thing.id}) {
let indices = [IndexPath(row: index, section: 0)]
self.tableView.beginUpdates()
self.tableView.reloadRows(at: indices, with: .none)
Expand Down Expand Up @@ -351,13 +351,13 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe

extension CommentViewController {
func textView(_ textView: UZTextView, didLongTapLinkAttribute value: Any?) {
if let dict = value as? [String: Any], let url = dict[NSAttributedStringKey.link.rawValue] as? URL {
if let dict = value as? [String: Any], let url = dict[NSAttributedString.Key.link.rawValue] as? URL {
print(url)
}
}

func textView(_ textView: UZTextView, didClickLinkAttribute value: Any?) {
if let dict = value as? [String: Any], let url = dict[NSAttributedStringKey.link.rawValue] as? URL {
if let dict = value as? [String: Any], let url = dict[NSAttributedString.Key.link.rawValue] as? URL {
print(url)
}
}
Expand Down
8 changes: 4 additions & 4 deletions application/ContentInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

protocol ContentInfoViewDelegate {
protocol ContentInfoViewDelegate: class {
func didTapAuthorsNameButtonOnContentInfoView(contentInfoView: ContentInfoView)
}

Expand Down Expand Up @@ -65,7 +65,7 @@ class ContentInfoView: UIView {
var nameButtonWidthContraint: NSLayoutConstraint?
var domainLabelWidthContraint: NSLayoutConstraint?

var delegate: ContentInfoViewDelegate?
weak var delegate: ContentInfoViewDelegate?

/// Text color of all strings.
var textColor = ContentInfoView.defaultTextColor {
Expand Down Expand Up @@ -141,7 +141,7 @@ class ContentInfoView: UIView {

self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-labelHorizontalMargin-[dateLabel]-labelHorizontalMargin-[nameButton]-(>=0)-[domainLabel]-labelHorizontalMargin-|",
options: NSLayoutFormatOptions(),
options: NSLayoutConstraint.FormatOptions(),
metrics: metric,
views: ["dateLabel": dateLabel, "nameButton": nameButton, "domainLabel": domainLabel])
)
Expand Down Expand Up @@ -216,7 +216,7 @@ class ContentInfoView: UIView {
self.addConstraints(
NSLayoutConstraint.constraints(
withVisualFormat: "V:|-0-[view]-0-|",
options: NSLayoutFormatOptions(),
options: NSLayoutConstraint.FormatOptions(),
metrics: nil,
views: ["view": view]
)
Expand Down
Loading