Showing
2 changed files
with
72 additions
and
0 deletions
No preview for this file type
... | @@ -121,12 +121,14 @@ import UIKit | ... | @@ -121,12 +121,14 @@ import UIKit |
121 | mapButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16) | 121 | mapButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16) |
122 | mapButton.setTitle("Καταστήματα κοντά μου", for: .normal) | 122 | mapButton.setTitle("Καταστήματα κοντά μου", for: .normal) |
123 | mapButton.setTitleColor(UIColor(rgb: 0xFFFFFF), for: .normal) | 123 | mapButton.setTitleColor(UIColor(rgb: 0xFFFFFF), for: .normal) |
124 | + mapButton.setTitleColor(UIColor(rgb: 0xFFFFFF), for: .highlighted) | ||
124 | mapButton.layer.cornerRadius = 4.0 | 125 | mapButton.layer.cornerRadius = 4.0 |
125 | mapButton.backgroundColor = UIColor(rgb: 0x000F1E) | 126 | mapButton.backgroundColor = UIColor(rgb: 0x000F1E) |
126 | 127 | ||
127 | websiteButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16) | 128 | websiteButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16) |
128 | websiteButton.setTitle("Δες το website", for: .normal) | 129 | websiteButton.setTitle("Δες το website", for: .normal) |
129 | websiteButton.setTitleColor(UIColor(rgb: 0x000F1E), for: .normal) | 130 | websiteButton.setTitleColor(UIColor(rgb: 0x000F1E), for: .normal) |
131 | + websiteButton.setTitleColor(UIColor(rgb: 0x000F1E), for: .highlighted) | ||
130 | websiteButton.backgroundColor = .clear | 132 | websiteButton.backgroundColor = .clear |
131 | websiteButton.layer.borderWidth = 1 | 133 | websiteButton.layer.borderWidth = 1 |
132 | websiteButton.layer.borderColor = UIColor(rgb: 0x000F1E).cgColor | 134 | websiteButton.layer.borderColor = UIColor(rgb: 0x000F1E).cgColor |
... | @@ -164,6 +166,7 @@ import UIKit | ... | @@ -164,6 +166,7 @@ import UIKit |
164 | couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 24) | 166 | couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 24) |
165 | couponCodeValueLabel.textColor = UIColor(rgb: 0x000F1E) | 167 | couponCodeValueLabel.textColor = UIColor(rgb: 0x000F1E) |
166 | couponCodeValueLabel.text = "coupons_ab" | 168 | couponCodeValueLabel.text = "coupons_ab" |
169 | + copyButton.addTarget(self, action: #selector(copyButtonTapped), for: .touchUpInside) | ||
167 | 170 | ||
168 | couponQRTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16) | 171 | couponQRTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16) |
169 | couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E) | 172 | couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E) |
... | @@ -363,4 +366,73 @@ import UIKit | ... | @@ -363,4 +366,73 @@ import UIKit |
363 | self.view.layoutIfNeeded() | 366 | self.view.layoutIfNeeded() |
364 | } | 367 | } |
365 | } | 368 | } |
369 | + | ||
370 | + @objc private func copyButtonTapped() { | ||
371 | + // Get the coupon code text | ||
372 | + guard let couponCode = couponCodeValueLabel.text else { return } | ||
373 | + | ||
374 | + // Copy to clipboard | ||
375 | + UIPasteboard.general.string = couponCode | ||
376 | + | ||
377 | + // Show visual feedback | ||
378 | + showCopyFeedback() | ||
379 | + | ||
380 | + // Optional: Haptic feedback | ||
381 | + let impactFeedback = UIImpactFeedbackGenerator(style: .medium) | ||
382 | + impactFeedback.impactOccurred() | ||
383 | + } | ||
384 | + | ||
385 | + private func showCopyFeedback() { | ||
386 | + // Store original image | ||
387 | + // let originalImage = copyButtonImage.image | ||
388 | + | ||
389 | + // Change to checkmark temporarily | ||
390 | + // copyButtonImage.image = UIImage(systemName: "checkmark") | ||
391 | + // copyButtonImage.tintColor = UIColor(rgb: 0x09914E) // Green color | ||
392 | + | ||
393 | + // Show toast message | ||
394 | + showToast(message: "Κωδικός αντιγράφηκε!") | ||
395 | + | ||
396 | + // Reset after 1.5 seconds | ||
397 | + // DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { | ||
398 | + // self.copyButtonImage.image = originalImage | ||
399 | + // self.copyButtonImage.tintColor = UIColor(rgb: 0xCBCED1) // Original color | ||
400 | + // } | ||
401 | + } | ||
402 | + | ||
403 | + private func showToast(message: String) { | ||
404 | + // Create toast label | ||
405 | + let toast = UILabel() | ||
406 | + toast.backgroundColor = UIColor.black.withAlphaComponent(0.8) | ||
407 | + toast.textColor = .white | ||
408 | + toast.textAlignment = .center | ||
409 | + toast.font = UIFont(name: "PingLCG-Regular", size: 14) | ||
410 | + toast.text = message | ||
411 | + toast.alpha = 0.0 | ||
412 | + toast.layer.cornerRadius = 8 | ||
413 | + toast.clipsToBounds = true | ||
414 | + | ||
415 | + // Add to view | ||
416 | + view.addSubview(toast) | ||
417 | + toast.translatesAutoresizingMaskIntoConstraints = false | ||
418 | + NSLayoutConstraint.activate([ | ||
419 | + toast.centerXAnchor.constraint(equalTo: view.centerXAnchor), | ||
420 | + toast.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -100), | ||
421 | + toast.widthAnchor.constraint(equalToConstant: 200), | ||
422 | + toast.heightAnchor.constraint(equalToConstant: 40) | ||
423 | + ]) | ||
424 | + | ||
425 | + // Animate in | ||
426 | + UIView.animate(withDuration: 0.3, animations: { | ||
427 | + toast.alpha = 1.0 | ||
428 | + }) { _ in | ||
429 | + // Animate out after delay | ||
430 | + UIView.animate(withDuration: 0.3, delay: 1.5, animations: { | ||
431 | + toast.alpha = 0.0 | ||
432 | + }) { _ in | ||
433 | + toast.removeFromSuperview() | ||
434 | + } | ||
435 | + } | ||
436 | + } | ||
437 | + | ||
366 | } | 438 | } | ... | ... |
-
Please register or login to post a comment