Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2025-05-28 16:06:59 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
794c4e8ea9b6ae2c20d4498f40560d3cd055c7c7
794c4e8e
1 parent
17214dab
copy coupon code functionality
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/screens/CouponViewController/CouponViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
794c4e8
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/screens/CouponViewController/CouponViewController.swift
View file @
794c4e8
...
...
@@ -121,12 +121,14 @@ import UIKit
mapButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
16
)
mapButton
.
setTitle
(
"Καταστήματα κοντά μου"
,
for
:
.
normal
)
mapButton
.
setTitleColor
(
UIColor
(
rgb
:
0xFFFFFF
),
for
:
.
normal
)
mapButton
.
setTitleColor
(
UIColor
(
rgb
:
0xFFFFFF
),
for
:
.
highlighted
)
mapButton
.
layer
.
cornerRadius
=
4.0
mapButton
.
backgroundColor
=
UIColor
(
rgb
:
0x000F1E
)
websiteButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
16
)
websiteButton
.
setTitle
(
"Δες το website"
,
for
:
.
normal
)
websiteButton
.
setTitleColor
(
UIColor
(
rgb
:
0x000F1E
),
for
:
.
normal
)
websiteButton
.
setTitleColor
(
UIColor
(
rgb
:
0x000F1E
),
for
:
.
highlighted
)
websiteButton
.
backgroundColor
=
.
clear
websiteButton
.
layer
.
borderWidth
=
1
websiteButton
.
layer
.
borderColor
=
UIColor
(
rgb
:
0x000F1E
)
.
cgColor
...
...
@@ -164,6 +166,7 @@ import UIKit
couponCodeValueLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
24
)
couponCodeValueLabel
.
textColor
=
UIColor
(
rgb
:
0x000F1E
)
couponCodeValueLabel
.
text
=
"coupons_ab"
copyButton
.
addTarget
(
self
,
action
:
#selector(
copyButtonTapped
)
,
for
:
.
touchUpInside
)
couponQRTitleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
16
)
couponQRTitleLabel
.
textColor
=
UIColor
(
rgb
:
0x000F1E
)
...
...
@@ -363,4 +366,73 @@ import UIKit
self
.
view
.
layoutIfNeeded
()
}
}
@objc
private
func
copyButtonTapped
()
{
// Get the coupon code text
guard
let
couponCode
=
couponCodeValueLabel
.
text
else
{
return
}
// Copy to clipboard
UIPasteboard
.
general
.
string
=
couponCode
// Show visual feedback
showCopyFeedback
()
// Optional: Haptic feedback
let
impactFeedback
=
UIImpactFeedbackGenerator
(
style
:
.
medium
)
impactFeedback
.
impactOccurred
()
}
private
func
showCopyFeedback
()
{
// Store original image
// let originalImage = copyButtonImage.image
// Change to checkmark temporarily
// copyButtonImage.image = UIImage(systemName: "checkmark")
// copyButtonImage.tintColor = UIColor(rgb: 0x09914E) // Green color
// Show toast message
showToast
(
message
:
"Κωδικός αντιγράφηκε!"
)
// Reset after 1.5 seconds
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
// self.copyButtonImage.image = originalImage
// self.copyButtonImage.tintColor = UIColor(rgb: 0xCBCED1) // Original color
// }
}
private
func
showToast
(
message
:
String
)
{
// Create toast label
let
toast
=
UILabel
()
toast
.
backgroundColor
=
UIColor
.
black
.
withAlphaComponent
(
0.8
)
toast
.
textColor
=
.
white
toast
.
textAlignment
=
.
center
toast
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
14
)
toast
.
text
=
message
toast
.
alpha
=
0.0
toast
.
layer
.
cornerRadius
=
8
toast
.
clipsToBounds
=
true
// Add to view
view
.
addSubview
(
toast
)
toast
.
translatesAutoresizingMaskIntoConstraints
=
false
NSLayoutConstraint
.
activate
([
toast
.
centerXAnchor
.
constraint
(
equalTo
:
view
.
centerXAnchor
),
toast
.
bottomAnchor
.
constraint
(
equalTo
:
view
.
safeAreaLayoutGuide
.
bottomAnchor
,
constant
:
-
100
),
toast
.
widthAnchor
.
constraint
(
equalToConstant
:
200
),
toast
.
heightAnchor
.
constraint
(
equalToConstant
:
40
)
])
// Animate in
UIView
.
animate
(
withDuration
:
0.3
,
animations
:
{
toast
.
alpha
=
1.0
})
{
_
in
// Animate out after delay
UIView
.
animate
(
withDuration
:
0.3
,
delay
:
1.5
,
animations
:
{
toast
.
alpha
=
0.0
})
{
_
in
toast
.
removeFromSuperview
()
}
}
}
}
...
...
Please
register
or
login
to post a comment