Skip to content

Commit 0baffc9

Browse files
authored
Merge pull request #478 from Hirobreak/more-options
More Options Interface
2 parents 1f2e0cd + c3759b3 commit 0baffc9

33 files changed

+803
-1086
lines changed

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
binary "./realm-cocoa.json" "3.15.0"
1+
binary "./realm-cocoa.json" "3.17.1"
22
github "1024jp/GzipSwift" "5.0.0"
33
github "Alamofire/Alamofire" "4.8.2"
44
github "CosmicMind/Material" "3.1.1"

ShareExtension/Base.lproj/ComposerUIView.xib

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait">
3+
<device id="retina5_9" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
@@ -17,6 +17,7 @@
1717
<objects>
1818
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ComposerUIView" customModule="ShareExtension" customModuleProvider="target">
1919
<connections>
20+
<outlet property="accountOptionsView" destination="Xhg-3J-MBr" id="ZRs-7l-3O1"/>
2021
<outlet property="arrowButton" destination="6aJ-Qs-ku0" id="F0l-yj-ih6"/>
2122
<outlet property="attachmentTableHeightConstraint" destination="xQx-hv-vhL" id="pvS-zx-1bG"/>
2223
<outlet property="attachmentsTableView" destination="lgr-7H-82B" id="WLD-xn-Vxr"/>
@@ -29,7 +30,6 @@
2930
<outlet property="editorView" destination="y6r-pP-m3L" id="9Y7-cZ-5G3"/>
3031
<outlet property="fromButton" destination="oRl-O7-iXF" id="zaY-xe-S9R"/>
3132
<outlet property="fromField" destination="6e0-4U-xWw" id="LJW-Dw-Xnf"/>
32-
<outlet property="fromMenuView" destination="1F4-6H-0U3" id="sFm-wX-BiV"/>
3333
<outlet property="navigationBar" destination="SlT-XZ-Wvh" id="Yxs-dh-sH5"/>
3434
<outlet property="navigationItem" destination="lGj-g1-km4" id="MXd-qv-hlN"/>
3535
<outlet property="scrollView" destination="1os-vN-Gop" id="agd-Rk-FeK"/>
@@ -41,12 +41,12 @@
4141
</connections>
4242
</placeholder>
4343
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
44-
<view contentMode="scaleToFill" id="iN0-l3-epB">
45-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
44+
<view opaque="NO" contentMode="scaleToFill" id="iN0-l3-epB">
45+
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
4646
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
4747
<subviews>
4848
<navigationBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SlT-XZ-Wvh">
49-
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
49+
<rect key="frame" x="0.0" y="44" width="375" height="44"/>
5050
<constraints>
5151
<constraint firstAttribute="height" constant="44" id="4A0-Ov-DwR"/>
5252
</constraints>
@@ -69,7 +69,7 @@
6969
</items>
7070
</navigationBar>
7171
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1os-vN-Gop">
72-
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
72+
<rect key="frame" x="0.0" y="88" width="375" height="724"/>
7373
<subviews>
7474
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1gj-Gv-XTk">
7575
<rect key="frame" x="0.0" y="0.0" width="375" height="45"/>
@@ -210,24 +210,23 @@
210210
<constraint firstItem="ORb-mH-PWG" firstAttribute="top" secondItem="cWv-qE-xQG" secondAttribute="bottom" id="yk0-BH-3zG"/>
211211
</constraints>
212212
</scrollView>
213-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1F4-6H-0U3" customClass="BottomMenuView" customModule="ShareExtension" customModuleProvider="target">
214-
<rect key="frame" x="0.0" y="110" width="375" height="557"/>
215-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
216-
<viewLayoutGuide key="safeArea" id="TMS-N3-rTC"/>
213+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xhg-3J-MBr" customClass="MoreOptionsUIView" customModule="ShareExtension" customModuleProvider="target">
214+
<rect key="frame" x="0.0" y="134" width="375" height="678"/>
215+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
217216
</view>
218217
</subviews>
219-
<color key="backgroundColor" red="0.21568627450980393" green="0.22745098039215686" blue="0.27058823529411763" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
218+
<color key="backgroundColor" red="0.21642738580000001" green="0.22670188550000001" blue="0.26275038719999999" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
220219
<constraints>
221220
<constraint firstItem="SlT-XZ-Wvh" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="22a-pg-RcV"/>
222-
<constraint firstItem="1F4-6H-0U3" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="EPa-p7-yOs"/>
221+
<constraint firstItem="Xhg-3J-MBr" firstAttribute="top" secondItem="SlT-XZ-Wvh" secondAttribute="bottom" constant="46" id="8Sy-Pr-PHa"/>
222+
<constraint firstAttribute="bottom" secondItem="1os-vN-Gop" secondAttribute="bottom" id="9pv-hQ-YtT"/>
223223
<constraint firstItem="1os-vN-Gop" firstAttribute="trailing" secondItem="SlT-XZ-Wvh" secondAttribute="trailing" id="G2O-oe-fzI"/>
224224
<constraint firstItem="SlT-XZ-Wvh" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="JI8-6p-6UZ"/>
225225
<constraint firstItem="SlT-XZ-Wvh" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="O0D-48-Pba"/>
226-
<constraint firstItem="1F4-6H-0U3" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="RKn-8T-aSY"/>
227226
<constraint firstItem="1os-vN-Gop" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="WTx-EM-B1X"/>
228-
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="1F4-6H-0U3" secondAttribute="bottom" id="YBZ-e2-TeT"/>
229-
<constraint firstItem="1F4-6H-0U3" firstAttribute="top" secondItem="SlT-XZ-Wvh" secondAttribute="bottom" constant="46" id="YOH-IB-YIV"/>
230-
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="1os-vN-Gop" secondAttribute="bottom" id="nSC-mW-Jrg"/>
227+
<constraint firstAttribute="bottom" secondItem="Xhg-3J-MBr" secondAttribute="bottom" id="Y9a-je-Qh8"/>
228+
<constraint firstAttribute="trailing" secondItem="Xhg-3J-MBr" secondAttribute="trailing" id="b8Q-pq-Ybf"/>
229+
<constraint firstItem="Xhg-3J-MBr" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="dYX-aW-NAq"/>
231230
<constraint firstItem="1os-vN-Gop" firstAttribute="leading" secondItem="SlT-XZ-Wvh" secondAttribute="leading" id="umT-Qd-fHZ"/>
232231
<constraint firstItem="1os-vN-Gop" firstAttribute="top" secondItem="SlT-XZ-Wvh" secondAttribute="top" constant="44" id="y6f-tg-QLw"/>
233232
</constraints>
@@ -238,6 +237,6 @@
238237
<resources>
239238
<image name="close-rounded" width="14" height="14"/>
240239
<image name="icon-down" width="13" height="8"/>
241-
<image name="send" width="23" height="20"/>
240+
<image name="send" width="26.333333969116211" height="23"/>
242241
</resources>
243242
</document>

