diff --git a/elpha-ios.xcodeproj/project.pbxproj b/elpha-ios.xcodeproj/project.pbxproj index ec60048..5f624f9 100644 --- a/elpha-ios.xcodeproj/project.pbxproj +++ b/elpha-ios.xcodeproj/project.pbxproj @@ -51,6 +51,7 @@ 15BB72AB2171A8D4002F1FA4 /* TimelinesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15BB72AA2171A8D4002F1FA4 /* TimelinesTableViewCell.swift */; }; 15C91A02216AB2D600D97DC3 /* AlertView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15C91A01216AB2D600D97DC3 /* AlertView.xib */; }; 15C91A04216AB32500D97DC3 /* AlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15C91A03216AB32500D97DC3 /* AlertView.swift */; }; + 15CF7244219282AF00E6BF19 /* UITextViewFixed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CF7243219282AF00E6BF19 /* UITextViewFixed.swift */; }; 15F9981721629965009E58DA /* TimelineTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15F9981621629965009E58DA /* TimelineTableViewController.swift */; }; 15F998352162C0E8009E58DA /* MastodonDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15F998342162C0E8009E58DA /* MastodonDataManager.swift */; }; /* End PBXBuildFile section */ @@ -237,6 +238,7 @@ 15BB72AA2171A8D4002F1FA4 /* TimelinesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinesTableViewCell.swift; sourceTree = ""; }; 15C91A01216AB2D600D97DC3 /* AlertView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlertView.xib; sourceTree = ""; }; 15C91A03216AB32500D97DC3 /* AlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertView.swift; sourceTree = ""; }; + 15CF7243219282AF00E6BF19 /* UITextViewFixed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextViewFixed.swift; sourceTree = ""; }; 15F9981621629965009E58DA /* TimelineTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineTableViewController.swift; sourceTree = ""; }; 15F998342162C0E8009E58DA /* MastodonDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonDataManager.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -378,11 +380,12 @@ 15960E59213145E100C38CE9 /* elpha-ios */ = { isa = PBXGroup; children = ( - 15960E5A213145E100C38CE9 /* AppDelegate.swift */, 15960E63213145E200C38CE9 /* Assets.xcassets */, - 15960E7621322C6F00C38CE9 /* Configuration.swift */, - 15960E6E21321FA500C38CE9 /* Elpha.xcdatamodeld */, 15960E68213145E200C38CE9 /* Info.plist */, + 15960E6E21321FA500C38CE9 /* Elpha.xcdatamodeld */, + 15960E5A213145E100C38CE9 /* AppDelegate.swift */, + 15960E7621322C6F00C38CE9 /* Configuration.swift */, + 15CF7243219282AF00E6BF19 /* UITextViewFixed.swift */, 156FF05621779C140074D9CA /* API */, 151AD4AF2166DDA000F07403 /* Extensions */, 15960E7121322B9F00C38CE9 /* Keychain Helper */, @@ -634,6 +637,7 @@ 15960E7C213272CD00C38CE9 /* AuthenticationManager.swift in Sources */, 15B127922192467F00F4EF1D /* String+HtmlAttributed.swift in Sources */, 15960E7E21329FED00C38CE9 /* AuthenticateViewController.swift in Sources */, + 15CF7244219282AF00E6BF19 /* UITextViewFixed.swift in Sources */, 15960E5B213145E100C38CE9 /* AppDelegate.swift in Sources */, 15131EF2216D8D570092B252 /* StatusView.swift in Sources */, 152734D22186DC74003DB3C8 /* TimelinesViewController.swift in Sources */, diff --git a/elpha-ios/AccountTableViewController.swift b/elpha-ios/AccountTableViewController.swift index 2a298ff..b63adcb 100644 --- a/elpha-ios/AccountTableViewController.swift +++ b/elpha-ios/AccountTableViewController.swift @@ -74,7 +74,7 @@ class AccountTableViewController: UITableViewController { } displayNameLabel.text = account.displayName - usernameLabel.text = account.acct + usernameLabel.text = "@\(account.acct!)" if let note = account.note { contentLabel.attributedText = note.htmlAttributed(size: 15, centered: true) @@ -370,7 +370,7 @@ extension AccountTableViewController: StatusViewDelegate { controller.status = status controller.attachmentIndex = index - self.navigationController?.pushViewController(controller, animated: false) + present(controller, animated: false) } } } diff --git a/elpha-ios/Assets.xcassets/Icons/Close.imageset/Contents.json b/elpha-ios/Assets.xcassets/Icons/Close.imageset/Contents.json new file mode 100644 index 0000000..58a1f2d --- /dev/null +++ b/elpha-ios/Assets.xcassets/Icons/Close.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "x-square.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/elpha-ios/Assets.xcassets/Icons/Close.imageset/x-square.pdf b/elpha-ios/Assets.xcassets/Icons/Close.imageset/x-square.pdf new file mode 100644 index 0000000..35aead3 Binary files /dev/null and b/elpha-ios/Assets.xcassets/Icons/Close.imageset/x-square.pdf differ diff --git a/elpha-ios/Assets.xcassets/Icons/Share.imageset/Contents.json b/elpha-ios/Assets.xcassets/Icons/Share.imageset/Contents.json new file mode 100644 index 0000000..840cdbf --- /dev/null +++ b/elpha-ios/Assets.xcassets/Icons/Share.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "share.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/elpha-ios/Assets.xcassets/Icons/Share.imageset/share.pdf b/elpha-ios/Assets.xcassets/Icons/Share.imageset/share.pdf new file mode 100644 index 0000000..d9a5758 Binary files /dev/null and b/elpha-ios/Assets.xcassets/Icons/Share.imageset/share.pdf differ diff --git a/elpha-ios/Assets.xcassets/New Folder/Contents.json b/elpha-ios/Assets.xcassets/New Folder/Contents.json deleted file mode 100644 index da4a164..0000000 --- a/elpha-ios/Assets.xcassets/New Folder/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/elpha-ios/AttachmentViewController.swift b/elpha-ios/AttachmentViewController.swift index 191335f..692f93c 100644 --- a/elpha-ios/AttachmentViewController.swift +++ b/elpha-ios/AttachmentViewController.swift @@ -9,30 +9,34 @@ import UIKit class AttachmentViewController: UIViewController { + @IBOutlet var attachmentScrollView: UIScrollView! @IBOutlet var attachmentImageView: UIImageView! - @IBOutlet var statusLabel: UILabel! + @IBOutlet var statusTextView: UITextView! var attachment: AttachmentMO? = nil + @IBAction func closeTapped(_ sender: Any) { + if let controller = self.parent as? AttachmentPageViewController { + controller.dismissController() + } + } + + @IBAction func shareTapped(_ sender: Any) { + if let image = attachmentImageView.image { + let controller = UIActivityViewController(activityItems: [image], applicationActivities: nil) + present(controller, animated: true) + } + } + override func viewDidLoad() { super.viewDidLoad() if let attachment = attachment { + attachmentScrollView.delegate = self attachmentImageView.af_setImage(withURL: attachment.url!) if let content = attachment.status?.content { - do { - let styledContent = " \(content)" - let attributedText = try NSAttributedString( - data: styledContent.data(using: String.Encoding.unicode, allowLossyConversion: true)!, - options: [.documentType: NSAttributedString.DocumentType.html], - documentAttributes: nil - ) - - statusLabel.attributedText = attributedText - } catch { - print("\(error)") - } + statusTextView.attributedText = content.htmlAttributed(size: 14, centered: true, color: UIColor.white) } } } @@ -40,10 +44,10 @@ class AttachmentViewController: UIViewController { override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } - - @IBAction func imageSwiped(_ sender: Any) { - if let controller = self.parent as? AttachmentPageViewController { - controller.dismissController() - } +} + +extension AttachmentViewController: UIScrollViewDelegate { + func viewForZooming(in scrollView: UIScrollView) -> UIView? { + return attachmentImageView } } diff --git a/elpha-ios/Base.lproj/Main.storyboard b/elpha-ios/Base.lproj/Main.storyboard index b11de00..11522f3 100644 --- a/elpha-ios/Base.lproj/Main.storyboard +++ b/elpha-ios/Base.lproj/Main.storyboard @@ -1232,35 +1232,73 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + + + + - - - - - - - + + + + + + + + + + + @@ -1277,20 +1315,21 @@ - + + - + - + - - + + - + - + @@ -1350,10 +1389,12 @@ + - + + @@ -1363,7 +1404,7 @@ - + diff --git a/elpha-ios/StatusTableViewController.swift b/elpha-ios/StatusTableViewController.swift index b86c035..a3f1757 100644 --- a/elpha-ios/StatusTableViewController.swift +++ b/elpha-ios/StatusTableViewController.swift @@ -253,7 +253,7 @@ extension StatusTableViewController { if let account = status.account { cell.avatarImageView.af_setImage(withURL: account.avatarURL!, filter: avatarFilter) cell.displayNameLabel.text = account.displayName - cell.usernameLabel.text = account.acct + cell.usernameLabel.text = "@\(account.acct!)" } } @@ -264,18 +264,7 @@ extension StatusTableViewController { } if let content = status.content { - do { - let styledContent = " \(content)" - let attributedText = try NSAttributedString( - data: styledContent.data(using: String.Encoding.unicode, allowLossyConversion: true)!, - options: [.documentType: NSAttributedString.DocumentType.html], - documentAttributes: nil - ) - - cell.contentLabel.attributedText = attributedText - } catch { - print("\(error)") - } + cell.contentLabel.attributedText = content.htmlAttributed(size: 16) } cell.attachmentsView.backgroundColor = UIColor.white diff --git a/elpha-ios/StatusView.swift b/elpha-ios/StatusView.swift index d1f92fa..111828c 100644 --- a/elpha-ios/StatusView.swift +++ b/elpha-ios/StatusView.swift @@ -231,7 +231,7 @@ class StatusView: UIView { if let account = status.account { avatarImageView.af_setImage(withURL: account.avatarURL!, filter: avatarFilter) displayNameLabel.text = account.displayName - usernameLabel.text = account.acct + usernameLabel.text = "@\(account.acct!)" } if let attachments = status.attachments, attachments.count > 0 { @@ -240,14 +240,7 @@ class StatusView: UIView { } if let content = status.content { -// let linkAttributes: [NSAttributedString.Key : Any] = [ -// NSAttributedString.Key.foregroundColor: UIColor(named: "Primary")!, -// NSAttributedString.Key.underlineColor: UIColor(named: "Primary")!, -// NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single, -// ] - contentTextView.attributedText = content.htmlAttributed(size: 15.0) - //contentTextView.linkTextAttributes = linkAttributes if status.hidden && spoilerView == nil { let spoilerText = UILabel(frame: contentTextView.frame) @@ -321,7 +314,7 @@ class StatusView: UIView { if let account = status.account { boostAvatarImageView.af_setImage(withURL: account.avatarURL!, filter: avatarFilter) boostDisplayNameLabel.text = account.displayName - boostUsernameLabel.text = account.acct + boostUsernameLabel.text = "@\(account.acct!)" } updateStatusContent(reblog) @@ -329,7 +322,7 @@ class StatusView: UIView { if let account = status.account { avatarImageView.af_setImage(withURL: account.avatarURL!, filter: avatarFilter) displayNameLabel.text = account.displayName - usernameLabel.text = account.acct + usernameLabel.text = "@\(account.acct!)" } updateStatusContent(status) @@ -340,7 +333,7 @@ class StatusView: UIView { replyView.isHidden = false replyAvatarImageView.af_setImage(withURL: replyAccount.avatarURL!, filter: avatarFilter) replyDisplayNameLabel.text = replyAccount.displayName - replyUsernameLabel.text = replyAccount.acct + replyUsernameLabel.text = "@\(replyAccount.acct!)" } } } diff --git a/elpha-ios/StatusView.xib b/elpha-ios/StatusView.xib index c05c51f..b9d5ec8 100644 --- a/elpha-ios/StatusView.xib +++ b/elpha-ios/StatusView.xib @@ -44,11 +44,11 @@ - + - + @@ -224,7 +224,7 @@ - + @@ -266,8 +266,8 @@ - - + + @@ -292,14 +292,14 @@ - + - + @@ -454,7 +454,7 @@ - + @@ -484,7 +484,7 @@ - + @@ -508,7 +508,7 @@ - + @@ -569,7 +569,7 @@ - + diff --git a/elpha-ios/String+HtmlAttributed.swift b/elpha-ios/String+HtmlAttributed.swift index 9dc2e70..0eff2a1 100644 --- a/elpha-ios/String+HtmlAttributed.swift +++ b/elpha-ios/String+HtmlAttributed.swift @@ -9,14 +9,16 @@ import UIKit extension String { - func htmlAttributed(size: CGFloat, centered: Bool = false) -> NSAttributedString? { + func htmlAttributed(size: CGFloat, centered: Bool = false, color: UIColor? = nil) -> NSAttributedString? { + let color = color ?? UIColor(named: "Text")! + do { let htmlString = """ diff --git a/elpha-ios/UITextViewFixed.swift b/elpha-ios/UITextViewFixed.swift new file mode 100644 index 0000000..283a068 --- /dev/null +++ b/elpha-ios/UITextViewFixed.swift @@ -0,0 +1,18 @@ +// +// UITextViewFixed.swift +// elpha-ios +// +// Created by Dwayne Harris on 11/6/18. +// Copyright © 2018 Elpha. All rights reserved. +// + +import UIKit + +@IBDesignable class UITextViewFixed: UITextView { + override func layoutSubviews() { + super.layoutSubviews() + + textContainerInset = UIEdgeInsets.zero + textContainer.lineFragmentPadding = 0 + } +}