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
Dimitris Togias
2022-09-21 09:56:04 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c9c94c6b658a1129d1d7e5363650328fd0d84437
c9c94c6b
1 parent
4bb005ca
implement sections in MFYViewController
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
29 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/project.pbxproj
SwiftWarplyFramework/SwiftWarplyFramework/CampaignCategory.swift
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/project.pbxproj
View file @
c9c94c6
...
...
@@ -38,6 +38,7 @@
A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; };
A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; };
A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; };
A0C6F45228DAE36900B089D1 /* CampaignCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0C6F45128DAE36900B089D1 /* CampaignCategory.swift */; };
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */; };
...
...
@@ -196,6 +197,7 @@
A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; };
A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; };
A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; };
A0C6F45128DAE36900B089D1 /* CampaignCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignCategory.swift; sourceTree = "<group>"; };
A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; };
B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; };
C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
...
...
@@ -386,6 +388,7 @@
isa = PBXGroup;
children = (
A07936722885E67400064122 /* AnalysisItem.swift */,
A0C6F45128DAE36900B089D1 /* CampaignCategory.swift */,
);
name = models;
sourceTree = "<group>";
...
...
@@ -910,6 +913,7 @@
E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */,
E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */,
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
A0C6F45228DAE36900B089D1 /* CampaignCategory.swift in Sources */,
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */,
...
...
SwiftWarplyFramework/SwiftWarplyFramework/CampaignCategory.swift
0 → 100644
View file @
c9c94c6
//
// CampaignCategory.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 21/9/22.
//
import
Foundation
public
class
CampaignCategory
:
Codable
{
// attributes
public
var
name
:
String
?
public
var
items
:
Array
<
swiftApi
.
CampaignItemModel
>
// initialization
public
init
(
_
name
:
String
)
{
self
.
name
=
name
self
.
items
=
[
swiftApi
.
CampaignItemModel
]()
}
}
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
View file @
c9c94c6
...
...
@@ -13,76 +13,123 @@ import SwiftEventBus
@IBOutlet
weak
var
mainView
:
UIView
!
@IBOutlet
weak
var
tableView
:
UITableView
!
var
categories
:
Array
<
CampaignCategory
>
=
[
CampaignCategory
]()
public
var
campaigns
:
Array
<
swiftApi
.
CampaignItemModel
>
=
swiftApi
()
.
mergeMFYCCMSLoyaltyCampaigns
(
campaigns
:
swiftApi
()
.
getCCMSLoyaltyCampaigns
())
public
var
ccmsList
:
Array
<
swiftApi
.
LoyaltyContextualOfferModel
>
=
swiftApi
()
.
getCCMSLoyaltyCampaigns
()
// lifecycle
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
hidesBottomBarWhenPushed
=
true
if
(
ccmsList
.
count
>
0
)
{
for
ccmsItem
in
ccmsList
{
if
(((
ccmsItem
.
_loyaltyCampaignId
==
""
)
||
(
ccmsItem
.
_loyaltyCampaignId
==
"NA"
))
&&
(
ccmsItem
.
_zone
==
"COSMOTE_APP_MORE4U"
))
{
let
newCampaign
=
swiftApi
.
CampaignItemModel
()
newCampaign
.
_title
=
ccmsItem
.
_title
newCampaign
.
_logo_url
=
ccmsItem
.
_imageUrl
newCampaign
.
_subtitle
=
ccmsItem
.
_subtitle
newCampaign
.
_message
=
ccmsItem
.
_message
newCampaign
.
_ccms
=
ccmsItem
campaigns
.
append
(
newCampaign
)
}
}
}
setBackButton
()
setNavigationTitle
(
"MORE for YOU"
,
"bold"
)
tableView
.
delegate
=
self
tableView
.
dataSource
=
self
tableView
.
clipsToBounds
=
true
tableView
.
layer
.
cornerRadius
=
30
tableView
.
layer
.
maskedCorners
=
[
.
layerMinXMinYCorner
]
// Top left corner radius
tableView
.
contentInset
.
top
=
50
// Add Top left corner radius
mainView
.
clipsToBounds
=
true
mainView
.
layer
.
cornerRadius
=
30
mainView
.
layer
.
maskedCorners
=
[
.
layerMinXMinYCorner
]
// Top left corner radius
mainView
.
backgroundColor
=
UIColor
(
red
:
0.22
,
green
:
0.32
,
blue
:
0.40
,
alpha
:
1.00
)
// data
SwiftEventBus
.
onMainThread
(
self
,
name
:
"ccms_retrieved"
)
{
result
in
print
(
"===== SwiftEventBus ccms_retrieved ====="
)
self
.
campaigns
=
swiftApi
()
.
mergeMFYCCMSLoyaltyCampaigns
(
campaigns
:
swiftApi
()
.
getCCMSLoyaltyCampaigns
())
self
.
tableView
.
re
loadData
()
self
.
loadData
()
}
SwiftEventBus
.
onMainThread
(
self
,
name
:
"campaigns_retrieved"
)
{
result
in
print
(
"===== SwiftEventBus campaigns_retrieved ====="
)
self
.
campaigns
=
swiftApi
()
.
mergeMFYCCMSLoyaltyCampaigns
(
campaigns
:
swiftApi
()
.
getCCMSLoyaltyCampaigns
())
self
.
tableView
.
re
loadData
()
self
.
loadData
()
}
tableView
.
clipsToBounds
=
true
tableView
.
layer
.
cornerRadius
=
30
tableView
.
layer
.
maskedCorners
=
[
.
layerMinXMinYCorner
]
// Top left corner radius
tableView
.
contentInset
.
top
=
50
loadData
()
}
// Add Top left corner radius
mainView
.
clipsToBounds
=
true
mainView
.
layer
.
cornerRadius
=
30
mainView
.
layer
.
maskedCorners
=
[
.
layerMinXMinYCorner
]
// Top left corner radius
mainView
.
backgroundColor
=
UIColor
(
red
:
0.22
,
green
:
0.32
,
blue
:
0.40
,
alpha
:
1.00
)
func
loadData
()
{
var
newData
=
[
CampaignCategory
]()
// parse campaigns
var
campaignsDict
=
[
String
:
CampaignCategory
]()
for
item
in
campaigns
{
guard
let
title
=
item
.
_category_title
else
{
continue
}
if
(
title
.
isEmpty
)
{
continue
}
var
category
=
campaignsDict
[
title
]
if
(
category
==
nil
)
{
category
=
CampaignCategory
(
title
)
campaignsDict
[
title
]
=
category
newData
.
append
(
category
!
)
}
category
?
.
items
.
append
(
item
)
}
// parse ccms
let
category
=
CampaignCategory
(
"ΑΛΛΕΣ"
)
for
ccmsItem
in
ccmsList
{
if
(((
ccmsItem
.
_loyaltyCampaignId
==
""
)
||
(
ccmsItem
.
_loyaltyCampaignId
==
"NA"
))
&&
(
ccmsItem
.
_zone
==
"COSMOTE_APP_MORE4U"
))
{
let
newCampaign
=
swiftApi
.
CampaignItemModel
()
newCampaign
.
_title
=
ccmsItem
.
_title
newCampaign
.
_logo_url
=
ccmsItem
.
_imageUrl
newCampaign
.
_subtitle
=
ccmsItem
.
_subtitle
newCampaign
.
_message
=
ccmsItem
.
_message
newCampaign
.
_ccms
=
ccmsItem
category
.
items
.
append
(
newCampaign
)
}
}
newData
.
append
(
category
)
// reload
categories
=
newData
self
.
tableView
.
reloadData
()
}
}
// MARK: - TableView
extension
MFYViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
public
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
1
return
self
.
categories
.
count
}
public
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
self
.
ca
mpaign
s
.
count
return
self
.
ca
tegories
[
section
]
.
item
s
.
count
}
public
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
220.0
+
10.0
// return UITableViewAutomaticDimension
}
public
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
tableView
.
frame
.
width
,
height
:
60
))
view
.
backgroundColor
=
.
clear
let
titleLabel
=
UILabel
(
frame
:
CGRect
(
x
:
15
,
y
:
20
,
width
:
view
.
frame
.
width
-
15
,
height
:
40
))
titleLabel
.
font
=
UIFont
(
name
:
"PFSquareSansPro-Bold"
,
size
:
21
)
titleLabel
.
textColor
=
.
white
titleLabel
.
text
=
categories
[
section
]
.
name
view
.
addSubview
(
titleLabel
)
return
view
}
public
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
c9c94c6
...
...
@@ -781,6 +781,8 @@ public class swiftApi {
private
var
ccms
:
LoyaltyContextualOfferModel
?
private
var
carousel
:
String
?
private
var
category_title
:
String
?
public
init
()
{
self
.
index_url
=
""
self
.
logo_url
=
""
...
...
@@ -828,6 +830,7 @@ public class swiftApi {
self
.
badge
=
extra_fields
[
"badge"
]
as?
String
?
??
""
self
.
type
=
extra_fields
[
"type"
]
as?
String
?
??
""
self
.
carousel
=
extra_fields
[
"carousel"
]
as?
String
?
??
"false"
self
.
category_title
=
extra_fields
[
"category_title"
]
as?
String
??
""
}
else
{
self
.
subcategory
=
""
self
.
loyaltyCampaignId
=
""
...
...
@@ -836,6 +839,7 @@ public class swiftApi {
self
.
badge
=
""
self
.
type
=
""
self
.
carousel
=
"false"
self
.
category_title
=
""
}
// let extra_fields = dictionary["extra_fields"] as AnyObject
...
...
@@ -1027,6 +1031,12 @@ public class swiftApi {
self
.
carousel
=
newValue
}
}
public
var
_category_title
:
String
?
{
get
{
// getter
return
self
.
category_title
}
}
}
public
class
CampaignDataModel
{
...
...
Please
register
or
login
to post a comment