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-24 11:42:25 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5ca5ae474cb81015fb735d1cb054fe839b2c18be
5ca5ae47
1 parent
fb69e34a
marketPassDetails fixes
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
57 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MarketPassViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/MarketPassViewController.swift
View file @
5ca5ae4
...
...
@@ -8,6 +8,7 @@
import
UIKit
import
RSBarcodes_Swift
import
AVFoundation
import
SwiftEventBus
@objc
public
class
MarketPassViewController
:
UIViewController
{
@IBOutlet
weak
var
passContainerView
:
UIView
!
...
...
@@ -21,9 +22,9 @@ import AVFoundation
@IBOutlet
weak
var
smLogosView
:
UIView
!
@IBOutlet
weak
var
mapButton
:
UIButton
!
var
marketPassDetails
:
swiftApi
.
MarketPassDetailsModel
?
var
marketPassDetails
:
swiftApi
.
MarketPassDetailsModel
?
=
swiftApi
()
.
getMarketPassDetails
()
let
spinner
=
SpinnerViewController
()
//
let spinner = SpinnerViewController()
let
uiscreen
:
CGRect
=
UIScreen
.
main
.
bounds
...
...
@@ -33,7 +34,19 @@ import AVFoundation
self
.
hidesBottomBarWhenPushed
=
true
passContainerView
.
isHidden
=
true
getMarketPassDetailsRequest
()
// getMarketPassDetailsRequest()
SwiftEventBus
.
onBackgroundThread
(
self
,
name
:
"market_pass_details_fetched"
)
{
result
in
DispatchQueue
.
main
.
async
{
if
let
tempMarketPassDetails
=
swiftApi
()
.
getMarketPassDetails
()
{
self
.
marketPassDetails
=
tempMarketPassDetails
self
.
updateUI
()
}
else
{
// self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
}
setBackButton
()
setNavigationTitle
(
"SUPERMARKET DEALS"
)
...
...
@@ -97,19 +110,18 @@ import AVFoundation
// 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
couponsValueString
=
"0.00"
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
couponsValueNormalText1
=
"Έχεις κουπόνια συνολικής αξίας "
let
couponsValueBoldText
=
couponsValueString
+
"€"
//
let couponsValueAttributedString = NSMutableAttributedString(string:couponsValueNormalText1, attributes:attrRegular)
//
let couponsValueBoldString = NSMutableAttributedString(string: couponsValueBoldText, attributes:attrBold)
let
couponsValueAttributedString
=
NSMutableAttributedString
(
string
:
couponsValueNormalText1
,
attributes
:
attrRegular
)
let
couponsValueBoldString
=
NSMutableAttributedString
(
string
:
couponsValueBoldText
,
attributes
:
attrBold
)
//
couponsValueAttributedString.append(couponsValueBoldString)
//
couponsValueLabel.attributedText = couponsValueAttributedString
couponsValueAttributedString
.
append
(
couponsValueBoldString
)
couponsValueLabel
.
attributedText
=
couponsValueAttributedString
mapButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
"PeridotPE-SBold"
,
size
:
16
)
mapButton
.
setTitle
(
"Δες στο χάρτη"
,
for
:
.
normal
)
...
...
@@ -155,6 +167,13 @@ import AVFoundation
// stackView.leadingAnchor.constraint(equalTo: smLogosView.leadingAnchor, constant: 25),
// stackView.centerYAnchor.constraint(equalTo: smLogosView.centerYAnchor),
// ])
if
let
tempMarketPassDetails
=
swiftApi
()
.
getMarketPassDetails
()
{
self
.
marketPassDetails
=
tempMarketPassDetails
self
.
updateUI
()
}
else
{
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
func
updateUI
()
{
...
...
@@ -174,8 +193,10 @@ import AVFoundation
}
else
{
barcodeImageHeight
.
constant
=
0
}
let
couponsValueString
=
String
(
marketPassDetails
?
.
_total_available_discount
??
0.0
)
let
couponsValueFloat
=
marketPassDetails
?
.
_total_available_discount
??
0.0
let
couponsValueString
=
String
(
format
:
"%.2f"
,
couponsValueFloat
)
// let couponsValueString = String(marketPassDetails?._total_available_discount ?? 0.0)
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
]
...
...
@@ -193,7 +214,7 @@ import AVFoundation
// Create a horizontal stack view
let
stackView
=
UIStackView
()
stackView
.
axis
=
.
horizontal
stackView
.
spacing
=
1
5
// Spacing between images
stackView
.
spacing
=
5
// Spacing between images
stackView
.
alignment
=
.
center
stackView
.
distribution
=
.
equalSpacing
...
...
@@ -201,8 +222,8 @@ import AVFoundation
for
sm
in
supermarkets
{
let
imageView
=
UIImageView
()
imageView
.
contentMode
=
.
scaleAspectFit
imageView
.
widthAnchor
.
constraint
(
equalToConstant
:
4
0
)
.
isActive
=
true
imageView
.
heightAnchor
.
constraint
(
equalToConstant
:
4
0
)
.
isActive
=
true
imageView
.
widthAnchor
.
constraint
(
equalToConstant
:
5
0
)
.
isActive
=
true
imageView
.
heightAnchor
.
constraint
(
equalToConstant
:
5
0
)
.
isActive
=
true
imageView
.
load
(
link
:
sm
.
_logo
,
placeholder
:
UIImage
(),
cache
:
URLCache
())
...
...
@@ -224,25 +245,25 @@ import AVFoundation
self
.
view
.
layoutIfNeeded
()
}
func
showSpinner
()
{
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
//
func showSpinner() {
//
// add the spinner view controller
//
// addChild(spinner)
//
// spinner.view.frame = view.frame
//
// view.addSubview(spinner.view)
//
// spinner.didMove(toParent: self)
addChild
(
spinner
)
spinner
.
view
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
)
self
.
view
.
addSubview
(
spinner
.
view
)
spinner
.
didMove
(
toParent
:
self
)
}
//
addChild(spinner)
//
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
//
self.view.addSubview(spinner.view)
//
spinner.didMove(toParent: self)
//
}
func
hideSpinner
()
{
// remove the spinner view controller
spinner
.
willMove
(
toParent
:
nil
)
spinner
.
view
.
removeFromSuperview
()
spinner
.
removeFromParent
()
}
//
func hideSpinner() {
//
// remove the spinner view controller
//
spinner.willMove(toParent: nil)
//
spinner.view.removeFromSuperview()
//
spinner.removeFromParent()
//
}
func
showDialog
(
_
alertTitle
:
String
,
_
alertSubTitle
:
String
)
->
Void
{
...
...
@@ -300,31 +321,30 @@ import AVFoundation
}
// MARK: - API Functions
func
getMarketPassDetailsRequest
()
{
showSpinner
()
//
func getMarketPassDetailsRequest() {
//
showSpinner()
swiftApi
()
.
getMarketPassDetailsAsync
(
getMarketPassDetailsCallback
,
failureCallback
:
{
errorCode
in
print
(
"========= getMarketPassDetailsRequest ERROR CODE ========="
,
errorCode
)
self
.
hideSpinner
()
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
})
}
//
swiftApi().getMarketPassDetailsAsync(getMarketPassDetailsCallback, failureCallback: {errorCode in
//
print("========= getMarketPassDetailsRequest ERROR CODE =========", errorCode)
//
self.hideSpinner()
//
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
//
})
//
}
func
getMarketPassDetailsCallback
(
_
marketPassDetailsData
:
swiftApi
.
MarketPassDetailsModel
?)
->
Void
{
self
.
hideSpinner
()
//
func getMarketPassDetailsCallback (_ marketPassDetailsData: swiftApi.MarketPassDetailsModel?) -> Void {
//
self.hideSpinner()
if
(
marketPassDetailsData
!=
nil
)
{
DispatchQueue
.
main
.
async
{
if
let
tempMarketPassDetailsData
=
marketPassDetailsData
{
self
.
marketPassDetails
=
tempMarketPassDetailsData
self
.
updateUI
()
}
}
}
else
{
self
.
showDialog
(
"Αποτυχία"
,
"Κάτι πήγε στραβά"
)
}
}
// MARK: - API Functions
// if (marketPassDetailsData != nil) {
// DispatchQueue.main.async {
// if let tempMarketPassDetailsData = marketPassDetailsData {
// self.marketPassDetails = tempMarketPassDetailsData
// self.updateUI()
// }
// }
// } else {
// self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
// }
// }
// MARK: - Actions
@IBAction
func
mapButtonAction
(
_
sender
:
Any
)
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
5ca5ae4
...
...
@@ -40,6 +40,7 @@ public struct GlobalVariables {
static
var
trackingStepsEnabled
:
Bool
=
false
static
var
carouselList
:
Array
<
swiftApi
.
CampaignItemModel
>
=
[]
static
var
showVouchersBanner
:
String
=
""
// We use String in order to have 3 different states: "", "true", "false"
static
var
marketPassDetails
:
swiftApi
.
MarketPassDetailsModel
?
}
var
timer
:
DispatchSourceTimer
?
...
...
@@ -194,6 +195,16 @@ public class swiftApi {
GlobalVariables
.
showVouchersBanner
=
""
}
public
func
setMarketPassDetails
(
_
newValue
:
swiftApi
.
MarketPassDetailsModel
)
{
GlobalVariables
.
marketPassDetails
=
newValue
}
public
func
getMarketPassDetails
()
->
swiftApi
.
MarketPassDetailsModel
?
{
return
GlobalVariables
.
marketPassDetails
}
public
func
setVouchersFetched
(
_
success
:
String
)
->
Void
{
// Possible values "true", "false", "null"
...
...
@@ -9567,6 +9578,8 @@ public class swiftApi {
if
let
responseDataResult
=
responseDataDictionary
[
"result"
]
as?
[
String
:
Any
]
{
let
tempMarketPassDetails
=
MarketPassDetailsModel
(
dictionary
:
responseDataResult
)
swiftApi
()
.
setMarketPassDetails
(
tempMarketPassDetails
)
SwiftEventBus
.
post
(
"market_pass_details_fetched"
)
successCallback
(
tempMarketPassDetails
)
}
else
{
...
...
Please
register
or
login
to post a comment