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-22 13:38:12 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2f053b7256df5b85ca803162a92208467dfaa9fe
2f053b72
1 parent
909d88fd
PopupMerchantsViewController dynamic list
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
27 deletions
SwiftWarplyFramework/SwiftWarplyFramework/CouponBarcodeViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/MerchantTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/PopupMerchantsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/CouponBarcodeViewController.swift
View file @
2f053b7
...
...
@@ -655,20 +655,35 @@ import AVFoundation
@IBAction
func
redeemButtomAction
(
_
sender
:
Any
)
{
if
(
isSMCoupon
==
true
)
{
var
availableShopsList
:
Array
<
swiftApi
.
ShopAvailabilityItemModel
>
=
[]
let
smCouponsetsList
=
swiftApi
()
.
getCouponSetsDealsList
()
let
couponsetUuid
=
coupon
?
.
couponset_uuid
for
couponset
in
smCouponsetsList
{
if
(
couponset
.
uuid
==
couponsetUuid
)
{
availableShopsList
=
couponset
.
shop_availability
??
[]
break
;
}
}
if
(
availableShopsList
.
count
>
0
)
{
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
if
let
popupVC
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"PopupMerchantsViewController"
)
as?
SwiftWarplyFramework
.
PopupMerchantsViewController
{
popupVC
.
modalPresentationStyle
=
.
overCurrentContext
popupVC
.
modalTransitionStyle
=
.
crossDissolve
popupVC
.
coupon
=
coupon
// popupVC.headerText = "Βρες το προϊον στα supermarket"
// popupVC.buttonTitle = "Βρες το"
popupVC
.
availableShopsList
=
availableShopsList
// popupVC.headerText = "Βρες το προϊον στα supermarket"
// popupVC.buttonTitle = "Βρες το"
popupVC
.
buttonIcon
=
"shopping_cart"
// popupVC.footerText = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
// popupVC.footerText = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
self
.
present
(
popupVC
,
animated
:
true
,
completion
:
nil
)
}
}
else
{
// TODO: add error popup
}
}
else
{
let
couponSetData
:
swiftApi
.
CouponSetItemModel
?
=
self
.
coupon
?
.
couponset_data
let
couponName
=
couponSetData
?
.
name
??
""
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MerchantTableViewCell.swift
View file @
2f053b7
...
...
@@ -23,6 +23,8 @@ class MerchantTableViewCell: UITableViewCell {
// Delegate variable
weak
var
delegate
:
MerchantTableViewCellDelegate
?
let
merchantList
:
Array
<
swiftApi
.
MerchantModel
>
=
swiftApi
()
.
getMerchantList
()
var
postImageURL
:
String
?
{
didSet
{
if
let
url
=
postImageURL
{
...
...
@@ -71,9 +73,14 @@ class MerchantTableViewCell: UITableViewCell {
contentView
.
frame
=
contentView
.
frame
.
inset
(
by
:
margins
)
}
func
configureCell
(
merchant
:
swiftApi
.
Merchant
Model
,
buttonTitle
:
String
,
iconImage
:
String
?)
{
func
configureCell
(
shop
:
swiftApi
.
ShopAvailabilityItem
Model
,
buttonTitle
:
String
,
iconImage
:
String
?)
{
for
merchant
in
merchantList
{
if
(
merchant
.
_uuid
==
shop
.
_merchant_uuid
)
{
self
.
postImageURL
=
merchant
.
_img_preview
break
;
}
}
buttonTitleLable
.
text
=
buttonTitle
...
...
SwiftWarplyFramework/SwiftWarplyFramework/PopupMerchantsViewController.swift
View file @
2f053b7
...
...
@@ -13,14 +13,13 @@ class PopupMerchantsViewController: UIViewController {
@IBOutlet
weak
var
closeButton
:
UIButton
!
@IBOutlet
weak
var
tableView
:
DynamicSizeTableView
!
public
var
coupon
:
swiftApi
.
CouponItemModel
?
public
var
availableShopsList
:
Array
<
swiftApi
.
ShopAvailabilityItemModel
>
=
[]
// public var coupon: swiftApi.CouponItemModel?
public
var
headerText
:
String
?
=
"Βρες το προϊον στα supermarket"
public
var
buttonTitle
:
String
?
=
"Βρες το"
public
var
buttonIcon
:
String
?
public
var
footerText
:
String
?
=
"Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
let
merchantList
:
Array
<
swiftApi
.
MerchantModel
>
=
swiftApi
()
.
getMerchantList
()
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -59,7 +58,7 @@ extension PopupMerchantsViewController: UITableViewDelegate, UITableViewDataSour
public
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
(
section
==
0
)
{
return
self
.
merchant
List
.
count
return
self
.
availableShops
List
.
count
}
else
if
(
section
==
1
)
{
return
1
}
else
{
...
...
@@ -82,7 +81,7 @@ extension PopupMerchantsViewController: UITableViewDelegate, UITableViewDataSour
public
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
if
(
indexPath
.
section
==
0
)
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"MerchantTableViewCellId"
,
for
:
indexPath
)
as!
MerchantTableViewCell
cell
.
configureCell
(
merchant
:
merchant
List
[
indexPath
.
row
],
buttonTitle
:
self
.
buttonTitle
??
"Βρες το"
,
iconImage
:
buttonIcon
)
cell
.
configureCell
(
shop
:
availableShops
List
[
indexPath
.
row
],
buttonTitle
:
self
.
buttonTitle
??
"Βρες το"
,
iconImage
:
buttonIcon
)
// Set the delegate to self
cell
.
delegate
=
self
...
...
@@ -98,19 +97,8 @@ extension PopupMerchantsViewController: UITableViewDelegate, UITableViewDataSour
}
public
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
// self.dismiss(animated: true, completion: {})
// TODO: DELETE LOGS
print
(
" didSelectRowAt Button tapped in row
\(
indexPath
.
row
)
"
)
// TODO: Open merchant url
// Logs
// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
// print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
// print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
// print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
// Do nothing - tap handled with protocol
// print(" didSelectRowAt Button tapped in row \(indexPath.row)")
}
...
...
@@ -138,11 +126,14 @@ extension PopupMerchantsViewController: MerchantTableViewCellDelegate {
func
didTapButton
(
in
cell
:
MerchantTableViewCell
)
{
// Find the index path of the cell where the button was tapped
if
let
indexPath
=
tableView
.
indexPath
(
for
:
cell
)
{
// TODO: DELETE LOGS
print
(
"Button tapped in row
\(
indexPath
.
row
)
"
)
print
(
"Button tapped cell:
\(
cell
)
"
)
// Handle the button tap action here
let
urlString
=
availableShopsList
[
indexPath
.
row
]
.
_product_url
if
let
url
=
URL
(
string
:
urlString
){
if
UIApplication
.
shared
.
canOpenURL
(
url
)
{
UIApplication
.
shared
.
open
(
url
,
options
:
[:],
completionHandler
:
nil
)
}
}
}
}
}
...
...
Please
register
or
login
to post a comment