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
2024-10-15 15:32:51 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
514d24b2e891a5ccccd8fe72722c93dd76f9b444
514d24b2
1 parent
1cc12977
add SM Coupons to UnifiedCouponsViewController
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
5 deletions
SwiftWarplyFramework/Pods/Pods.xcodeproj/xcuserdata/manos.xcuserdatad/xcschemes/xcschememanagement.plist
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/xcuserdata/manos.xcuserdatad/xcschemes/xcschememanagement.plist
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/CouponsTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
SwiftWarplyFramework/SwiftWarplyFramework/UnifiedCouponsViewController.swift
SwiftWarplyFramework/Pods/Pods.xcodeproj/xcuserdata/manos.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
514d24b
...
...
@@ -7,7 +7,7 @@
<key>
Pods-SwiftWarplyFramework.xcscheme_^#shared#^_
</key>
<dict>
<key>
orderHint
</key>
<integer>
1
</integer>
<integer>
0
</integer>
</dict>
</dict>
</dict>
...
...
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/xcuserdata/manos.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
514d24b
...
...
@@ -7,7 +7,7 @@
<key>
SwiftWarplyFramework.xcscheme_^#shared#^_
</key>
<dict>
<key>
orderHint
</key>
<integer>
0
</integer>
<integer>
1
</integer>
</dict>
</dict>
</dict>
...
...
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
514d24b
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/CouponsTableViewCell.swift
View file @
514d24b
...
...
@@ -20,12 +20,32 @@ import UIKit
@IBOutlet
weak
var
expirationRedImage
:
UIImageView
!
@IBOutlet
weak
var
expirationRedLabel
:
UILabel
!
// Variables for the view, image, and button
var
selectView
:
UIView
!
var
selectImageView
:
UIImageView
!
var
selectButton
:
UIButton
!
// Boolean to track if the selectView should be visible
var
isSelectViewVisible
:
Bool
=
false
{
didSet
{
selectView
.
isHidden
=
!
isSelectViewVisible
}
}
// Boolean to track the selection state of the cell
var
isSelectedCell
:
Bool
=
false
{
didSet
{
updateSelectionState
()
}
}
// Action closure for button tap inside the cell
var
selectButtonAction
:
(()
->
Void
)?
var
postImageURL
:
String
?
{
didSet
{
if
let
url
=
postImageURL
{
// TODO: DELETE LOGS
print
(
"=== postImageURL: "
,
url
)
self
.
couponImage
.
image
=
UIImage
()
// UIImage(named: "loading")
UIImage
.
loadImageUsingCacheWithUrlString
(
url
)
{
image
in
...
...
@@ -49,6 +69,8 @@ import UIKit
couponBgImage
.
image
=
UIImage
(
named
:
"coupon_bg_2"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
borderView
.
addDashedBorderVertical
(
color
:
UIColor
(
red
:
0.62
,
green
:
0.62
,
blue
:
0.61
,
alpha
:
1.00
),
width
:
1.0
,
height
:
110.0
)
setupSelectButton
()
}
public
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
...
...
@@ -64,6 +86,69 @@ import UIKit
contentView
.
frame
=
contentView
.
frame
.
inset
(
by
:
margins
)
}
// Setup Select Button UI and layout
func
setupSelectButton
()
{
// Create the container view (selectView)
selectView
=
UIView
()
selectView
.
translatesAutoresizingMaskIntoConstraints
=
false
contentView
.
addSubview
(
selectView
)
// Set selectView constraints
NSLayoutConstraint
.
activate
([
selectView
.
widthAnchor
.
constraint
(
equalToConstant
:
26
),
selectView
.
heightAnchor
.
constraint
(
equalToConstant
:
26
),
selectView
.
topAnchor
.
constraint
(
equalTo
:
contentView
.
topAnchor
,
constant
:
6
),
selectView
.
trailingAnchor
.
constraint
(
equalTo
:
contentView
.
trailingAnchor
,
constant
:
-
16
)
])
// Create the UIImageView inside selectView
selectImageView
=
UIImageView
()
selectImageView
.
contentMode
=
.
scaleAspectFit
selectImageView
.
translatesAutoresizingMaskIntoConstraints
=
false
selectView
.
addSubview
(
selectImageView
)
// Set imageView constraints to match the size of the selectView
NSLayoutConstraint
.
activate
([
selectImageView
.
leadingAnchor
.
constraint
(
equalTo
:
selectView
.
leadingAnchor
),
selectImageView
.
trailingAnchor
.
constraint
(
equalTo
:
selectView
.
trailingAnchor
),
selectImageView
.
topAnchor
.
constraint
(
equalTo
:
selectView
.
topAnchor
),
selectImageView
.
bottomAnchor
.
constraint
(
equalTo
:
selectView
.
bottomAnchor
)
])
// Create the transparent button on top of the imageView
selectButton
=
UIButton
(
type
:
.
custom
)
selectButton
.
backgroundColor
=
.
clear
// Make the button transparent
selectButton
.
translatesAutoresizingMaskIntoConstraints
=
false
selectButton
.
addTarget
(
self
,
action
:
#selector(
selectButtonTapped
)
,
for
:
.
touchUpInside
)
selectView
.
addSubview
(
selectButton
)
// Set button constraints to match the size of the selectView
NSLayoutConstraint
.
activate
([
selectButton
.
leadingAnchor
.
constraint
(
equalTo
:
selectView
.
leadingAnchor
),
selectButton
.
trailingAnchor
.
constraint
(
equalTo
:
selectView
.
trailingAnchor
),
selectButton
.
topAnchor
.
constraint
(
equalTo
:
selectView
.
topAnchor
),
selectButton
.
bottomAnchor
.
constraint
(
equalTo
:
selectView
.
bottomAnchor
)
])
// Initially hide the selectView (selectView)
selectView
.
isHidden
=
true
}
// Button action handler
@objc
func
selectButtonTapped
()
{
// Trigger the action closure when the button is pressed
selectButtonAction
?()
}
// Update the cell's appearance based on selection state
func
updateSelectionState
()
{
// Update the image based on the new state
if
(
isSelectedCell
)
{
selectImageView
.
image
=
UIImage
(
named
:
"circle_checked"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
// Selected image
}
else
{
selectImageView
.
image
=
UIImage
(
named
:
"circle_unchecked"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
// Unselected image
}
}
func
configureCell
(
coupon
:
swiftApi
.
CouponItemModel
)
{
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
...
...
@@ -240,4 +325,22 @@ import UIKit
}
// Configure the cell with visibility of the selectView, a selected state, and select Button Action
func
showSelectButton
(
isSelectViewVisible
:
Bool
,
isSelected
:
Bool
,
buttonAction
:
@escaping
()
->
Void
)
{
self
.
isSelectViewVisible
=
isSelectViewVisible
self
.
isSelectedCell
=
isSelected
self
.
selectButtonAction
=
buttonAction
if
(
isSelected
)
{
couponBgImage
.
image
=
UIImage
(
named
:
"coupon_bg_2_selected"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
}
else
{
couponBgImage
.
image
=
UIImage
(
named
:
"coupon_bg_2"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
}
// Set nameLabel constraints to not overlap selectView
NSLayoutConstraint
.
activate
([
nameLabel
.
trailingAnchor
.
constraint
(
equalTo
:
selectView
.
leadingAnchor
,
constant
:
-
5
)
])
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
View file @
514d24b
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/UnifiedCouponsViewController.swift
View file @
514d24b
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment