Merge branch 'master' of https://git.warp.ly/open-source/warply_sdk_framework
Showing
40 changed files
with
751 additions
and
2 deletions
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_cart.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_cart-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_cart-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
1.36 KB
1.36 KB
1.36 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_cosmote_logo.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_cosmote_logo-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_cosmote_logo-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
13.6 KB
13.6 KB
13.6 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_down.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_down-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_down-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
789 Bytes
789 Bytes
789 Bytes
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_gift.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_gift-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_gift-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
635 Bytes
635 Bytes
635 Bytes
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_plane.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_plane-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_plane-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
1.58 KB
1.58 KB
1.58 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_smile.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_smile-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_smile-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
2.17 KB
2.17 KB
2.17 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_steering_wheel.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_steering_wheel-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_steering_wheel-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
979 Bytes
979 Bytes
979 Bytes
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_up.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_up-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_up-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
744 Bytes
744 Bytes
744 Bytes
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -11,6 +11,8 @@ | ... | @@ -11,6 +11,8 @@ |
11 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; }; | 11 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; }; |
12 | 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; }; | 12 | 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; }; |
13 | 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; }; | 13 | 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; }; |
14 | + 1E7536732822B72500149CC9 /* DetailsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7536722822B72500149CC9 /* DetailsViewInterface.swift */; }; | ||
15 | + 1E7536752822B76000149CC9 /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7536742822B76000149CC9 /* DetailsView.swift */; }; | ||
14 | 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E24281AC96A0089F489 /* OldCouponsView.swift */; }; | 16 | 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E24281AC96A0089F489 /* OldCouponsView.swift */; }; |
15 | 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; }; | 17 | 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; }; |
16 | 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; | 18 | 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; |
... | @@ -156,6 +158,8 @@ | ... | @@ -156,6 +158,8 @@ |
156 | 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; }; | 158 | 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; }; |
157 | 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; }; | 159 | 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; }; |
158 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; }; | 160 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; }; |
161 | + 1E7536722822B72500149CC9 /* DetailsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsViewInterface.swift; sourceTree = "<group>"; }; | ||
162 | + 1E7536742822B76000149CC9 /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; }; | ||
159 | 1E879E24281AC96A0089F489 /* OldCouponsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsView.swift; sourceTree = "<group>"; }; | 163 | 1E879E24281AC96A0089F489 /* OldCouponsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsView.swift; sourceTree = "<group>"; }; |
160 | 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsViewInterface.swift; sourceTree = "<group>"; }; | 164 | 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsViewInterface.swift; sourceTree = "<group>"; }; |
161 | 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; }; | 165 | 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; }; |
... | @@ -359,6 +363,8 @@ | ... | @@ -359,6 +363,8 @@ |
359 | E639EFA0280810E300B9DD94 /* CouponsView.swift */, | 363 | E639EFA0280810E300B9DD94 /* CouponsView.swift */, |
360 | E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */, | 364 | E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */, |
361 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */, | 365 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */, |
366 | + 1E7536722822B72500149CC9 /* DetailsViewInterface.swift */, | ||
367 | + 1E7536742822B76000149CC9 /* DetailsView.swift */, | ||
362 | 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */, | 368 | 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */, |
363 | 1E879E24281AC96A0089F489 /* OldCouponsView.swift */, | 369 | 1E879E24281AC96A0089F489 /* OldCouponsView.swift */, |
364 | 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */, | 370 | 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */, |
... | @@ -827,6 +833,7 @@ | ... | @@ -827,6 +833,7 @@ |
827 | 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */, | 833 | 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */, |
828 | E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */, | 834 | E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */, |
829 | E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */, | 835 | E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */, |
836 | + 1E7536752822B76000149CC9 /* DetailsView.swift in Sources */, | ||
830 | E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */, | 837 | E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */, |
831 | E6D8DEF727A942920006A3A9 /* WLNativeAdsCollectionMode.m in Sources */, | 838 | E6D8DEF727A942920006A3A9 /* WLNativeAdsCollectionMode.m in Sources */, |
832 | E6D8DEF427A942920006A3A9 /* WLCustomNativeCollectionViewCell.m in Sources */, | 839 | E6D8DEF427A942920006A3A9 /* WLCustomNativeCollectionViewCell.m in Sources */, |
... | @@ -849,6 +856,7 @@ | ... | @@ -849,6 +856,7 @@ |
849 | E6D8DEEE27A942920006A3A9 /* WarplyReactMethods.m in Sources */, | 856 | E6D8DEEE27A942920006A3A9 /* WarplyReactMethods.m in Sources */, |
850 | E6D8DEF927A942920006A3A9 /* WLNativeAdCollectionViewCell.m in Sources */, | 857 | E6D8DEF927A942920006A3A9 /* WLNativeAdCollectionViewCell.m in Sources */, |
851 | E634A36B2822999B0069DE27 /* CouponsViewController.swift in Sources */, | 858 | E634A36B2822999B0069DE27 /* CouponsViewController.swift in Sources */, |
859 | + 1E7536732822B72500149CC9 /* DetailsViewInterface.swift in Sources */, | ||
852 | E6D8DF4E27A942920006A3A9 /* FMDatabaseQueue.m in Sources */, | 860 | E6D8DF4E27A942920006A3A9 /* FMDatabaseQueue.m in Sources */, |
853 | E6D8DF0827A942920006A3A9 /* WLBaseItem.m in Sources */, | 861 | E6D8DF0827A942920006A3A9 /* WLBaseItem.m in Sources */, |
854 | E6D8DF0727A942920006A3A9 /* WLInboxItemViewController.m in Sources */, | 862 | E6D8DF0727A942920006A3A9 /* WLInboxItemViewController.m in Sources */, | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
1 | +// | ||
2 | +// DetailsView.swift | ||
3 | +// WarplySDKFrameworkIOS | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 3/5/22. | ||
6 | +// | ||
7 | + | ||
8 | + | ||
9 | +#if canImport(SwiftUI) | ||
10 | +import SwiftUI | ||
11 | +import Combine | ||
12 | +import Foundation | ||
13 | +import UIKit | ||
14 | + | ||
15 | + | ||
16 | +extension DetailsView { | ||
17 | + struct headerView: View { | ||
18 | + var goBack: () -> () | ||
19 | + | ||
20 | + var uiscreen = UIScreen.main.bounds | ||
21 | + | ||
22 | + var body: some View { | ||
23 | + HStack(alignment: .center) { | ||
24 | + Button { | ||
25 | + // Button Action | ||
26 | + print("Back Button tapped!") | ||
27 | + goBack() | ||
28 | + } label: { | ||
29 | + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | ||
30 | + .resizable() | ||
31 | + .aspectRatio(contentMode: .fit) | ||
32 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | ||
33 | + } | ||
34 | + | ||
35 | + Text("Ανάλυση") | ||
36 | + .fontWeight(.medium) | ||
37 | + .font(.system(size: 16)) | ||
38 | + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
39 | + .multilineTextAlignment(.center) | ||
40 | + .frame(maxWidth: .infinity) | ||
41 | + .padding(.horizontal) | ||
42 | + .offset(x: -self.uiscreen.height * 0.025) | ||
43 | + } | ||
44 | + .frame(maxWidth: .infinity) | ||
45 | + .padding(.horizontal) | ||
46 | + .padding(.vertical, 10) | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + struct Tabs: View { | ||
51 | + @Binding var tabs: [String] // The tab titles | ||
52 | + @Binding var selection: Int // Currently selected tab | ||
53 | + | ||
54 | + let uiscreen = UIScreen.main.bounds | ||
55 | + | ||
56 | + var body: some View { | ||
57 | + // Pack the tabs horizontally and allow them to be scrolled | ||
58 | +// GeometryReader { geometry in | ||
59 | +// ScrollView(.horizontal, showsIndicators: false) { | ||
60 | + HStack(alignment: .center, spacing: self.uiscreen.width * 0.05) { | ||
61 | + ForEach(tabs, id: \.self) { | ||
62 | + self.tab(title: $0) | ||
63 | + } | ||
64 | + } | ||
65 | + .padding(.horizontal, self.uiscreen.width * 0.1) | ||
66 | + .frame(maxWidth: .infinity) | ||
67 | + .padding(.vertical, 5) | ||
68 | +// .frame(minWidth: geometry.size.width) | ||
69 | +// } | ||
70 | +// .frame(maxWidth: .infinity) | ||
71 | +// } | ||
72 | +// .frame(maxWidth: .infinity) | ||
73 | +// } | ||
74 | + } | ||
75 | + | ||
76 | + private func tab(title: String) -> some View { | ||
77 | + let index = self.tabs.firstIndex(of: title)! | ||
78 | + let isSelected = index == selection | ||
79 | + | ||
80 | + return Button (action: { | ||
81 | + // // Allows for animated transitions of the underline, | ||
82 | + // // as well as other views on the same screen | ||
83 | + withAnimation { | ||
84 | + self.selection = index | ||
85 | + } | ||
86 | + }) { | ||
87 | + VStack(alignment: .center, spacing: 5.0) { | ||
88 | + Text(title) | ||
89 | + .font(.system(size: 16)) | ||
90 | + .fontWeight(.medium) | ||
91 | + .foregroundColor(isSelected ? Color(red: 0.1803921568627451, green: 0.6980392156862745, blue: 0.7254901960784313) : Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
92 | + .multilineTextAlignment(.center) | ||
93 | + .frame(maxWidth: .infinity) | ||
94 | + | ||
95 | + VStack {} | ||
96 | + .frame(height: 3) | ||
97 | + .frame(width: uiscreen.width * 0.2) | ||
98 | + .foregroundColor(.clear) | ||
99 | + .background(isSelected ? | ||
100 | + LinearGradient(gradient: Gradient(colors: [Color(red: 0.06, green: 0.67, blue: 0.84), Color(red: 0.47, green: 0.75, blue: 0.43)]), startPoint: .leading, endPoint: .trailing) | ||
101 | + : LinearGradient(gradient: Gradient(colors: [.clear, .clear]), startPoint: .leading, endPoint: .trailing) | ||
102 | + ) | ||
103 | + .cornerRadius(20) | ||
104 | + } | ||
105 | + .frame(maxWidth: .infinity) | ||
106 | + } | ||
107 | + .frame(maxWidth: .infinity) | ||
108 | + | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | + struct ImageView: View { | ||
113 | + @ObservedObject var imageLoader:UrlImageModel | ||
114 | + @State var width:CGFloat | ||
115 | + @State var isFill:Bool | ||
116 | + | ||
117 | + var uiscreen = UIScreen.main.bounds | ||
118 | + | ||
119 | + init(withURL url:String , width:CGFloat, isFill:Bool) { | ||
120 | + imageLoader = UrlImageModel(urlString:url) | ||
121 | + self.width = width | ||
122 | + self.isFill = isFill | ||
123 | + } | ||
124 | + | ||
125 | + var body: some View { | ||
126 | + | ||
127 | + Image(uiImage: imageLoader.image ?? UIImage()) | ||
128 | + .resizable() | ||
129 | + .aspectRatio(contentMode: isFill ? .fill : .fit) | ||
130 | + .frame(width: self.width) | ||
131 | + .frame(maxHeight: .infinity) | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
135 | + | ||
136 | + | ||
137 | + struct DropdownOption: Hashable { | ||
138 | + let key: String | ||
139 | + let value: String | ||
140 | + | ||
141 | + public static func == (lhs: DropdownOption, rhs: DropdownOption) -> Bool { | ||
142 | + return lhs.key == rhs.key | ||
143 | + } | ||
144 | + } | ||
145 | + | ||
146 | + struct DropdownRow: View { | ||
147 | + var option: DropdownOption | ||
148 | + var onOptionSelected: ((_ option: DropdownOption) -> Void)? | ||
149 | + | ||
150 | + var body: some View { | ||
151 | + Button(action: { | ||
152 | + if let onOptionSelected = self.onOptionSelected { | ||
153 | + onOptionSelected(self.option) | ||
154 | + } | ||
155 | + }) { | ||
156 | + HStack { | ||
157 | + Text(self.option.value) | ||
158 | + .font(.system(size: 14)) | ||
159 | + .fontWeight(.regular) | ||
160 | + .foregroundColor(Color(red: 0.23529411764705882, green: 0.23137254901960785, blue: 0.2823529411764706)) | ||
161 | + Spacer() | ||
162 | + } | ||
163 | + } | ||
164 | + .padding(.horizontal, 16) | ||
165 | + .padding(.vertical, 5) | ||
166 | + } | ||
167 | + } | ||
168 | + | ||
169 | + struct Dropdown: View { | ||
170 | + var options: [DropdownOption] | ||
171 | + var onOptionSelected: ((_ option: DropdownOption) -> Void)? | ||
172 | + var backColor: Color | ||
173 | + | ||
174 | + var body: some View { | ||
175 | + ScrollView { | ||
176 | + VStack(alignment: .leading, spacing: 0) { | ||
177 | + ForEach(self.options, id: \.self) { option in | ||
178 | + DropdownRow(option: option, onOptionSelected: self.onOptionSelected) | ||
179 | + } | ||
180 | + } | ||
181 | + } | ||
182 | + .frame(minHeight: CGFloat(options.count) * 30, maxHeight: 250) | ||
183 | + .padding(.vertical, 5) | ||
184 | + .background(self.backColor) | ||
185 | + .cornerRadius(8) | ||
186 | + } | ||
187 | + } | ||
188 | + | ||
189 | + struct DropdownSelector: View { | ||
190 | + @State private var shouldShowDropdown = false | ||
191 | + @State private var selectedOption: DropdownOption? = nil | ||
192 | +// var placeholder: String | ||
193 | + var options: [DropdownOption] | ||
194 | + var onOptionSelected: ((_ option: DropdownOption) -> Void)? | ||
195 | + var backColor: Color | ||
196 | + private let buttonHeight: CGFloat = 50 | ||
197 | + | ||
198 | + init(options: [DropdownOption], onOptionSelected: ((_ option: DropdownOption) -> Void)?, backColor: Color) { | ||
199 | + self.selectedOption = options[0] | ||
200 | + self.options = options | ||
201 | + self.onOptionSelected = onOptionSelected | ||
202 | + self.backColor = backColor | ||
203 | + } | ||
204 | + | ||
205 | + var body: some View { | ||
206 | + Button(action: { | ||
207 | + self.shouldShowDropdown.toggle() | ||
208 | + }) { | ||
209 | + HStack { | ||
210 | +// Text(selectedOption == nil ? placeholder : selectedOption!.value) | ||
211 | + Text(selectedOption?.value ?? "") | ||
212 | + .font(.system(size: 14)) | ||
213 | + .fontWeight(.bold) | ||
214 | + .foregroundColor(Color(red: 0.23529411764705882, green: 0.23137254901960785, blue: 0.2823529411764706)) | ||
215 | +// .foregroundColor(selectedOption == nil ? Color.gray: Color.black) | ||
216 | + | ||
217 | + Spacer() | ||
218 | + | ||
219 | + Image((self.shouldShowDropdown ? "ic_up" : "ic_down"), bundle: Bundle(for: MyEmptyClass.self)) | ||
220 | + .resizable() | ||
221 | + .aspectRatio(contentMode: .fit) | ||
222 | + .frame(width: 15, height: 10) | ||
223 | + | ||
224 | + } | ||
225 | + } | ||
226 | + .padding(.horizontal) | ||
227 | + .cornerRadius(5) | ||
228 | + .frame(height: self.buttonHeight) | ||
229 | + .frame(maxWidth: .infinity) | ||
230 | + .overlay( | ||
231 | + VStack { | ||
232 | + if self.shouldShowDropdown { | ||
233 | + Spacer(minLength: buttonHeight + 10) | ||
234 | + Dropdown( | ||
235 | + options: self.options, | ||
236 | + onOptionSelected: { option in | ||
237 | + shouldShowDropdown = false | ||
238 | + selectedOption = option | ||
239 | + self.onOptionSelected?(option) | ||
240 | + }, | ||
241 | + backColor: self.backColor | ||
242 | + ) | ||
243 | + } | ||
244 | + }, alignment: .topLeading | ||
245 | + ) | ||
246 | + .background( | ||
247 | + RoundedRectangle(cornerRadius: 8).fill(self.backColor) | ||
248 | + ) | ||
249 | + } | ||
250 | + } | ||
251 | + | ||
252 | + //MARK:- Chart Data | ||
253 | + struct ChartData: Identifiable { | ||
254 | + var id = UUID() | ||
255 | + var color : Color | ||
256 | + var percent : CGFloat | ||
257 | + var value : CGFloat | ||
258 | + var title : String | ||
259 | + var image : String | ||
260 | + } | ||
261 | + | ||
262 | + class ChartDataContainer : ObservableObject { | ||
263 | + @Published var chartData: Array<ChartData> | ||
264 | + | ||
265 | + | ||
266 | + init(chartData: Array<ChartData>) { | ||
267 | + self.chartData = chartData | ||
268 | + calc() | ||
269 | + } | ||
270 | + | ||
271 | + func calc(){ | ||
272 | + var value : CGFloat = 0 | ||
273 | + | ||
274 | + for i in 0..<chartData.count { | ||
275 | + value += chartData[i].percent | ||
276 | + chartData[i].value = value | ||
277 | + } | ||
278 | + } | ||
279 | + } | ||
280 | + | ||
281 | + //MARK:- Donut Graph | ||
282 | + struct DonutChart : View { | ||
283 | + @ObservedObject var charDataObj: ChartDataContainer | ||
284 | +// @State var indexOfTappedSlice = -1 | ||
285 | + | ||
286 | + var uiscreen = UIScreen.main.bounds | ||
287 | + | ||
288 | + init (charDataObj: ChartDataContainer) { | ||
289 | + self.charDataObj = charDataObj | ||
290 | + } | ||
291 | + | ||
292 | + var body: some View { | ||
293 | + VStack { | ||
294 | + ZStack { | ||
295 | + ForEach(Array(charDataObj.chartData.enumerated()), id: \.offset) { index, item in | ||
296 | + Circle() | ||
297 | + .trim(from: index == 0 ? 0.0 : charDataObj.chartData[index-1].value/100, | ||
298 | + to: charDataObj.chartData[index].value/100) | ||
299 | + .stroke(charDataObj.chartData[index].color,lineWidth: 12) | ||
300 | +// .onTapGesture { | ||
301 | +// indexOfTappedSlice = indexOfTappedSlice == index ? -1 : index | ||
302 | +// } | ||
303 | +// .scaleEffect(index == indexOfTappedSlice ? 1.1 : 1.0) | ||
304 | + .animation(.spring()) | ||
305 | + } | ||
306 | + Image("ic_cosmote_logo", bundle: Bundle(for: MyEmptyClass.self)) | ||
307 | + .resizable() | ||
308 | + .aspectRatio(contentMode: .fit) | ||
309 | + .frame(width: self.uiscreen.width * 0.3, height: self.uiscreen.height * 0.04) | ||
310 | + | ||
311 | +// if indexOfTappedSlice != -1 { | ||
312 | +// Text(String(format: "%.2f", Double(charDataObj.chartData[indexOfTappedSlice].percent))+"%") | ||
313 | +// .font(.title) | ||
314 | +// } | ||
315 | + } | ||
316 | + .frame(width: self.uiscreen.width * 0.5, height: self.uiscreen.width * 0.5) | ||
317 | + .padding() | ||
318 | + .onAppear() { | ||
319 | + self.charDataObj.calc() | ||
320 | + } | ||
321 | + } | ||
322 | + } | ||
323 | + } | ||
324 | + | ||
325 | +} | ||
326 | + | ||
327 | +@available(iOS 13.0.0, *) | ||
328 | +struct DetailsView: View { | ||
329 | + var parentView: UIView | ||
330 | + | ||
331 | + var coupons:Array<swiftApi.CouponItemModel> = [] | ||
332 | + | ||
333 | + var uiscreen = UIScreen.main.bounds | ||
334 | + | ||
335 | + @State private var selectedTab = 0 | ||
336 | + @State private var selectedCouponOption: DropdownOption? = couponOptions[0] | ||
337 | + @State private var selectedRedeemOption: DropdownOption? = redeemOptions[0] | ||
338 | + | ||
339 | + let couponsChartData: Array<ChartData> = [ | ||
340 | + ChartData(color: Color(red: 0.57, green: 0.82, blue: 0.02), percent: 60, value: 0, title: "Διασκέδαση", image: "ic_smile"), | ||
341 | + ChartData(color: Color(red: 0.24, green: 0.32, blue: 0.40), percent: 22, value: 0, title: "Supermarket", image: "ic_cart"), | ||
342 | + ChartData(color: Color(red: 0.14, green: 0.66, blue: 0.71), percent: 18, value: 0, title: "Ταξίδια", image: "ic_plane") | ||
343 | + ] | ||
344 | + | ||
345 | + | ||
346 | + let giftsChartData: Array<ChartData> = [ | ||
347 | + ChartData(color: Color(red: 0.57, green: 0.82, blue: 0.02), percent: 50, value: 0, title: "Δώρο Γενεθλίων", image: "ic_gift"), | ||
348 | + ChartData(color: Color(red: 0.24, green: 0.32, blue: 0.40), percent: 50, value: 0, title: "Safe driving", image: "ic_steering_wheel") | ||
349 | + ] | ||
350 | + | ||
351 | + @State var charDataObj: ChartDataContainer | ||
352 | + | ||
353 | + static var uniqueKey: String { | ||
354 | + UUID().uuidString | ||
355 | + } | ||
356 | + | ||
357 | + static let couponOptions: [DropdownOption] = [ | ||
358 | + DropdownOption(key: uniqueKey, value: "Κουπόνια"), | ||
359 | + DropdownOption(key: uniqueKey, value: "Δώρα"), | ||
360 | + ] | ||
361 | + | ||
362 | + static let redeemOptions: [DropdownOption] = [ | ||
363 | + DropdownOption(key: uniqueKey, value: "Εξαργύρωση"), | ||
364 | + DropdownOption(key: uniqueKey, value: "Συλλογή"), | ||
365 | + ] | ||
366 | + | ||
367 | + init(parentView: UIView) { //initializer method | ||
368 | + | ||
369 | + let instanceOfMySwiftApi = swiftApi() | ||
370 | + let couponsData = instanceOfMySwiftApi.getCoupons() | ||
371 | + | ||
372 | + self.coupons = couponsData | ||
373 | + self.parentView = parentView | ||
374 | + | ||
375 | + self.charDataObj = ChartDataContainer(chartData: couponsChartData) | ||
376 | + } | ||
377 | + | ||
378 | + func goBack(){ | ||
379 | + for subview in parentView.subviews { | ||
380 | + if(subview.tag == 10) { | ||
381 | + subview.removeFromSuperview() | ||
382 | + } | ||
383 | + } | ||
384 | + } | ||
385 | + | ||
386 | + var body: some View { | ||
387 | + | ||
388 | + VStack { | ||
389 | + headerView(goBack: goBack) | ||
390 | + | ||
391 | + Tabs(tabs: .constant(["Μηνιαία", "6Μηνο", "12Μηνο"]), | ||
392 | + selection: $selectedTab) | ||
393 | + | ||
394 | + VStack { | ||
395 | + GeometryReader { geometry in | ||
396 | + ScrollView(showsIndicators: false) { | ||
397 | + VStack { | ||
398 | + VStack { | ||
399 | + | ||
400 | + DropdownSelector( | ||
401 | + // placeholder: "Δώρα", | ||
402 | + options: DetailsView.couponOptions, | ||
403 | + onOptionSelected: { option in | ||
404 | + print(option) | ||
405 | + selectedCouponOption = option | ||
406 | + | ||
407 | + if (option == DetailsView.couponOptions[0]) { | ||
408 | + self.charDataObj = ChartDataContainer(chartData: couponsChartData) | ||
409 | + } else { | ||
410 | + self.charDataObj = ChartDataContainer(chartData: giftsChartData) | ||
411 | + } | ||
412 | + }, | ||
413 | + backColor: Color(red: 0.9607843137254902, green: 0.9607843137254902, blue: 0.9607843137254902) | ||
414 | + ) | ||
415 | + .padding(.horizontal, 25) | ||
416 | + .padding(.top, self.uiscreen.height * 0.02) | ||
417 | + .zIndex(2) | ||
418 | + | ||
419 | + DonutChart(charDataObj: self.charDataObj) | ||
420 | + .padding(.vertical, self.uiscreen.height * 0.03) | ||
421 | + | ||
422 | + DropdownSelector( | ||
423 | + // placeholder: "Δώρα", | ||
424 | + options: DetailsView.redeemOptions, | ||
425 | + onOptionSelected: { option in | ||
426 | + selectedRedeemOption = option | ||
427 | + }, | ||
428 | + backColor: Color(red: 0.9333333333333333, green: 0.9686274509803922, blue: 1.0) | ||
429 | + ) | ||
430 | + .padding(.horizontal, 25) | ||
431 | + .zIndex(1) | ||
432 | + | ||
433 | + VStack { | ||
434 | + VStack(spacing: self.uiscreen.width * 0.06) { | ||
435 | + ForEach(Array(charDataObj.chartData.enumerated()), id: \.offset) { index, item in | ||
436 | + HStack { | ||
437 | + Image(charDataObj.chartData[index].image, bundle: Bundle(for: MyEmptyClass.self)) | ||
438 | + .resizable() | ||
439 | + .aspectRatio(contentMode: .fit) | ||
440 | + .frame(width: self.uiscreen.height * 0.02, height: self.uiscreen.height * 0.02) | ||
441 | + | ||
442 | + Text(charDataObj.chartData[index].title) | ||
443 | + .fontWeight(.medium) | ||
444 | + .font(.system(size: 14)) | ||
445 | + .foregroundColor(Color(red: 0.30196078431372547, green: 0.2980392156862745, blue: 0.34509803921568627)) | ||
446 | + .padding(.horizontal) | ||
447 | + | ||
448 | + Spacer() | ||
449 | + | ||
450 | +// Text(String(format: "%.2f", Double(charDataObj.chartData[index].percent))+"%") | ||
451 | + Text(String(format: "%.0f", Double(charDataObj.chartData[index].percent))+"%") | ||
452 | + .fontWeight(.medium) | ||
453 | + .font(.system(size: 16)) | ||
454 | + .foregroundColor(charDataObj.chartData[index].color) | ||
455 | + } | ||
456 | + .frame(maxWidth: .infinity) | ||
457 | + } | ||
458 | + } | ||
459 | + .padding(.all, self.uiscreen.width * 0.06) | ||
460 | + .frame(maxWidth: .infinity) | ||
461 | + } | ||
462 | + .frame(width:self.uiscreen.width * 0.86) | ||
463 | +// .frame(maxHeight: .infinity) | ||
464 | + .background(Color(red: 0.9490196078431372, green: 0.9490196078431372, blue: 0.9490196078431372, opacity: 0.49)) | ||
465 | + .cornerRadius(10) | ||
466 | + .padding(.top, self.uiscreen.height * 0.04) | ||
467 | + | ||
468 | + Spacer() | ||
469 | + | ||
470 | + VStack(alignment: .center) { | ||
471 | + Button { | ||
472 | + // Button Action | ||
473 | + print("More Details Button tapped!") | ||
474 | + } label: { | ||
475 | + HStack { | ||
476 | + Text("Αναλυτικά") | ||
477 | + .fontWeight(.medium) | ||
478 | + .font(.system(size: 16)) | ||
479 | + .foregroundColor(Color.white) | ||
480 | + .multilineTextAlignment(.center) | ||
481 | + .padding(.all) | ||
482 | + } | ||
483 | + .frame(maxWidth: .infinity) | ||
484 | + } | ||
485 | + .frame(width: self.uiscreen.width * 0.8) | ||
486 | + .background(Color(red: 0.4745098039215686, green: 0.7490196078431373, blue: 0.0784313725490196)) | ||
487 | + .cornerRadius(7) | ||
488 | + } | ||
489 | + .frame(maxWidth: .infinity) | ||
490 | + .padding(.top, self.uiscreen.height * 0.04) | ||
491 | + .padding(.bottom, self.uiscreen.height * 0.02) | ||
492 | +// .padding(.horizontal, 25) | ||
493 | + | ||
494 | + } | ||
495 | + .frame(width:self.uiscreen.width * 0.93) | ||
496 | + .frame(maxHeight: .infinity) | ||
497 | + .background(Color.white) | ||
498 | + .cornerRadius(10) | ||
499 | + } | ||
500 | + .padding(.vertical, self.uiscreen.height * 0.02) | ||
501 | + .frame(minHeight: geometry.size.height) | ||
502 | +// .frame(maxHeight: .infinity) | ||
503 | + | ||
504 | + } | ||
505 | + .cornerRadius(10, corners: [.topLeft]) | ||
506 | + .frame(width:self.uiscreen.width) | ||
507 | + .frame(maxHeight: .infinity) | ||
508 | + } | ||
509 | + .frame(width:self.uiscreen.width) | ||
510 | + .frame(maxHeight: .infinity) | ||
511 | + } | ||
512 | + .frame(width:self.uiscreen.width) | ||
513 | + .frame(maxHeight: .infinity) | ||
514 | + .padding(.top, 5) | ||
515 | + .background( | ||
516 | + Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self)) | ||
517 | + .resizable() | ||
518 | + ) | ||
519 | + | ||
520 | + } | ||
521 | + .edgesIgnoringSafeArea([.bottom]) | ||
522 | + .frame(width:self.uiscreen.width) | ||
523 | + .frame(maxHeight: .infinity) | ||
524 | + } | ||
525 | +} | ||
526 | +#endif | ||
527 | + | ||
528 | +//struct DetailsView_Previews: PreviewProvider { | ||
529 | +// static var previews: some View { | ||
530 | +// DetailsView() | ||
531 | +// } | ||
532 | +//} |
1 | +// | ||
2 | +// DetailsViewInterface.swift | ||
3 | +// WarplySDKFrameworkIOS | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 3/5/22. | ||
6 | +// | ||
7 | + | ||
8 | +import Foundation | ||
9 | +import SwiftUI | ||
10 | + | ||
11 | +@available(iOS 13.0.0, *) | ||
12 | +@objc public class DetailsViewInterface : NSObject { | ||
13 | + | ||
14 | + @objc(detailsViewController:) static public func detailsViewController(parentView: UIView?) -> UIViewController { | ||
15 | + return UIHostingController(rootView: DetailsView(parentView: parentView!)) | ||
16 | + } | ||
17 | + | ||
18 | +} |
... | @@ -29,6 +29,7 @@ | ... | @@ -29,6 +29,7 @@ |
29 | - (UIViewController *) openMoreForYou:(UIView*) parentView; | 29 | - (UIViewController *) openMoreForYou:(UIView*) parentView; |
30 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; | 30 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; |
31 | - (UIViewController *) openSteps:(UIView*) parentView; | 31 | - (UIViewController *) openSteps:(UIView*) parentView; |
32 | +- (UIViewController *) openDetails:(UIView*) parentView; | ||
32 | - (NSDictionary *) provideInfoForCampaign; | 33 | - (NSDictionary *) provideInfoForCampaign; |
33 | - (void) applicationDidEnterBackground:(UIApplication *)application; | 34 | - (void) applicationDidEnterBackground:(UIApplication *)application; |
34 | - (void) applicationWillEnterForeground:(UIApplication *)application; | 35 | - (void) applicationWillEnterForeground:(UIApplication *)application; | ... | ... |
... | @@ -150,6 +150,12 @@ CMPedometer *pedometer; | ... | @@ -150,6 +150,12 @@ CMPedometer *pedometer; |
150 | return stepsViewController; | 150 | return stepsViewController; |
151 | } | 151 | } |
152 | 152 | ||
153 | +- (UIViewController *) openDetails:(UIView*) parentView{ | ||
154 | + | ||
155 | + UIViewController *detailsViewController = [DetailsViewInterface detailsViewController:parentView]; | ||
156 | + return detailsViewController; | ||
157 | +} | ||
158 | + | ||
153 | - (NSDictionary *) provideInfoForCampaign { | 159 | - (NSDictionary *) provideInfoForCampaign { |
154 | NSMutableDictionary* info = [[NSMutableDictionary alloc] init]; | 160 | NSMutableDictionary* info = [[NSMutableDictionary alloc] init]; |
155 | info[@"web_id"] = [Warply sharedService].webId; | 161 | info[@"web_id"] = [Warply sharedService].webId; | ... | ... |
-
Please register or login to post a comment