Manos Chorianopoulos

open webview from gifts

......@@ -11,6 +11,7 @@ import SwiftUI
import Combine
import Foundation
import UIKit
import WarplySDKFrameworkIOS
class CouponSetItemModel {
......@@ -304,13 +305,20 @@ extension GiftsView {
var item: CampaignItemModel
var isFirst: Bool
var isLast: Bool
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
Button {
// GiftItem Action
print("GiftItem tapped!")
let instanceOfMyApi = MyApi()
let campaignViewController = instanceOfMyApi.openCampaign(parentView, campaign: item.index_url)!
campaignViewController.view.tag = 6
// addChild(couponsViewController)
campaignViewController.view.frame = parentView.frame
parentView.addSubview(campaignViewController.view)
campaignViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
......@@ -338,6 +346,7 @@ extension GiftsView {
struct giftsContainer: View {
@State var gifts:Array<CampaignItemModel> = []
@State var title:String = ""
@State var parentView:UIView
var uiscreen = UIScreen.main.bounds
......@@ -357,7 +366,7 @@ extension GiftsView {
HStack(alignment: .center) {
ForEach(Array(gifts.enumerated()), id: \.offset) { index, item in
giftItemView(item: item, isFirst: index == 0, isLast: index == (gifts.count-1))
giftItemView(item: item, isFirst: index == 0, isLast: index == (gifts.count-1), parentView: parentView)
}
}
......@@ -529,12 +538,12 @@ struct GiftsView: View {
ScrollView(showsIndicators: false) {
VStack {
if (campains.filter { $0.subcategory == "gifts" }.count) > 0 {
giftsContainer(gifts: campains.filter { $0.subcategory == "gifts" }, title: "ΔΩΡΑ")
giftsContainer(gifts: campains.filter { $0.subcategory == "gifts" }, title: "ΔΩΡΑ", parentView: parentView)
}
if (campains.filter { $0.subcategory == "rewards" }.count) > 0 {
giftsContainer(gifts: campains.filter { $0.subcategory == "rewards"}, title: "ΕΠΙΒΡΑΒΕΥΣΕΙΣ" )
giftsContainer(gifts: campains.filter { $0.subcategory == "rewards"}, title: "ΕΠΙΒΡΑΒΕΥΣΕΙΣ", parentView: parentView )
}
if (coupons.count) > 0 {
......