Skip to content

Commit aa92659

Browse files
committed
Add request SKStoreReviewController; add AnalyticsManger.shared.sendFeedback; add keyboard observer #720.
1 parent 0d7e985 commit aa92659

File tree

8 files changed

+140
-14
lines changed

8 files changed

+140
-14
lines changed

Commun.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
B101CB6823E4631B00269253 /* ShareExtensionData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B101CB6723E4631B00269253 /* ShareExtensionData.swift */; };
160160
B101CB6B23E4634900269253 /* ShareExtensionData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B101CB6723E4631B00269253 /* ShareExtensionData.swift */; };
161161
B10DB961240F8789001BD0E4 /* CMAppLikeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10DB960240F8789001BD0E4 /* CMAppLikeView.swift */; };
162+
B10DB96B240FB99B001BD0E4 /* CMFeedbackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B10DB96A240FB99B001BD0E4 /* CMFeedbackViewController.swift */; };
162163
B16EF85623EADCA2002C2050 /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3C8B83234779FE00D8BADB /* UIImage.swift */; };
163164
B170AC15228AFBDA00C6FFBC /* SignUpVC.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5797E0F9225DDA490026C4D5 /* SignUpVC.storyboard */; };
164165
B17A970C228002440081B8E0 /* SignUpRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17A970B228002440081B8E0 /* SignUpRouter.swift */; };
@@ -729,6 +730,7 @@
729730
AE43B2305FC441D96462E0AB /* Pods-Commun.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Commun.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Commun/Pods-Commun.debug.xcconfig"; sourceTree = "<group>"; };
730731
B101CB6723E4631B00269253 /* ShareExtensionData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareExtensionData.swift; sourceTree = "<group>"; };
731732
B10DB960240F8789001BD0E4 /* CMAppLikeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMAppLikeView.swift; sourceTree = "<group>"; };
733+
B10DB96A240FB99B001BD0E4 /* CMFeedbackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMFeedbackViewController.swift; sourceTree = "<group>"; };
732734
B12684EF22C1E56B0046C838 /* Commun.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Commun.entitlements; sourceTree = "<group>"; };
733735
B17A970B228002440081B8E0 /* SignUpRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpRouter.swift; sourceTree = "<group>"; };
734736
B17BE49823FD6203004C6440 /* CMHint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMHint.swift; sourceTree = "<group>"; };
@@ -1354,6 +1356,7 @@
13541356
children = (
13551357
3BB32F1423438C1F006572F3 /* CommunActionSheet */,
13561358
3BC613AB23420FFC00075570 /* SwipeDownToDismissViewController */,
1359+
B10DB96A240FB99B001BD0E4 /* CMFeedbackViewController.swift */,
13571360
);
13581361
path = UIViewControllers;
13591362
sourceTree = "<group>";
@@ -3583,6 +3586,7 @@
35833586
BC597A6B238BBDAC00103F4F /* FittingSizePresentationController.swift in Sources */,
35843587
3B0686302346FFA6008953C5 /* CommunButton.swift in Sources */,
35853588
BC4AD66423B1C41C008546A4 /* TransferHistorySegmentedControl.swift in Sources */,
3589+
B10DB96B240FB99B001BD0E4 /* CMFeedbackViewController.swift in Sources */,
35863590
3BB342B422CA7412009546B2 /* CreateBioVC.swift in Sources */,
35873591
3BB32F1923438D4F006572F3 /* DimmingPresentationController.swift in Sources */,
35883592
3B5CB30522A5752100757533 /* ListViewModelType.swift in Sources */,

