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
Vasilis
2022-04-19 22:58:49 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c75461017be75015fd097946fd0949b459375b1a
c7546101
1 parent
f263c944
fix for navigating back from coupons and more
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
75 deletions
WarplySDKFrameworkIOS/Warply/Warply.m
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponsView.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponsViewInterface.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.h
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
WarplySDKFrameworkIOS/Warply/Warply.m
View file @
c754610
This diff could not be displayed because it is too large.
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
View file @
c754610
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponsView.swift
View file @
c754610
...
...
@@ -7,6 +7,9 @@
#if canImport(SwiftUI)
import
SwiftUI
import
Combine
import
Foundation
class
DataModel
{
var
data
:
Array
<
NSDictionary
>
=
[]
...
...
@@ -50,63 +53,42 @@ class DataModel {
}
}
struct
UrlImageView
:
View
{
@ObservedObject
var
urlImageModel
:
UrlImageModel
init
(
urlString
:
String
?)
{
urlImageModel
=
UrlImageModel
(
urlString
:
urlString
)
class
ImageLoader
:
ObservableObject
{
var
didChange
=
PassthroughSubject
<
Data
,
Never
>
()
var
data
=
Data
()
{
didSet
{
didChange
.
send
(
data
)
}
}
var
body
:
some
View
{
Image
(
uiImage
:
urlImageModel
.
image
??
UrlImageView
.
defaultImage
!
)
.
resizable
()
.
scaledToFill
()
init
(
urlString
:
String
)
{
guard
let
url
=
URL
(
string
:
urlString
)
else
{
return
}
let
task
=
URLSession
.
shared
.
dataTask
(
with
:
url
)
{
data
,
response
,
error
in
guard
let
data
=
data
else
{
return
}
DispatchQueue
.
main
.
async
{
self
.
data
=
data
}
}
task
.
resume
()
}
static
var
defaultImage
=
UIImage
(
systemName
:
"photo"
)
}
class
UrlImageModel
:
ObservableObject
{
@
Published
var
image
:
UIImage
?
var
urlString
:
String
?
struct
ImageView
:
View
{
@
ObservedObject
var
imageLoader
:
ImageLoader
@State
var
image
:
UIImage
=
UIImage
()
init
(
urlString
:
String
?)
{
self
.
urlString
=
urlString
loadImage
()
init
(
withURL
url
:
String
)
{
imageLoader
=
ImageLoader
(
urlString
:
url
)
}
func
loadImage
()
{
loadImageFromUrl
()
}
func
loadImageFromUrl
()
{
guard
let
urlString
=
urlString
else
{
return
}
let
url
=
URL
(
string
:
urlString
)
!
let
task
=
URLSession
.
shared
.
dataTask
(
with
:
url
,
completionHandler
:
getImageFromResponse
(
data
:
response
:
error
:))
task
.
resume
()
}
func
getImageFromResponse
(
data
:
Data
?,
response
:
URLResponse
?,
error
:
Error
?)
{
guard
error
==
nil
else
{
print
(
"Error:
\(
error
!
)
"
)
return
}
guard
let
data
=
data
else
{
print
(
"No data found"
)
return
}
var
body
:
some
View
{
DispatchQueue
.
main
.
async
{
guard
let
loadedImage
=
UIImage
(
data
:
data
)
else
{
return
}
self
.
image
=
loadedImage
Image
(
uiImage
:
image
)
.
resizable
()
.
aspectRatio
(
contentMode
:
.
fit
)
// .frame(width:100, height:100)
.
onReceive
(
imageLoader
.
didChange
)
{
data
in
self
.
image
=
UIImage
(
data
:
data
)
??
UIImage
()
}
}
}
...
...
@@ -117,41 +99,61 @@ extension CouponsView {
var
uiscreen
=
UIScreen
.
main
.
bounds
var
body
:
some
View
{
Z
Stack
{
H
Stack
{
Image
(
"ic_back"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
.
resizable
()
.
frame
(
width
:
self
.
uiscreen
.
height
*
0.025
,
height
:
self
.
uiscreen
.
height
*
0.02
)
.
offset
(
x
:
-
self
.
uiscreen
.
width
/
2
+
self
.
uiscreen
.
width
*
0.05
,
y
:
self
.
uiscreen
.
height
*
0.0
7
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.025
,
height
:
self
.
uiscreen
.
height
*
0.02
)
.
offset
(
x
:
-
self
.
uiscreen
.
width
/
2
+
self
.
uiscreen
.
width
*
0.05
,
y
:
self
.
uiscreen
.
height
*
0.0
4
)
Text
(
"Όλα τα κουπόνια μου"
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.8
,
height
:
self
.
uiscreen
.
height
*
0.025
,
alignment
:
.
center
)
.
offset
(
y
:
self
.
uiscreen
.
height
*
0.07
)
.
frame
(
width
:
self
.
uiscreen
.
width
)
.
offset
(
y
:
self
.
uiscreen
.
height
*
0.04
)
}
.
frame
(
width
:
self
.
uiscreen
.
width
,
height
:
self
.
uiscreen
.
height
*
0.12
)
}
}
struct
couponView
:
View
{
var
result
:
NSDictionary
var
index
:
Int
var
uiscreen
=
UIScreen
.
main
.
bounds
static
func
localizedWithParameter
(
parameter
:
String
)
->
LocalizedStringKey
{
return
"
\(
parameter
)
"
}
var
body
:
some
View
{
ZStack
{
UrlImageView
(
urlString
:
result
[
"img_preview"
]
as?
String
)
.
frame
(
width
:
self
.
uiscreen
.
height
*
0.25
,
height
:
self
.
uiscreen
.
height
*
0.05
,
alignment
:
.
leading
)
.
offset
(
x
:
self
.
uiscreen
.
width
*
0.05
,
y
:
self
.
uiscreen
.
height
*
0.06
)
HStack
(
alignment
:
.
center
)
{
HStack
(
alignment
:
.
center
)
{
ImageView
(
withURL
:
result
[
"img_preview"
]
as!
String
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.2
,
height
:
self
.
uiscreen
.
height
*
0.05
)
// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.2, y: -self.uiscreen.height * 0.05 * 0.96)
// .padding(.leading, self.uiscreen.width * 0.05)
Rectangle
()
.
frame
(
width
:
1
,
height
:
self
.
uiscreen
.
height
*
0.1
*
0.93
)
// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.205, y: -self.uiscreen.height * 0.05 * 0.93)
VStack
{
Text
(
CouponsView
.
couponView
.
localizedWithParameter
(
parameter
:
result
[
"admin_name"
]
as!
String
))
Text
(
CouponsView
.
couponView
.
localizedWithParameter
(
parameter
:
result
[
"discount"
]
as!
String
))
Text
(
CouponsView
.
couponView
.
localizedWithParameter
(
parameter
:
"Ισχύει εώς "
+
(
result
[
"expiration"
]
as!
String
)
.
components
(
separatedBy
:
[
" "
])
.
filter
({
!
$0
.
isEmpty
})[
0
]))
}
.
frame
(
maxHeight
:
.
infinity
)
VStack
{
Text
(
CouponsView
.
couponView
.
localizedWithParameter
(
parameter
:
result
[
"short_description"
]
as!
String
))
}
.
frame
(
maxWidth
:
self
.
uiscreen
.
width
*
0.15
,
maxHeight
:
.
infinity
)
}
.
frame
(
maxWidth
:
.
infinity
,
maxHeight
:
.
infinity
)
}
.
background
(
Image
(
"coupons_container"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
.
resizable
()
.
offset
(
x
:
self
.
uiscreen
.
width
*
0.05
,
y
:
(
CGFloat
(
index
+
1
)
*
self
.
uiscreen
.
height
*
0.06
)
+
CGFloat
(
index
)
*
self
.
uiscreen
.
height
*
0.17
)
.
padding
()
.
frame
(
width
:
UIScreen
.
main
.
bounds
.
width
*
0.9
,
height
:
UIScreen
.
main
.
bounds
.
height
*
0.17
,
alignment
:
.
topLeading
)
)
// .padding(.top, self.uiscreen.height * 0.05)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.9
,
height
:
self
.
uiscreen
.
height
*
0.1
)
.
background
(
Color
.
purple
)
}
}
...
...
@@ -174,10 +176,12 @@ struct CouponsView: View {
couponView
(
result
:
result
,
index
:
index
)
}
}
}
.
frame
(
width
:
self
.
uiscreen
.
width
,
height
:
self
.
uiscreen
.
height
)
}
}
}
.
frame
(
width
:
self
.
uiscreen
.
width
,
height
:
self
.
uiscreen
.
height
*
0.88
)
}
.
frame
(
width
:
self
.
uiscreen
.
width
,
height
:
self
.
uiscreen
.
height
)
.
background
(
Color
.
red
)
}
}
#endif
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponsViewInterface.swift
View file @
c754610
...
...
@@ -11,8 +11,8 @@ import SwiftUI
@available(iOS 13.0.0, *)
@objc
public
class
CouponsViewInterface
:
NSObject
{
@objc
static
public
func
couponsViewController
(
)
->
UIViewController
{
return
UIHostingController
(
rootView
:
CouponsView
())
@objc
(couponsViewController:)
static
public
func
couponsViewController
(
parentView
:
UIView
?
)
->
UIViewController
{
return
UIHostingController
(
rootView
:
CouponsView
(
parentView
:
parentView
!
))
}
}
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.h
View file @
c754610
...
...
@@ -15,7 +15,7 @@
+
(
void
)
init
:(
NSDictionary
*
)
launchOptions
uuid
:(
NSString
*
)
uuid
merchantId
:(
NSString
*
)
merchantId
lang
:(
NSString
*
)
lang
;
-
(
void
)
setToStage
;
-
(
void
)
setLang
:(
NSString
*
)
lang
;
-
(
UIViewController
*
)
openCoupons
;
-
(
UIViewController
*
)
openCoupons
:(
UIView
*
)
parentView
;
-
(
void
)
applicationDidEnterBackground
:(
UIApplication
*
)
application
;
-
(
void
)
applicationWillEnterForeground
:(
UIApplication
*
)
application
;
-
(
void
)
applicationDidBecomeActive
:(
UIApplication
*
)
application
;
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
View file @
c754610
...
...
@@ -46,12 +46,8 @@ NSString *LANG;
LANG
=
lang
;
}
-
(
UIViewController
*
)
openCoupons
{
UIViewController
*
couponsViewController
=
[
CouponsViewInterface
couponsViewController
];
// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController];
// [window makeKeyAndVisible];
-
(
UIViewController
*
)
openCoupons
:
(
UIView
*
)
parentView
{
UIViewController
*
couponsViewController
=
[
CouponsViewInterface
couponsViewController
:
parentView
];
return
couponsViewController
;
}
...
...
Please
register
or
login
to post a comment