ShareExtension/ComposerUIView.swift

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ComposerUIView: UIView {
3333

3434
@IBOutlet weak var fromField: UILabel!
3535
@IBOutlet weak var fromButton: UIButton!
36-
@IBOutlet weak var fromMenuView: BottomMenuView!
36+
@IBOutlet weak var accountOptionsView: MoreOptionsUIView!
3737

3838
@IBOutlet weak var separatorView: UIView!
3939
@IBOutlet weak var arrowButton: UIButton!
@@ -61,6 +61,7 @@ class ComposerUIView: UIView {
6161
var collapsed = false
6262
weak var myAccount: Account!
6363
var checkedDomains: [String: Bool] = Utils.defaultDomains
64+
var accountOptionsInterface: AccountOptionsInterface?
6465

6566
var theme: Theme {
6667
return ThemeManager.shared.theme
@@ -98,7 +99,6 @@ class ComposerUIView: UIView {
9899

99100
toField.becomeFirstResponder()
100101

101-
fromMenuView.delegate = self
102102
applyTheme()
103103
}
104104

@@ -136,22 +136,25 @@ class ComposerUIView: UIView {
136136
navigationBar.isTranslucent = false
137137
}
138138

139-
func setFrom(account: Account, emails: [String]) {
140-
fromButton.isHidden = emails.count == 0
139+
func setFrom(account: Account) {
140+
let accounts = Array(SharedDB.getAccounts(ignore: account.compoundKey))
141+
fromButton.isHidden = accounts.count == 0
141142
let attributedFrom = NSMutableAttributedString(string: "\(String.localize("FROM")): ", attributes: [.font: Font.bold.size(15)!])
142143
let attributedEmail = NSAttributedString(string: account.email, attributes: [.font: Font.regular.size(15)!])
143144
attributedFrom.append(attributedEmail)
144-
fromMenuView.isUserInteractionEnabled = false
145-
fromMenuView.initialLoad(options: emails)
145+
146146
fromField.attributedText = attributedFrom
147147
fromButton.setImage(UIImage(named: "icon-down"), for: .normal)
148+
149+
accountOptionsInterface = AccountOptionsInterface(accounts: accounts)
150+
accountOptionsInterface?.delegate = self
151+
accountOptionsView.setDelegate(newDelegate: accountOptionsInterface!)
148152
self.myAccount = account
149153
}
150154

151155
@IBAction func didPressFrom(_ sender: Any) {
152-
fromMenuView.isUserInteractionEnabled = true
153-
fromMenuView.toggleMenu(true)
154156
fromButton.setImage(UIImage(named: "icon-up"), for: .normal)
157+
accountOptionsView.showMoreOptions()
155158

156159
self.toField.endEditing()
157160
self.ccField.endEditing()
@@ -325,7 +328,7 @@ extension ComposerUIView: CLTokenInputViewDelegate {
325328

326329
func tokenInputViewDidEndEditing(_ view: CLTokenInputView) {
327330

328-
//self.contactTableView.isHidden = true
331+
self.contactsTableView.isHidden = true
329332

330333
guard let text = view.text, text.count > 0 else {
331334
return
@@ -343,14 +346,18 @@ extension ComposerUIView: CLTokenInputViewDelegate {
343346
}
344347
}
345348

346-
extension ComposerUIView: BottomMenuDelegate {
347-
func didPressOption(_ option: String) {
348-
delegate?.setAccount(accountId: option)
349+
extension ComposerUIView: AccountOptionsInterfaceDelegate {
350+
func onClose() {
351+
fromButton.setImage(UIImage(named: "icon-down"), for: .normal)
352+
accountOptionsView.closeMoreOptions()
349353
}
350354

351-
func didPressBackground() {
352-
fromMenuView.isUserInteractionEnabled = false
353-
self.fromMenuView.toggleMenu(false)
355+
func accountSelected(account: Account) {
354356
fromButton.setImage(UIImage(named: "icon-down"), for: .normal)
357+
accountOptionsView.closeMoreOptions()
358+
guard !account.isInvalidated else {
359+
return
360+
}
361+
self.setFrom(account: account)
355362
}
356363
}

ShareExtension/ShareViewController.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@ class ShareViewController: UIViewController {
6060
self.view.backgroundColor = theme.overallBackground
6161
}
6262

63+
override func viewDidAppear(_ animated: Bool) {
64+
super.viewDidAppear(animated)
65+
composerUIView.accountOptionsView.refreshView()
66+
}
67+
6368
func setFrom(account: Account) {
64-
let accounts = SharedDB.getAccounts(ignore: account.username)
65-
let emails = Array(accounts.map({$0.email}))
6669
myAccount = account
67-
68-
composerUIView.setFrom(account: account, emails: emails)
70+
fileManager.myAccount = myAccount
71+
composerUIView.setFrom(account: account)
6972
}
7073

7174
func shouldShowPinLock() -> Bool {

0 commit comments

Comments
 (0)