mvcgen 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -15
- data/lib/mvcgen/generator.rb +61 -1
- data/lib/mvcgen/version.rb +1 -1
- data/lib/templates/default/swift/Controllers/Login/ForgetPasswordVC.swift +32 -39
- data/lib/templates/default/swift/Controllers/Login/LoginVC.swift +21 -11
- data/lib/templates/default/swift/Controllers/Login/RegisterVC.swift +69 -59
- data/lib/templates/default/swift/Controllers/Notifications/Cells/NotificationCell.swift +28 -1
- data/lib/templates/default/swift/Controllers/Notifications/NotificationsVC.swift +17 -27
- data/lib/templates/default/swift/Controllers/OtherLogin/ForgetPasswordTVC.swift +9 -10
- data/lib/templates/default/swift/Controllers/OtherLogin/LoginTVC.swift +1 -1
- data/lib/templates/default/swift/Controllers/OtherLogin/OtherRegisterVC.swift +11 -10
- data/lib/templates/default/swift/Controllers/OtherLogin/SelectLanguageVC.swift +22 -21
- data/lib/templates/default/swift/Controllers/OtherLogin/TermsAndConditionsVC.swift +8 -7
- data/lib/templates/default/swift/Controllers/Profile/AboutUsVC.swift +23 -11
- data/lib/templates/default/swift/Controllers/Profile/Cells/AboutUsImageCell.swift +21 -5
- data/lib/templates/default/swift/Controllers/Profile/Cells/DescriptionCell.swift +10 -0
- data/lib/templates/default/swift/Controllers/Profile/Cells/DestinationCell.swift +5 -0
- data/lib/templates/default/swift/Controllers/Profile/Cells/FavoriteCollectionCell.swift +2 -0
- data/lib/templates/default/swift/Controllers/Profile/Cells/ImagesCollectionViewCell.swift +12 -0
- data/lib/templates/default/swift/Controllers/Profile/ProfileContainerVC.swift +18 -14
- data/lib/templates/default/swift/Controllers/Profile/ProfileTVC.swift +65 -85
- data/lib/templates/default/swift/Controllers/Tutorial/TutorialVC.swift +12 -9
- data/lib/templates/default/swift/Extensions/Buttons.swift +0 -12
- data/lib/templates/default/swift/Extensions/{ArrayDuplicates.swift → Utils+Array.swift} +1 -1
- data/lib/templates/default/swift/Extensions/{Images.swift → Utils+Images.swift} +8 -7
- data/lib/templates/default/swift/Extensions/Utils+String.swift +34 -0
- data/lib/templates/default/swift/Extensions/Utils+UIButton.swift +21 -0
- data/lib/templates/default/swift/Extensions/{UIColorExtensions.swift → Utils+UIColor.swift} +1 -1
- data/lib/templates/default/swift/Extensions/{TableViewEmptyView.swift → Utils+UITableView.swift} +1 -2
- data/lib/templates/default/swift/Extensions/Utils+UITextField.swift +22 -0
- data/lib/templates/default/swift/Extensions/{GradientView.swift → Utils+UIView.swift} +82 -2
- data/lib/templates/default/swift/Extensions/{TapEffectExtension.swift → Utils+UIViewController.swift} +18 -1
- data/lib/templates/default/swift/Helper/Utils.swift +1 -1
- data/lib/templates/default/swift/UI/Storyboards/Home.storyboard +4 -4
- data/lib/templates/default/swift/UI/Views/EmptyTableView/Xibs/EmptyTableLabelView.xib +1 -1
- metadata +11 -18
- data/lib/templates/default/swift/Assets.xcassets/alert_beach.imageset/Contents.json +0 -21
- data/lib/templates/default/swift/Assets.xcassets/alert_beach.imageset/icons8-beach-64.png +0 -0
- data/lib/templates/default/swift/Assets.xcassets/alert_nobaggage.imageset/Contents.json +0 -21
- data/lib/templates/default/swift/Assets.xcassets/alert_nobaggage.imageset/icons8-no-baggage-100.png +0 -0
- data/lib/templates/default/swift/Assets.xcassets/alert_signpost.imageset/Contents.json +0 -21
- data/lib/templates/default/swift/Assets.xcassets/alert_signpost.imageset/icons8-signpost-64.png +0 -0
- data/lib/templates/default/swift/Assets.xcassets/alert_sunbed.imageset/Contents.json +0 -21
- data/lib/templates/default/swift/Assets.xcassets/alert_sunbed.imageset/sunbed.png +0 -0
- data/lib/templates/default/swift/Extensions/HideKeyboard.swift +0 -22
- data/lib/templates/default/swift/Extensions/InnerShadowExtension.swift +0 -83
@@ -7,19 +7,24 @@
|
|
7
7
|
//
|
8
8
|
|
9
9
|
import UIKit
|
10
|
-
import Kingfisher
|
11
10
|
|
12
11
|
class AboutUsImageCell: UITableViewCell {
|
13
12
|
|
13
|
+
// MARK: - Outlets
|
14
|
+
|
14
15
|
@IBOutlet weak var collectionView: UICollectionView!
|
15
16
|
@IBOutlet weak var pageControl: UIPageControl!
|
17
|
+
|
18
|
+
// MARK: - Properties
|
19
|
+
|
16
20
|
var pictures : [Pic] = []
|
17
|
-
|
18
21
|
var thisWidth:CGFloat = 0
|
19
|
-
|
22
|
+
|
23
|
+
// MARK: - Life cycle
|
20
24
|
|
21
25
|
override func awakeFromNib() {
|
22
26
|
super.awakeFromNib()
|
27
|
+
|
23
28
|
self.collectionView.dataSource = self
|
24
29
|
self.collectionView.delegate = self
|
25
30
|
|
@@ -35,31 +40,42 @@ class AboutUsImageCell: UITableViewCell {
|
|
35
40
|
}
|
36
41
|
|
37
42
|
}
|
43
|
+
|
44
|
+
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout
|
45
|
+
|
38
46
|
extension AboutUsImageCell : UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout{
|
47
|
+
|
39
48
|
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
49
|
+
|
40
50
|
return self.pictures.count
|
41
51
|
}
|
42
52
|
|
43
53
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
54
|
+
|
44
55
|
return 1
|
45
56
|
}
|
46
57
|
|
47
58
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
48
59
|
|
49
60
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "imagesCollectionViewCell", for: indexPath) as! ImagesCollectionViewCell
|
61
|
+
|
50
62
|
let picture = pictures[indexPath.section]
|
51
|
-
|
52
|
-
cell.
|
63
|
+
|
64
|
+
cell.configure(with: picture)
|
65
|
+
|
53
66
|
return cell
|
54
67
|
|
55
68
|
}
|
56
69
|
|
57
70
|
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
71
|
+
|
58
72
|
self.pageControl.currentPage = indexPath.section
|
59
73
|
}
|
60
74
|
|
61
75
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
76
|
+
|
62
77
|
thisWidth = self.collectionView.frame.width
|
78
|
+
|
63
79
|
return CGSize(width: thisWidth, height: self.collectionView.frame.height)
|
64
80
|
}
|
65
81
|
|
@@ -7,10 +7,20 @@
|
|
7
7
|
//
|
8
8
|
|
9
9
|
import UIKit
|
10
|
+
import Kingfisher
|
10
11
|
|
11
12
|
class DescriptionCell: UITableViewCell {
|
12
13
|
|
14
|
+
// MARK: - Outlets
|
15
|
+
|
13
16
|
@IBOutlet weak var descriptionTextView: UITextView!
|
17
|
+
|
18
|
+
func configure(with userHistory: UserHistory) {
|
19
|
+
|
20
|
+
self.destinationLabel.text = userHistory.name.capitalized
|
21
|
+
self.destinationBackgroundImage.kf.indicatorType = .activity
|
22
|
+
self.destinationBackgroundImage.kf.setImage(with: URL(string: history.thumbnailUrl), options: [.transition(.fade(0.2))])
|
23
|
+
}
|
14
24
|
|
15
25
|
}
|
16
26
|
|
@@ -10,6 +10,8 @@ import UIKit
|
|
10
10
|
|
11
11
|
class DestinationCell: UICollectionViewCell {
|
12
12
|
|
13
|
+
// MARK: - Outlets
|
14
|
+
|
13
15
|
@IBOutlet weak var destinationBackgroundImage: UIImageView!
|
14
16
|
|
15
17
|
@IBOutlet weak var destinationLabel: UILabel!
|
@@ -18,8 +20,11 @@ class DestinationCell: UICollectionViewCell {
|
|
18
20
|
|
19
21
|
@IBOutlet weak var tickImage: UIImageView!
|
20
22
|
|
23
|
+
// MARK: - Life cycle
|
24
|
+
|
21
25
|
override func awakeFromNib() {
|
22
26
|
super.awakeFromNib()
|
27
|
+
|
23
28
|
// Initialization code
|
24
29
|
self.blueGradientView.applyGradient(withColours: [Colors.firstGradientColor, UIColor.clear], alpha: 0.8, angle: 90)
|
25
30
|
}
|
@@ -7,9 +7,21 @@
|
|
7
7
|
//
|
8
8
|
|
9
9
|
import UIKit
|
10
|
+
import Kingfisher
|
10
11
|
|
11
12
|
class ImagesCollectionViewCell: UICollectionViewCell {
|
13
|
+
|
14
|
+
// MARK: - Outlets
|
15
|
+
|
12
16
|
@IBOutlet weak var imageOutlet: UIImageView!
|
17
|
+
|
18
|
+
// MARK: - Life cycle
|
19
|
+
|
20
|
+
func configure(with picture: Pic) {
|
21
|
+
|
22
|
+
self.imageOutlet.kf.indicatorType = .activity
|
23
|
+
self.imageOutlet.kf.setImage(with: URL(string : picture.url))
|
24
|
+
}
|
13
25
|
|
14
26
|
}
|
15
27
|
|
@@ -10,12 +10,22 @@ import UIKit
|
|
10
10
|
|
11
11
|
class ProfileContainerVC: UIViewController {
|
12
12
|
|
13
|
+
// MARK: - Outlets
|
14
|
+
|
13
15
|
@IBOutlet weak var gradientView: UIView!
|
14
16
|
|
15
17
|
@IBOutlet weak var containerView: UIView!
|
18
|
+
|
19
|
+
// MARK: - Properties
|
16
20
|
|
17
|
-
let homeStoryboard = UIStoryboard(name: "Home", bundle: Bundle.main)
|
21
|
+
private static let homeStoryboard = UIStoryboard(name: "Home", bundle: Bundle.main)
|
22
|
+
|
23
|
+
private lazy var profileTVC: ProfileTVC = {
|
24
|
+
return self.homeStoryboard.instantiateViewController(withIdentifier: "ProfileTVC") as! ProfileTVC
|
25
|
+
}()
|
18
26
|
|
27
|
+
// MARK: - Life cycle
|
28
|
+
|
19
29
|
override func viewDidLoad() {
|
20
30
|
super.viewDidLoad()
|
21
31
|
|
@@ -23,31 +33,24 @@ class ProfileContainerVC: UIViewController {
|
|
23
33
|
|
24
34
|
self.add(asChildViewController: self.profileTVC)
|
25
35
|
}
|
36
|
+
|
26
37
|
override func viewDidLayoutSubviews() {
|
27
38
|
super.viewDidLayoutSubviews()
|
28
|
-
|
29
|
-
// self.gradientView.backgroundColor = ColorConstants.backgroundColor
|
30
|
-
|
39
|
+
|
31
40
|
self.gradientView.applyGradient(withColours: [Colors.firstGradientColor, Colors.thirdGradientColor], locations: [0, 0.5])
|
32
|
-
|
33
41
|
}
|
42
|
+
|
43
|
+
// MARK: - Private
|
34
44
|
|
35
|
-
func setupNavigationBar() {
|
45
|
+
private func setupNavigationBar() {
|
46
|
+
|
36
47
|
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
|
37
48
|
self.navigationController?.navigationBar.shadowImage = UIImage()
|
38
49
|
self.navigationController?.navigationBar.isTranslucent = true
|
39
50
|
self.navigationController?.view.backgroundColor = UIColor.clear
|
40
|
-
|
41
51
|
}
|
42
52
|
|
43
|
-
private lazy var profileTVC: ProfileTVC = {
|
44
|
-
|
45
|
-
return self.homeStoryboard.instantiateViewController(withIdentifier: "ProfileTVC") as! ProfileTVC
|
46
|
-
|
47
|
-
}()
|
48
|
-
|
49
53
|
private func add(asChildViewController viewController: UIViewController) {
|
50
|
-
addChildViewController(viewController)
|
51
54
|
|
52
55
|
containerView.addSubview(viewController.view)
|
53
56
|
|
@@ -60,6 +63,7 @@ class ProfileContainerVC: UIViewController {
|
|
60
63
|
}
|
61
64
|
|
62
65
|
private func remove(asChildViewController viewController: UIViewController) {
|
66
|
+
|
63
67
|
// Notify Child View Controller
|
64
68
|
viewController.willMove(toParentViewController: nil)
|
65
69
|
|
@@ -25,7 +25,6 @@ struct UserHistory{
|
|
25
25
|
|
26
26
|
class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadProtocol, UITextViewDelegate {
|
27
27
|
|
28
|
-
|
29
28
|
// MARK: - Outlets
|
30
29
|
|
31
30
|
@IBOutlet weak var editProfileImageButton: UIButton! {
|
@@ -117,19 +116,14 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
117
116
|
|
118
117
|
// MARK: - Properties
|
119
118
|
|
120
|
-
let homeStoryboard = UIStoryboard(name: "Home", bundle: Bundle.main)
|
119
|
+
private static let homeStoryboard = UIStoryboard(name: "Home", bundle: Bundle.main)
|
121
120
|
|
122
121
|
var profileImageChanged: Bool = false
|
123
122
|
|
124
123
|
var favorites: [Favorite] = []{
|
125
124
|
didSet{
|
126
|
-
|
127
|
-
|
128
|
-
self.favoritesCollectionView.isHidden = false
|
129
|
-
} else {
|
130
|
-
self.noFavoritesView.isHidden = false
|
131
|
-
self.favoritesCollectionView.isHidden = true
|
132
|
-
}
|
125
|
+
self.noFavoritesView.isHidden = self.favorites.count > 0 ? true : false
|
126
|
+
self.favoritesCollectionView.isHidden = self.favorites.count > 0 ? false : true
|
133
127
|
}
|
134
128
|
}
|
135
129
|
|
@@ -137,13 +131,8 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
137
131
|
|
138
132
|
var userHistory: [UserHistory] = []{
|
139
133
|
didSet{
|
140
|
-
|
141
|
-
|
142
|
-
self.historyTripsCollectionView.isHidden = false
|
143
|
-
} else {
|
144
|
-
self.noTravelsView.isHidden = false
|
145
|
-
self.historyTripsCollectionView.isHidden = true
|
146
|
-
}
|
134
|
+
self.noTravelsView.isHidden = self.userHistory.count > 0 ? true : false
|
135
|
+
self.historyTripsCollectionView.isHidden = self.userHistory.count > 0 ? false : true
|
147
136
|
}
|
148
137
|
}
|
149
138
|
|
@@ -155,19 +144,19 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
155
144
|
|
156
145
|
var newNotifications = false{
|
157
146
|
didSet{
|
158
|
-
|
159
|
-
self.notificationBadgeView.isHidden = false
|
160
|
-
} else {
|
161
|
-
self.notificationBadgeView.isHidden = true
|
162
|
-
}
|
147
|
+
self.notificationBadgeView.isHidden = !newNotifications
|
163
148
|
}
|
164
149
|
}
|
165
150
|
|
166
151
|
var notifications = [Notif]()
|
167
152
|
|
153
|
+
// MARK: - Life cycle
|
154
|
+
|
168
155
|
override func viewDidLoad() {
|
169
156
|
super.viewDidLoad()
|
157
|
+
|
170
158
|
self.fetchData()
|
159
|
+
|
171
160
|
self.setupViews()
|
172
161
|
|
173
162
|
if #available(iOS 11.0, *) {
|
@@ -183,23 +172,30 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
183
172
|
hideKeyboardWhenTappedAround()
|
184
173
|
|
185
174
|
NotificationCenter.default.addObserver(self, selector: #selector(handleFavoritesUpdated(_:)), name: Notification.Name("FavoritesUpdated"), object: nil)
|
186
|
-
|
187
|
-
|
188
175
|
}
|
189
176
|
|
190
177
|
|
191
178
|
override func viewWillAppear(_ animated: Bool) {
|
192
179
|
super.viewWillAppear(true)
|
193
|
-
|
180
|
+
|
194
181
|
self.navigationController?.navigationBar.isHidden = false
|
195
182
|
self.navigationItem.hidesBackButton = true
|
196
183
|
|
197
184
|
setNotificationBadge()
|
185
|
+
}
|
186
|
+
|
187
|
+
override func viewDidLayoutSubviews() {
|
188
|
+
super.viewDidLayoutSubviews()
|
198
189
|
|
190
|
+
self.aboutMeTextView.layoutIfNeeded()
|
191
|
+
self.aboutMeTextView.changeBorderColor(newColor: UIColor.white)
|
199
192
|
}
|
200
193
|
|
201
|
-
|
202
|
-
|
194
|
+
// MARK: - Private
|
195
|
+
|
196
|
+
private func setNotificationBadge(){
|
197
|
+
|
198
|
+
// TODO: Enable when done
|
203
199
|
// APIManager.sharedInstance.getNotifications(){
|
204
200
|
// result, notifications in
|
205
201
|
// self.notifications = notifications.sorted(by: {$0.createdDate.compare($1.createdDate) == .orderedDescending})
|
@@ -217,8 +213,10 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
217
213
|
// }
|
218
214
|
}
|
219
215
|
|
220
|
-
|
221
|
-
|
216
|
+
private func fetchData() {
|
217
|
+
|
218
|
+
// TODO: change for local or remote user data
|
219
|
+
|
222
220
|
self.profileImageLoading.startAnimating()
|
223
221
|
|
224
222
|
self.emailTextField.text = "John"
|
@@ -228,19 +226,20 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
228
226
|
self.phoneCountry = "Uruguay"
|
229
227
|
self.phonePrefix.text = "+598"
|
230
228
|
|
231
|
-
self.aboutMeTextView.text =
|
229
|
+
self.aboutMeTextView.text = "Add something about yourself!"
|
232
230
|
self.aboutMeTextView.textColor = UIColor.lightGray
|
233
231
|
|
234
232
|
self.profileImageLoading.stopAnimating()
|
233
|
+
|
235
234
|
self.editProfileImageView.image = Asset.userTestPhoto.image
|
236
235
|
|
237
|
-
// TODO: Add favorites and history
|
236
|
+
// TODO: Add favorites and history or something like that if needed
|
238
237
|
|
239
238
|
}
|
240
239
|
|
241
|
-
func setupViews() {
|
240
|
+
private func setupViews() {
|
242
241
|
|
243
|
-
self.notificationImage.image =
|
242
|
+
self.notificationImage.image = Asset.notification.image
|
244
243
|
|
245
244
|
self.logoutButton.layoutIfNeeded()
|
246
245
|
self.logoutButton.layer.cornerRadius = self.logoutButton.frame.height/7
|
@@ -271,21 +270,16 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
271
270
|
historyTripsCollectionView.dataSource = self
|
272
271
|
historyTripsCollectionView.isMultipleTouchEnabled = false
|
273
272
|
historyTripsCollectionView.allowsSelection = false
|
273
|
+
|
274
274
|
let destNib = UINib(nibName: "DestinationCellView", bundle: nil)
|
275
275
|
historyTripsCollectionView.register(destNib, forCellWithReuseIdentifier: "DestinationCellView")
|
276
276
|
|
277
277
|
}
|
278
278
|
|
279
|
-
override func viewDidLayoutSubviews() {
|
280
|
-
super.viewDidLayoutSubviews()
|
281
|
-
|
282
|
-
self.aboutMeTextView.layoutIfNeeded()
|
283
|
-
self.aboutMeTextView.changeBorderColor(newColor: UIColor.white)
|
284
|
-
}
|
285
|
-
|
286
279
|
// MARK: - TextViewDelegate
|
287
280
|
|
288
281
|
func textViewDidBeginEditing(_ textView: UITextView) {
|
282
|
+
|
289
283
|
if textView.textColor == UIColor.lightGray {
|
290
284
|
textView.text = nil
|
291
285
|
textView.textColor = UIColor.white
|
@@ -293,8 +287,9 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
293
287
|
}
|
294
288
|
|
295
289
|
func textViewDidEndEditing(_ textView: UITextView) {
|
290
|
+
|
296
291
|
if textView.text.isEmpty {
|
297
|
-
textView.text =
|
292
|
+
textView.text = "Add something about yourself!"
|
298
293
|
textView.textColor = UIColor.lightGray
|
299
294
|
}
|
300
295
|
}
|
@@ -321,22 +316,24 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
321
316
|
}
|
322
317
|
|
323
318
|
override var prefersStatusBarHidden: Bool {
|
319
|
+
|
324
320
|
return navigationController?.isNavigationBarHidden ?? false
|
325
321
|
}
|
326
322
|
|
327
323
|
// MARK: - Actions
|
328
324
|
|
329
|
-
|
325
|
+
/// Function which is triggered when handleTap is called
|
330
326
|
@objc func handleNotificationTap(_ sender: UITapGestureRecognizer) {
|
331
|
-
|
327
|
+
|
332
328
|
guard let vc = self.homeStoryboard.instantiateViewController(withIdentifier: "NotificationsVC") as? NotificationsVC else { return }
|
329
|
+
self.animateViewBounceAndZoom(viewToAnimate: self.notificationButton)
|
333
330
|
vc.delegate = self
|
334
331
|
vc.notifications = self.notifications
|
335
332
|
self.navigationController?.pushViewController(vc, animated: true)
|
336
333
|
}
|
337
334
|
|
338
335
|
func setAsRead(value: Bool) {
|
339
|
-
// TODO:
|
336
|
+
// TODO: Enable when done
|
340
337
|
// if value {
|
341
338
|
// APIManager.sharedInstance.readNotifications(){
|
342
339
|
// result in
|
@@ -361,7 +358,6 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
361
358
|
|
362
359
|
self.profileImageChanged = true
|
363
360
|
self.editProfileImageView.image = image
|
364
|
-
|
365
361
|
})
|
366
362
|
}
|
367
363
|
}
|
@@ -369,9 +365,9 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
369
365
|
}
|
370
366
|
|
371
367
|
@IBAction func saveDataTapped(_ sender: UIButton) {
|
368
|
+
|
372
369
|
if self.validateData(){
|
373
370
|
// TODO
|
374
|
-
|
375
371
|
}
|
376
372
|
}
|
377
373
|
|
@@ -420,42 +416,25 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
420
416
|
//
|
421
417
|
// }
|
422
418
|
// }
|
423
|
-
|
424
|
-
func isValidEmail(_ testStr:String) -> Bool {
|
425
|
-
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
|
426
|
-
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
|
427
|
-
return emailTest.evaluate(with: testStr)
|
428
|
-
}
|
429
|
-
|
430
|
-
func isValidName(_ testStr:String) -> Bool {
|
431
|
-
let nameRegEx = "[A-Za-z\\s]+"
|
432
|
-
let nameTest = NSPredicate(format:"SELF MATCHES %@", nameRegEx)
|
433
|
-
return nameTest.evaluate(with: testStr)
|
434
|
-
}
|
435
|
-
|
436
|
-
func isValidPhone(_ testStr:String) -> Bool {
|
437
|
-
let phoneRegEx = "[0-9]*"
|
438
|
-
let phoneTest = NSPredicate(format:"SELF MATCHES %@", phoneRegEx)
|
439
|
-
return phoneTest.evaluate(with: testStr)
|
440
|
-
}
|
441
|
-
|
419
|
+
|
442
420
|
func validateData() -> Bool{
|
443
|
-
if
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
421
|
+
if !self.nameTextField.isName(){
|
422
|
+
APIHelper.sharedInstance.showErrorMessage(with: NSLocalizedString("Invalid name", comment: ""), and: "")
|
423
|
+
return false
|
424
|
+
}
|
425
|
+
if !self.lastnameTextField.isName(){
|
426
|
+
APIHelper.sharedInstance.showErrorMessage(with: NSLocalizedString("Invalid lastname", comment: ""), and: "")
|
427
|
+
return false
|
428
|
+
}
|
429
|
+
if !self.phoneTextField.isPhone() {
|
430
|
+
APIHelper.sharedInstance.showErrorMessage(with: NSLocalizedString("Invalid phone number", comment: ""), and: "")
|
431
|
+
return false
|
454
432
|
}
|
455
433
|
return true
|
456
434
|
}
|
457
435
|
|
458
436
|
@IBAction func selectCountryTapped(_ sender: UIButton) {
|
437
|
+
|
459
438
|
if self.countries.isEmpty {
|
460
439
|
// TODO: Set countries
|
461
440
|
} else {
|
@@ -464,6 +443,7 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
464
443
|
}
|
465
444
|
|
466
445
|
func addActionSheetPicker(_ sender: UIButton){
|
446
|
+
|
467
447
|
let prevCountryValue = self.phonePrefix.text
|
468
448
|
let prevPhoneCountryValue = self.phoneCountry
|
469
449
|
let acp = ActionSheetStringPicker(title: "", rows: self.countries.map{$0.name}, initialSelection: 0, doneBlock: {
|
@@ -495,13 +475,13 @@ class ProfileTVC: UITableViewController, UITextFieldDelegate, NotificationReadPr
|
|
495
475
|
}
|
496
476
|
|
497
477
|
@IBAction func aboutUsTapped(_ sender: UIButton) {
|
478
|
+
|
498
479
|
guard let vc = self.homeStoryboard.instantiateViewController(withIdentifier: "AboutUsVC") as? AboutUsVC else { return }
|
499
480
|
self.navigationController?.pushViewController(vc, animated: true)
|
500
481
|
}
|
501
482
|
|
502
483
|
@objc func handleFavoritesUpdated(_ notification: Foundation.Notification) {
|
503
484
|
//TODO: Get favorites again
|
504
|
-
|
505
485
|
}
|
506
486
|
|
507
487
|
}
|
@@ -539,36 +519,36 @@ extension ProfileTVC: UICollectionViewDelegate, UICollectionViewDataSource, UICo
|
|
539
519
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FavoriteCollectionCell", for: indexPath) as! FavoriteCollectionCell
|
540
520
|
|
541
521
|
let favorite = favorites[indexPath.row]
|
522
|
+
|
542
523
|
cell.destinationLabel.text = favorite.name
|
543
524
|
cell.removeButton.addTarget(self, action: #selector(handleRemoveButton(_:)), for: .touchUpInside)
|
525
|
+
|
544
526
|
return cell
|
545
|
-
|
546
527
|
} else {
|
528
|
+
|
547
529
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DestinationCellView", for: indexPath) as! DestinationCell
|
548
530
|
|
549
531
|
let history = userHistory[indexPath.row]
|
550
|
-
|
551
|
-
cell.
|
552
|
-
|
553
|
-
// for dest in travelGroup.destinations {
|
554
|
-
// cell.cityLabel.text = "\(cell.cityLabel.text!)\(travelGroup.destinations[0].destination?.city ?? ""), "
|
555
|
-
// }
|
556
|
-
// cell.cityLabel.text?.removeLast(2)
|
532
|
+
|
533
|
+
cell.configure(with: userHistory)
|
534
|
+
|
557
535
|
return cell
|
558
536
|
}
|
559
537
|
}
|
560
538
|
|
561
539
|
@objc func handleRemoveButton(_ sender: UIButton) {
|
540
|
+
|
562
541
|
let touchPoint = sender.convert(CGPoint.zero, to: self.favoritesCollectionView)
|
563
542
|
if let clickedIndexPath = self.favoritesCollectionView.indexPathForItem(at: touchPoint) {
|
564
543
|
self.noMoreFavorites.append(favorites[clickedIndexPath.row])
|
565
544
|
let removeDest = self.favorites.remove(at: clickedIndexPath.row)
|
566
545
|
self.noMoreFavorites.append(removeDest)
|
567
546
|
self.favoritesCollectionView.deleteItems(at: [clickedIndexPath])
|
568
|
-
|
547
|
+
}
|
569
548
|
}
|
570
549
|
|
571
550
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
551
|
+
|
572
552
|
if collectionView == favoritesCollectionView {
|
573
553
|
let size = (favorites[indexPath.row].name as NSString).size(withAttributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 16.0)])
|
574
554
|
return CGSize(width: size.width + 65, height: 40)
|