forked from shadowfacts/Tusker
Start progress view
This commit is contained in:
parent
186e2d7520
commit
a1cd9496e9
|
@ -7,6 +7,8 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
04409A082142AC3800341FA7 /* ProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04409A072142AC3800341FA7 /* ProgressView.swift */; };
|
||||||
|
04409A0A2142AD8000341FA7 /* SteppedProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04409A092142AD8000341FA7 /* SteppedProgressView.swift */; };
|
||||||
04DACE8A212CA6B7009840C4 /* Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE89212CA6B7009840C4 /* Timeline.swift */; };
|
04DACE8A212CA6B7009840C4 /* Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE89212CA6B7009840C4 /* Timeline.swift */; };
|
||||||
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE8B212CB14B009840C4 /* MainTabBarViewController.swift */; };
|
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE8B212CB14B009840C4 /* MainTabBarViewController.swift */; };
|
||||||
04DACE8E212CC7CC009840C4 /* AvatarCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE8D212CC7CC009840C4 /* AvatarCache.swift */; };
|
04DACE8E212CC7CC009840C4 /* AvatarCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DACE8D212CC7CC009840C4 /* AvatarCache.swift */; };
|
||||||
|
@ -102,6 +104,8 @@
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
04409A072142AC3800341FA7 /* ProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = "<group>"; };
|
||||||
|
04409A092142AD8000341FA7 /* SteppedProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SteppedProgressView.swift; sourceTree = "<group>"; };
|
||||||
04DACE89212CA6B7009840C4 /* Timeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Timeline.swift; sourceTree = "<group>"; };
|
04DACE89212CA6B7009840C4 /* Timeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Timeline.swift; sourceTree = "<group>"; };
|
||||||
04DACE8B212CB14B009840C4 /* MainTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabBarViewController.swift; sourceTree = "<group>"; };
|
04DACE8B212CB14B009840C4 /* MainTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabBarViewController.swift; sourceTree = "<group>"; };
|
||||||
04DACE8D212CC7CC009840C4 /* AvatarCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarCache.swift; sourceTree = "<group>"; };
|
04DACE8D212CC7CC009840C4 /* AvatarCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarCache.swift; sourceTree = "<group>"; };
|
||||||
|
@ -367,6 +371,8 @@
|
||||||
D6C94D882139E6EC00CB5196 /* AttachmentView.swift */,
|
D6C94D882139E6EC00CB5196 /* AttachmentView.swift */,
|
||||||
D6333B762138D94E00CE884A /* ComposeMediaView.swift */,
|
D6333B762138D94E00CE884A /* ComposeMediaView.swift */,
|
||||||
D641C77E213DC78A004B4513 /* InlineTextAttachment.swift */,
|
D641C77E213DC78A004B4513 /* InlineTextAttachment.swift */,
|
||||||
|
04409A072142AC3800341FA7 /* ProgressView.swift */,
|
||||||
|
04409A092142AD8000341FA7 /* SteppedProgressView.swift */,
|
||||||
D641C78A213DD926004B4513 /* Status */,
|
D641C78A213DD926004B4513 /* Status */,
|
||||||
D641C78B213DD92F004B4513 /* Profile Header */,
|
D641C78B213DD92F004B4513 /* Profile Header */,
|
||||||
D641C78C213DD937004B4513 /* Notifications */,
|
D641C78C213DD937004B4513 /* Notifications */,
|
||||||
|
@ -611,6 +617,7 @@
|
||||||
D641C777213CAA9E004B4513 /* ActionNotificationTableViewCell.swift in Sources */,
|
D641C777213CAA9E004B4513 /* ActionNotificationTableViewCell.swift in Sources */,
|
||||||
D64D0AB12128D9AE005A6F37 /* OnboardingViewController.swift in Sources */,
|
D64D0AB12128D9AE005A6F37 /* OnboardingViewController.swift in Sources */,
|
||||||
D663626821360E2C00C9CBA2 /* PreferencesTableViewController.swift in Sources */,
|
D663626821360E2C00C9CBA2 /* PreferencesTableViewController.swift in Sources */,
|
||||||
|
04409A0A2142AD8000341FA7 /* SteppedProgressView.swift in Sources */,
|
||||||
D66362732136FFC600C9CBA2 /* UITextView+Placeholder.swift in Sources */,
|
D66362732136FFC600C9CBA2 /* UITextView+Placeholder.swift in Sources */,
|
||||||
D66362752137068A00C9CBA2 /* Visibility+Helpers.swift in Sources */,
|
D66362752137068A00C9CBA2 /* Visibility+Helpers.swift in Sources */,
|
||||||
D646C95A213B5D0500269FB5 /* LargeImageInteractionController.swift in Sources */,
|
D646C95A213B5D0500269FB5 /* LargeImageInteractionController.swift in Sources */,
|
||||||
|
@ -624,6 +631,7 @@
|
||||||
D663625F2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift in Sources */,
|
D663625F2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift in Sources */,
|
||||||
D667E5E721349D4C0057A976 /* ProfileTableViewController.swift in Sources */,
|
D667E5E721349D4C0057A976 /* ProfileTableViewController.swift in Sources */,
|
||||||
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,
|
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,
|
||||||
|
04409A082142AC3800341FA7 /* ProgressView.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,19 +141,36 @@
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="trailing" secondItem="WID-nQ-ZzS" secondAttribute="trailing" constant="16" id="0Sy-jt-Ddv"/>
|
<constraint firstAttribute="trailing" secondItem="WID-nQ-ZzS" secondAttribute="trailing" constant="16" id="0Sy-jt-Ddv"/>
|
||||||
<constraint firstItem="bGo-tx-r56" firstAttribute="height" secondItem="L3H-aB-fGr" secondAttribute="height" constant="-68" id="5Xh-ao-jAN"/>
|
<constraint firstItem="bGo-tx-r56" firstAttribute="height" secondItem="L3H-aB-fGr" secondAttribute="height" constant="-78" id="5Xh-ao-jAN"/>
|
||||||
<constraint firstItem="WID-nQ-ZzS" firstAttribute="leading" secondItem="L3H-aB-fGr" secondAttribute="leading" constant="16" id="8Aw-l2-092"/>
|
<constraint firstItem="WID-nQ-ZzS" firstAttribute="leading" secondItem="L3H-aB-fGr" secondAttribute="leading" constant="16" id="8Aw-l2-092"/>
|
||||||
<constraint firstItem="WID-nQ-ZzS" firstAttribute="top" secondItem="L3H-aB-fGr" secondAttribute="top" constant="16" id="CYg-ft-CAr"/>
|
<constraint firstItem="WID-nQ-ZzS" firstAttribute="top" secondItem="L3H-aB-fGr" secondAttribute="top" constant="16" id="CYg-ft-CAr"/>
|
||||||
<constraint firstAttribute="bottom" secondItem="WID-nQ-ZzS" secondAttribute="bottom" id="yTD-d9-Cr8"/>
|
<constraint firstAttribute="bottom" secondItem="WID-nQ-ZzS" secondAttribute="bottom" id="yTD-d9-Cr8"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</scrollView>
|
</scrollView>
|
||||||
|
<view contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YEm-sV-aLt" customClass="SteppedProgressView" customModule="Tusker" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="64" width="375" height="10"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" constant="5" id="inZ-C1-b96"/>
|
||||||
|
</constraints>
|
||||||
|
<userDefinedRuntimeAttributes>
|
||||||
|
<userDefinedRuntimeAttribute type="number" keyPath="steps">
|
||||||
|
<integer key="value" value="2"/>
|
||||||
|
</userDefinedRuntimeAttribute>
|
||||||
|
<userDefinedRuntimeAttribute type="number" keyPath="currentStep">
|
||||||
|
<integer key="value" value="1"/>
|
||||||
|
</userDefinedRuntimeAttribute>
|
||||||
|
</userDefinedRuntimeAttributes>
|
||||||
|
</view>
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="L3H-aB-fGr" firstAttribute="leading" secondItem="qto-r6-ocp" secondAttribute="leading" id="01l-qs-Ff4"/>
|
<constraint firstItem="L3H-aB-fGr" firstAttribute="leading" secondItem="qto-r6-ocp" secondAttribute="leading" id="01l-qs-Ff4"/>
|
||||||
<constraint firstItem="L3H-aB-fGr" firstAttribute="top" secondItem="qto-r6-ocp" secondAttribute="topMargin" constant="-64" id="7BB-7k-gaN"/>
|
<constraint firstItem="L3H-aB-fGr" firstAttribute="top" secondItem="qto-r6-ocp" secondAttribute="topMargin" constant="-64" id="7BB-7k-gaN"/>
|
||||||
<constraint firstItem="WID-nQ-ZzS" firstAttribute="width" secondItem="qto-r6-ocp" secondAttribute="width" constant="-32" id="Fer-8I-o1H"/>
|
<constraint firstItem="WID-nQ-ZzS" firstAttribute="width" secondItem="qto-r6-ocp" secondAttribute="width" constant="-32" id="Fer-8I-o1H"/>
|
||||||
|
<constraint firstItem="YEm-sV-aLt" firstAttribute="top" secondItem="7ws-AM-scc" secondAttribute="top" id="Hbc-XF-3kW"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="L3H-aB-fGr" secondAttribute="trailing" id="NWJ-dh-7ED"/>
|
<constraint firstAttribute="trailing" secondItem="L3H-aB-fGr" secondAttribute="trailing" id="NWJ-dh-7ED"/>
|
||||||
|
<constraint firstItem="YEm-sV-aLt" firstAttribute="leading" secondItem="7ws-AM-scc" secondAttribute="leading" id="Zbh-7Q-t0V"/>
|
||||||
|
<constraint firstItem="7ws-AM-scc" firstAttribute="trailing" secondItem="YEm-sV-aLt" secondAttribute="trailing" id="b9h-V2-Fgf"/>
|
||||||
<constraint firstItem="7ws-AM-scc" firstAttribute="bottom" secondItem="L3H-aB-fGr" secondAttribute="bottom" id="uZs-Y8-hGM"/>
|
<constraint firstItem="7ws-AM-scc" firstAttribute="bottom" secondItem="L3H-aB-fGr" secondAttribute="bottom" id="uZs-Y8-hGM"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<viewLayoutGuide key="safeArea" id="7ws-AM-scc"/>
|
<viewLayoutGuide key="safeArea" id="7ws-AM-scc"/>
|
||||||
|
@ -175,6 +192,7 @@
|
||||||
<outlet property="inReplyToUsernameLabel" destination="neM-1F-PcJ" id="Lej-ut-yp9"/>
|
<outlet property="inReplyToUsernameLabel" destination="neM-1F-PcJ" id="Lej-ut-yp9"/>
|
||||||
<outlet property="mediaStackView" destination="gcH-tf-prn" id="oM2-hc-rXY"/>
|
<outlet property="mediaStackView" destination="gcH-tf-prn" id="oM2-hc-rXY"/>
|
||||||
<outlet property="paddingView" destination="VuB-eX-IiL" id="wDo-4O-g30"/>
|
<outlet property="paddingView" destination="VuB-eX-IiL" id="wDo-4O-g30"/>
|
||||||
|
<outlet property="postProgressView" destination="YEm-sV-aLt" id="7V1-fd-Tuu"/>
|
||||||
<outlet property="scrollView" destination="L3H-aB-fGr" id="kbS-H5-K2I"/>
|
<outlet property="scrollView" destination="L3H-aB-fGr" id="kbS-H5-K2I"/>
|
||||||
<outlet property="statusTextView" destination="gQU-rc-mM7" id="FVL-nk-159"/>
|
<outlet property="statusTextView" destination="gQU-rc-mM7" id="FVL-nk-159"/>
|
||||||
<outlet property="visibilityButton" destination="caP-6L-HWj" id="89p-Bl-cRH"/>
|
<outlet property="visibilityButton" destination="caP-6L-HWj" id="89p-Bl-cRH"/>
|
||||||
|
|
|
@ -31,6 +31,7 @@ class ComposeViewController: UIViewController {
|
||||||
@IBOutlet weak var contentWarningTextField: UITextField!
|
@IBOutlet weak var contentWarningTextField: UITextField!
|
||||||
@IBOutlet weak var mediaStackView: UIStackView!
|
@IBOutlet weak var mediaStackView: UIStackView!
|
||||||
@IBOutlet weak var paddingView: UIView!
|
@IBOutlet weak var paddingView: UIView!
|
||||||
|
@IBOutlet weak var postProgressView: SteppedProgressView!
|
||||||
|
|
||||||
var scrolled = false
|
var scrolled = false
|
||||||
|
|
||||||
|
@ -98,6 +99,8 @@ class ComposeViewController: UIViewController {
|
||||||
statusTextView.text += "@\(mentioning.acct) "
|
statusTextView.text += "@\(mentioning.acct) "
|
||||||
statusTextView.textViewDidChange(statusTextView)
|
statusTextView.textViewDidChange(statusTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postProgressView.progress = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidLayoutSubviews() {
|
override func viewDidLayoutSubviews() {
|
||||||
|
@ -191,6 +194,9 @@ class ComposeViewController: UIViewController {
|
||||||
|
|
||||||
let visibility = self.visibility
|
let visibility = self.visibility
|
||||||
|
|
||||||
|
postProgressView.steps = 2
|
||||||
|
postProgressView.currentStep = 1
|
||||||
|
|
||||||
var attachments: [Attachment?] = []
|
var attachments: [Attachment?] = []
|
||||||
let group = DispatchGroup()
|
let group = DispatchGroup()
|
||||||
for view in mediaStackView.arrangedSubviews {
|
for view in mediaStackView.arrangedSubviews {
|
||||||
|
@ -204,10 +210,13 @@ class ComposeViewController: UIViewController {
|
||||||
MastodonController.shared.client.run(req) { result in
|
MastodonController.shared.client.run(req) { result in
|
||||||
guard case let .success(attachment, _) = result else { fatalError() }
|
guard case let .success(attachment, _) = result else { fatalError() }
|
||||||
attachments[index] = attachment
|
attachments[index] = attachment
|
||||||
|
self.postProgressView.step()
|
||||||
group.leave()
|
group.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postProgressView.steps += attachments.count
|
||||||
|
|
||||||
group.notify(queue: .main) {
|
group.notify(queue: .main) {
|
||||||
let mediaIDs = attachments.map { $0!.id }
|
let mediaIDs = attachments.map { $0!.id }
|
||||||
|
|
||||||
|
@ -222,6 +231,7 @@ class ComposeViewController: UIViewController {
|
||||||
guard case let .success(status, _) = result else { fatalError() }
|
guard case let .success(status, _) = result else { fatalError() }
|
||||||
self.status = status
|
self.status = status
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
self.postProgressView.step()
|
||||||
self.performSegue(withIdentifier: "postComplete", sender: self)
|
self.performSegue(withIdentifier: "postComplete", sender: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// ProgressView.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/7/18.
|
||||||
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@IBDesignable
|
||||||
|
class ProgressView: UIView {
|
||||||
|
|
||||||
|
@IBInspectable var progress: CGFloat = 0 {
|
||||||
|
didSet {
|
||||||
|
updateSublayer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var shapeLayer: CAShapeLayer!
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
super.init(coder: aDecoder)
|
||||||
|
updateSublayer()
|
||||||
|
}
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
updateSublayer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateSublayer() {
|
||||||
|
if shapeLayer == nil {
|
||||||
|
shapeLayer = CAShapeLayer()
|
||||||
|
shapeLayer.fillColor = tintColor.cgColor
|
||||||
|
layer.addSublayer(shapeLayer)
|
||||||
|
}
|
||||||
|
let rect = CGRect(x: 0, y: 0, width: frame.width * progress, height: frame.height)
|
||||||
|
shapeLayer.path = CGPath(rect: rect, transform: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func layoutSubviews() {
|
||||||
|
updateSublayer()
|
||||||
|
super.layoutSubviews()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
//
|
||||||
|
// SteppedProgressView.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 9/7/18.
|
||||||
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@IBDesignable
|
||||||
|
class SteppedProgressView: ProgressView {
|
||||||
|
|
||||||
|
@IBInspectable var steps: Int = 0
|
||||||
|
@IBInspectable var currentStep: Int = 0 {
|
||||||
|
didSet {
|
||||||
|
progress = CGFloat(currentStep) / CGFloat(steps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
super.init(coder: aDecoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
override init(frame: CGRect) {
|
||||||
|
super.init(frame: frame)
|
||||||
|
}
|
||||||
|
|
||||||
|
func step() {
|
||||||
|
if currentStep < steps {
|
||||||
|
currentStep += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue