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-01-15 17:00:02 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
21a444d023f9ac8ef0c14ba6ccf311430cefe9fb
21a444d0
1 parent
2a98a4e8
add MarketPassViewController
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
2 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
SwiftWarplyFramework/SwiftWarplyFramework/MarketPassViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletActiveCouponsScrollTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
21a444d
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
View file @
21a444d
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/MarketPassViewController.swift
View file @
21a444d
...
...
@@ -10,6 +10,18 @@ import RSBarcodes_Swift
import
AVFoundation
@objc
public
class
MarketPassViewController
:
UIViewController
{
@IBOutlet
weak
var
passContainerView
:
UIView
!
@IBOutlet
weak
var
passTitleLabel
:
UILabel
!
@IBOutlet
weak
var
passSubtitleLabel
:
UILabel
!
@IBOutlet
weak
var
barcodeView
:
UIView
!
@IBOutlet
weak
var
barcodeImage
:
UIImageView
!
@IBOutlet
weak
var
barcodeImageHeight
:
NSLayoutConstraint
!
@IBOutlet
weak
var
barcodeLabel
:
UILabel
!
@IBOutlet
weak
var
couponsValueLabel
:
UILabel
!
@IBOutlet
weak
var
smLogosView
:
UIView
!
@IBOutlet
weak
var
mapButton
:
UIButton
!
let
uiscreen
:
CGRect
=
UIScreen
.
main
.
bounds
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -21,8 +33,13 @@ import AVFoundation
// Setup the info button with an action
setNavBarRightInfoButton
()
{
// This closure is the action that will be executed when the info button is tapped
// self.presentInfoPopup()
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"MarketPassInfoViewController"
)
as!
SwiftWarplyFramework
.
MarketPassInfoViewController
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
setupUI
()
}
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
...
...
@@ -33,4 +50,151 @@ import AVFoundation
self
.
navigationController
?
.
hideHairline
()
}
// MARK: - Functions
func
setupUI
()
{
passContainerView
.
backgroundColor
=
UIColor
(
rgb
:
0x36B32B
)
passContainerView
.
layer
.
cornerRadius
=
16.0
// Add shadow
passContainerView
.
layer
.
shadowColor
=
UIColor
(
red
:
0.00
,
green
:
0.00
,
blue
:
0.00
,
alpha
:
0.31
)
.
cgColor
passContainerView
.
layer
.
shadowOffset
=
CGSize
(
width
:
0.0
,
height
:
1.0
)
passContainerView
.
layer
.
shadowOpacity
=
1.0
passContainerView
.
layer
.
shadowRadius
=
3.0
passTitleLabel
.
text
=
"SUPERMARKET DEALS CARD"
// passTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 23)
passTitleLabel
.
font
=
UIFont
(
name
:
"BTCosmo-Bold"
,
size
:
22
)
passTitleLabel
.
textColor
=
.
white
passSubtitleLabel
.
text
=
"Χρησιμοποίησε τον κωδικό σου και κέρδισε έκπτωση στις αγορές σου!"
passSubtitleLabel
.
font
=
UIFont
(
name
:
"PeridotPE-Regular"
,
size
:
17.0
)
passSubtitleLabel
.
textColor
=
.
white
barcodeView
.
backgroundColor
=
.
white
barcodeView
.
layer
.
cornerRadius
=
16.0
barcodeView
.
layer
.
borderWidth
=
2
barcodeView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xDADDE4
)
.
cgColor
//TODO: FIX
// let barcodeString = constructBarcode(coupon: coupon) ?? ""
// let barcodeString = coupon?._barcode ?? ""
let
barcodeString
=
"4006381333931"
barcodeLabel
.
text
=
barcodeString
barcodeLabel
.
font
=
UIFont
(
name
:
"PeridotPE-Regular"
,
size
:
19.0
)
barcodeLabel
.
textColor
=
UIColor
(
rgb
:
0x212121
)
if
let
barcodeUIImage
=
RSUnifiedCodeGenerator
.
shared
.
generateCode
(
barcodeString
,
machineReadableCodeObjectType
:
AVMetadataObject
.
ObjectType
.
ean13
.
rawValue
,
targetSize
:
CGSize
(
width
:
self
.
uiscreen
.
width
*
0.8
,
height
:
self
.
uiscreen
.
height
*
0.12
))
{
// if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: 110, height: 83)) {
barcodeImage
.
image
=
barcodeUIImage
barcodeImageHeight
.
constant
=
self
.
uiscreen
.
height
*
0.12
// barcodeImageHeight.constant = 83
}
else
{
barcodeImageHeight
.
constant
=
0
}
// TODO: FIX
let
couponsValueString
=
"30"
let
attrRegular
=
[
NSAttributedString
.
Key
.
font
:
UIFont
(
name
:
"PeridotPE-Regular"
,
size
:
17
)
??
UIFont
.
systemFont
(
ofSize
:
16
),
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
.
white
]
let
attrBold
=
[
NSAttributedString
.
Key
.
font
:
UIFont
(
name
:
"PeridotPE-Bold"
,
size
:
17
)
??
UIFont
.
boldSystemFont
(
ofSize
:
16
),
NSAttributedString
.
Key
.
foregroundColor
:
UIColor
.
white
]
let
couponsValueNormalText1
=
"Έχεις κουπόνια συνολικής αξίας "
let
couponsValueBoldText
=
couponsValueString
+
"€"
let
couponsValueAttributedString
=
NSMutableAttributedString
(
string
:
couponsValueNormalText1
,
attributes
:
attrRegular
)
let
couponsValueBoldString
=
NSMutableAttributedString
(
string
:
couponsValueBoldText
,
attributes
:
attrBold
)
couponsValueAttributedString
.
append
(
couponsValueBoldString
)
couponsValueLabel
.
attributedText
=
couponsValueAttributedString
mapButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
"PeridotPE-SBold"
,
size
:
16
)
mapButton
.
setTitle
(
"Δες στο χάρτη"
,
for
:
.
normal
)
mapButton
.
setTitleColor
(
UIColor
(
rgb
:
0x006D26
),
for
:
.
normal
)
mapButton
.
layer
.
cornerRadius
=
10.0
mapButton
.
frame
=
CGRect
(
x
:
0.0
,
y
:
0.0
,
width
:
148
,
height
:
48
)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 55)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
mapButton
.
backgroundColor
=
.
clear
mapButton
.
layer
.
borderWidth
=
2
mapButton
.
layer
.
borderColor
=
UIColor
(
rgb
:
0x006D26
)
.
cgColor
smLogosView
.
layer
.
cornerRadius
=
16.0
smLogosView
.
layer
.
maskedCorners
=
[
.
layerMinXMaxYCorner
,
.
layerMaxXMaxYCorner
]
// Bottom left, right corner radius
// TODO: FIX - Replace with dynamic images
let
imageNames
=
[
"active_code_logo_2"
,
"active_code_logo_2"
,
"active_code_logo_2"
]
// let images = imageNames.compactMap { UIImage(named: $0) }
let
images
=
imageNames
.
compactMap
{
UIImage
(
named
:
$0
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
}
// Create a horizontal stack view
let
stackView
=
UIStackView
()
stackView
.
axis
=
.
horizontal
stackView
.
spacing
=
15
// Spacing between images
stackView
.
alignment
=
.
center
stackView
.
distribution
=
.
equalSpacing
// Add UIImageViews to the stack view
for
image
in
images
{
let
imageView
=
UIImageView
(
image
:
image
)
imageView
.
contentMode
=
.
scaleAspectFit
imageView
.
widthAnchor
.
constraint
(
equalToConstant
:
40
)
.
isActive
=
true
// Set a width
imageView
.
heightAnchor
.
constraint
(
equalToConstant
:
40
)
.
isActive
=
true
// Set a height
stackView
.
addArrangedSubview
(
imageView
)
}
// Add the stack view to your main view
smLogosView
.
addSubview
(
stackView
)
// Set up constraints for the stack view
stackView
.
translatesAutoresizingMaskIntoConstraints
=
false
NSLayoutConstraint
.
activate
([
stackView
.
leadingAnchor
.
constraint
(
equalTo
:
smLogosView
.
leadingAnchor
,
constant
:
25
),
stackView
.
centerYAnchor
.
constraint
(
equalTo
:
smLogosView
.
centerYAnchor
),
])
}
func
constructBarcode
()
->
String
?
{
// EAN 13 barcode construction
//TODO: FIX
// let couponString = coupon?._barcode ?? ""
let
couponString
=
"123456789101112"
if
(
!
couponString
.
isEmpty
)
{
var
checkDigit
=
0
;
var
result
=
0
;
var
fixedCouponCode
=
couponString
;
if
(
fixedCouponCode
.
count
<
12
)
{
let
loops
=
12
-
fixedCouponCode
.
count
;
var
zerosStr
=
""
;
for
i
in
0
..<
loops
{
zerosStr
+=
"0"
}
// fixedCouponCode = zerosStr + fixedCouponCode;
fixedCouponCode
=
fixedCouponCode
+
zerosStr
;
}
var
multiplier
=
3
;
for
idx
in
(
0
...
(
fixedCouponCode
.
count
-
1
))
.
reversed
()
{
let
curChar
=
fixedCouponCode
[
idx
];
result
+=
(
Int
(
curChar
)
??
0
)
*
multiplier
;
multiplier
=
multiplier
==
3
?
1
:
3
;
}
checkDigit
=
10
-
(
result
%
10
);
let
barcodeStr
=
fixedCouponCode
+
String
(
checkDigit
);
return
barcodeStr
;
}
return
""
}
// MARK: - Actions
@IBAction
func
mapButtonAction
(
_
sender
:
Any
)
{
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"CampaignViewController"
)
as!
SwiftWarplyFramework
.
CampaignViewController
vc
.
campaignUrl
=
swiftApi
()
.
getMarketPassMapUrl
()
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/WalletActiveCouponsScrollTableViewCell.swift
View file @
21a444d
...
...
@@ -170,7 +170,8 @@ extension WalletActiveCouponsScrollTableViewCell: UICollectionViewDataSource,UIC
swiftApi
()
.
logTrackersEvent
(
"click"
,
(
"LoyaltyWalletScreen:"
+
"ActiveMarketBanner"
))
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"UnifiedCouponsViewController"
)
as!
SwiftWarplyFramework
.
UnifiedCouponsViewController
// let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"MarketPassViewController"
)
as!
SwiftWarplyFramework
.
MarketPassViewController
parent
?
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
else
if
(
badgeId
==
"gfy"
)
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
21a444d
...
...
@@ -9357,5 +9357,13 @@ public class swiftApi {
}
}
public
func
getMarketPassMapUrl
()
->
String
{
let
appUuid
=
swiftApi
()
.
getAppUuid
()
if
(
appUuid
==
"f83dfde1145e4c2da69793abb2f579af"
)
{
return
"https://dev.supermarketdeals.eu/map"
}
else
{
return
"https://supermarketdeals.eu/map"
}
}
}
...
...
Please
register
or
login
to post a comment