Commun/Controllers/PostPageVC/PostPageVC.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class PostPageVC: CommentsViewController {
4848
// MARK: - Life cycle
4949
override func viewWillAppear(_ animated: Bool) {
5050
super.viewWillAppear(animated)
51+
5152
navigationController?.setNavigationBarHidden(true, animated: animated)
5253
tabBarController?.tabBar.isHidden = true
5354

Commun/Controllers/WalletVC/ViewControllers/WalletSendPoints/WalletSendPointsVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class WalletSendPointsVC: BaseViewController {
420420
}
421421

422422
let nc = BaseNavigationController(rootViewController: friendsListVC)
423-
present(nc, animated: true, completion: nil)
423+
present(nc, animated: true, completion: nil)
424424
}
425425

426426
@objc func clearButtonTapped(_ sender: UIButton) {

Commun/Controllers/WelcomeScreenVC/WelcomeVC.storyboard

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,9 @@
8787
<constraint firstAttribute="width" constant="35" id="aJj-KX-Fpr"/>
8888
</constraints>
8989
</imageView>
90-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="79b-EL-6JX">
91-
<rect key="frame" x="9" y="13" width="46" height="30"/>
92-
<state key="normal" title="Button"/>
93-
<connections>
94-
<action selector="tapped:" destination="5Vs-ev-2DK" eventType="touchUpInside" id="klf-ze-7yS"/>
95-
</connections>
96-
</button>
9790
</subviews>
9891
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
9992
<constraints>
100-
<constraint firstItem="79b-EL-6JX" firstAttribute="leading" secondItem="bF6-IB-5mY" secondAttribute="leading" constant="9" id="Pdu-Pc-ETg"/>
10193
<constraint firstItem="IfS-V6-9za" firstAttribute="top" secondItem="qQo-fb-NcH" secondAttribute="bottom" constant="14" id="S5D-R6-UkA" customClass="ScalableLayoutConstraint" customModule="Commun" customModuleProvider="target"/>
10294
<constraint firstItem="qQo-fb-NcH" firstAttribute="leading" secondItem="bF6-IB-5mY" secondAttribute="leading" id="Tjd-Cq-itW"/>
10395
<constraint firstItem="qQo-fb-NcH" firstAttribute="top" secondItem="oXF-w0-ktq" secondAttribute="top" id="UWO-ih-eU6" customClass="ScalableLayoutConstraint" customModule="Commun" customModuleProvider="target"/>
@@ -107,7 +99,6 @@
10799
<constraint firstItem="zIG-dP-Ewi" firstAttribute="centerY" secondItem="JZ3-e2-Mok" secondAttribute="centerY" id="g8S-fO-23r"/>
108100
<constraint firstItem="zIG-dP-Ewi" firstAttribute="centerX" secondItem="JZ3-e2-Mok" secondAttribute="centerX" constant="-106" id="jvu-nh-f2P"/>
109101
<constraint firstItem="bF6-IB-5mY" firstAttribute="bottom" secondItem="IfS-V6-9za" secondAttribute="bottom" constant="20" id="kDl-Ko-m8v" customClass="ScalableLayoutConstraint" customModule="Commun" customModuleProvider="target"/>
110-
<constraint firstItem="79b-EL-6JX" firstAttribute="top" secondItem="bF6-IB-5mY" secondAttribute="top" constant="13" id="ldq-aR-yfL"/>
111102
<constraint firstItem="qQo-fb-NcH" firstAttribute="trailing" secondItem="bF6-IB-5mY" secondAttribute="trailing" id="mLH-q0-tby"/>
112103
<constraint firstItem="bF6-IB-5mY" firstAttribute="trailing" secondItem="IfS-V6-9za" secondAttribute="trailing" constant="20" id="sit-PB-k0c" customClass="ScalableLayoutConstraint" customModule="Commun" customModuleProvider="target"/>
113104
</constraints>

Commun/Controllers/WelcomeScreenVC/WelcomeVC.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,4 @@ class WelcomeVC: UIViewController {
133133
self.welcomePageVC.showActionButtons(indexNext)
134134
self.pageControl.selectedIndex = indexNext
135135
}
136-
137-
@IBAction func tapped(_ sender: Any) {
138-
appLiked()
139-
}
140136
}

Commun/Extensions/UIViewController+Extensions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ extension UIViewController {
463463
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
464464
SKStoreReviewController.requestReview()
465465
}
466+
} else {
467+
let vc = CMFeedbackViewController()
468+
self.present(vc, animated: true, completion: nil)
466469
}
467470
})
468471
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
//
2+
// CMFeedbackViewController.swift
3+
// Commun
4+
//
5+
// Created by Sergey Monastyrskiy on 04.03.2020.
6+
// Copyright © 2020 Commun Limited. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import RxSwift
11+
12+
class CMFeedbackViewController: UIViewController {
13+
// MARK: - Properties
14+
let disposeBag = DisposeBag()
15+
lazy var closeButton = UIButton.close()
16+
let sendButton = CommunButton.default(height: .adaptive(height: 50.0), label: "send".localized().uppercaseFirst, isDisabled: true)
17+
18+
let titleLabel = UILabel.init(text: "feedback".localized().uppercaseFirst,
19+
font: .systemFont(ofSize: .adaptive(width: 15.0), weight: .bold),
20+
numberOfLines: 1,
21+
color: #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1))
22+
23+
lazy var textView: UITextView = {
24+
let textViewInstance = UITextView()
25+
textViewInstance.placeholder = "text view feedback placeholder".localized().uppercaseFirst
26+
textViewInstance.tune(withTextColors: blackWhiteColorPickers, font: .systemFont(ofSize: .adaptive(width: 17.0), weight: .regular), alignment: .left)
27+
28+
return textViewInstance
29+
}()
30+
31+
32+
// MARK: - Class Initialization
33+
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
34+
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
35+
36+
self.bind()
37+
self.setUp()
38+
}
39+
40+
required init?(coder: NSCoder) {
41+
fatalError("init(coder:) has not been implemented")
42+
}
43+
44+
deinit {
45+
Logger.log(message: "Success", event: .severe)
46+
}
47+
48+
49+
// MARK: - Class Functions
50+
override func viewDidLoad() {
51+
super.viewDidLoad()
52+
53+
// Do any additional setup after loading the view.
54+
}
55+
56+
57+
// MARK: - Custom Functions
58+
private func bind() {
59+
let tap = UITapGestureRecognizer(target: self, action: #selector(viewTapped))
60+
view.addGestureRecognizer(tap)
61+
62+
self.textView.rx.didChange
63+
.map { self.textView.text }
64+
.filter { $0 != nil }
65+
.map { $0! }
66+
.subscribe(onNext: { text in
67+
self.sendButton.isDisabled = text.count == 0 || text == "\n"
68+
})
69+
.disposed(by: self.disposeBag)
70+
}
71+
72+
private func setUp() {
73+
view.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
74+
75+
view.addSubview(closeButton)
76+
closeButton.autoPinTopAndTrailingToSuperView(inset: .adaptive(height: 15.0), xInset: .adaptive(width: 15.0))
77+
closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside)
78+
79+
view.addSubview(titleLabel)
80+
titleLabel.autoAlignAxis(toSuperviewAxis: .vertical)
81+
titleLabel.autoAlignAxis(.horizontal, toSameAxisOf: closeButton)
82+
83+
view.addSubview(textView)
84+
textView.autoPinEdgesToSuperviewSafeArea(with: UIEdgeInsets(horizontal: .adaptive(width: 30.0), vertical: .adaptive(height: 108.0)), excludingEdge: .bottom)
85+
86+
view.addSubview(sendButton)
87+
sendButton.autoAlignAxis(toSuperviewAxis: .vertical)
88+
sendButton.autoPinEdge(toSuperviewEdge: .leading, withInset: .adaptive(width: 15.0))
89+
sendButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: .adaptive(width: 15.0))
90+
sendButton.autoPinEdge(.top, to: .bottom, of: textView, withOffset: .adaptive(height: 15.0))
91+
sendButton.addTarget(self, action: #selector(sendButtonTapped), for: .touchUpInside)
92+
93+
let keyboardViewV = KeyboardLayoutConstraint(item: view!.safeAreaLayoutGuide,
94+
attribute: .bottom,
95+
relatedBy: .equal,
96+
toItem: sendButton,
97+
attribute: .bottom,
98+
multiplier: 1.0,
99+
constant: .adaptive(height: 10.0))
100+
keyboardViewV.observeKeyboardHeight()
101+
view.addConstraint(keyboardViewV)
102+
}
103+
104+
private func checkValues() -> Bool {
105+
guard !textView.text.isEmpty else {
106+
self.hintView?.display(inPosition: sendButton.frame.origin, withType: .enterText, completion: {})
107+
return false
108+
}
109+
110+
return true
111+
}
112+
113+
114+
// MARK: - Actions
115+
@objc func closeButtonTapped( _ sender: UIButton) {
116+
self.dismiss(animated: true, completion: nil)
117+
}
118+
119+
@objc func sendButtonTapped( _ sender: UIButton) {
120+
guard checkValues() else { return }
121+
122+
self.dismiss(animated: true, completion: {
123+
AnalyticsManger.shared.sendFeedback(message: self.textView.text)
124+
})
125+
}
126+
127+
@objc func viewTapped( _ sender: UITapGestureRecognizer) {
128+
view.endEditing(true)
129+
}
130+
}

Commun/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
"to" = "to";
245245
"the presence of non-alphanumeric characters side by side is not allowed" = "the presence of non-alphanumeric characters side by side is not allowed";
246246
"non-alphanumeric character cannot be at the beginning or end of a username" = "non-alphanumeric character cannot be at the beginning or end of a username";
247+
"text view feedback placeholder" = "describe the problem...";
247248

248249

249250
// U

0 commit comments

Comments
 (0)