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
2022-04-26 14:18:17 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a3a5baf02499cad5c90553e0ea050a1119af8a13
a3a5baf0
1 parent
a16260ed
add CouponBarcodeView v3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
64 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponBarcodeView.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/CouponBarcodeView.swift
View file @
a3a5baf
...
...
@@ -10,7 +10,8 @@ import SwiftUI
import
Combine
import
Foundation
import
UIKit
//import RSBarcodes_Swift
//import AVFoundation
extension
CouponBarcodeView
{
...
...
@@ -65,56 +66,136 @@ extension CouponBarcodeView {
}
}
func
generateBarcode
(
from
string
:
String
)
->
Image
?
{
let
data
=
string
.
data
(
using
:
String
.
Encoding
.
ascii
)
if
let
filter
=
CIFilter
(
name
:
"CICode128BarcodeGenerator"
)
{
filter
.
setValue
(
data
,
forKey
:
"inputMessage"
)
// let transform = CGAffineTransform(scaleX: 3, y: 3)
// if let output = filter.outputImage?.transformed(by: transform) {
if
let
output
=
filter
.
outputImage
{
// // Change the color using CIFilter
// let colorParameters = [
// "inputColor0": CIColor(color: UIColor.black), // Foreground
// "inputColor1": CIColor(color: UIColor.clear) // Background
// ]
// let colored = output.applyingFilter("CIFalseColor", parameters: colorParameters)
let
image
=
Image
(
uiImage
:
UIImage
(
ciImage
:
output
))
// return UIImage(ciImage: output)
return
image
}
}
return
nil
}
var
body
:
some
View
{
GeometryReader
{
geometry
in
ScrollView
(
showsIndicators
:
false
)
{
VStack
(
alignment
:
.
leading
)
{
ImageView
(
withURL
:
coupon
[
"img_preview"
]
as?
String
??
""
)
Text
(
coupon
[
"name"
]
as?
String
??
""
)
.
fontWeight
(
.
bold
)
.
font
(
.
system
(
size
:
16
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
leading
)
.
padding
(
.
horizontal
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.04
)
Text
(
coupon
[
"short_description"
]
as?
String
??
""
)
.
fontWeight
(
.
regular
)
.
font
(
.
system
(
size
:
14
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
leading
)
.
padding
(
.
horizontal
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.02
)
VStack
(
alignment
:
.
center
)
{
VStack
{}
.
frame
(
height
:
1
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.9
)
.
background
(
Color
(
red
:
0.9019607843137255
,
green
:
0.9019607843137255
,
blue
:
0.9019607843137255
))
}
.
frame
(
maxWidth
:
.
infinity
)
VStack
(
alignment
:
.
center
)
{
VStack
{}
.
frame
(
height
:
1
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.9
)
.
background
(
Color
(
red
:
0.9019607843137255
,
green
:
0.9019607843137255
,
blue
:
0.9019607843137255
))
VStack
(
alignment
:
.
leading
)
{
Text
(
coupon
[
"name"
]
as?
String
??
""
)
.
fontWeight
(
.
bold
)
.
font
(
.
system
(
size
:
16
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
leading
)
.
padding
(
.
horizontal
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.04
)
Text
(
coupon
[
"short_description"
]
as?
String
??
""
)
.
fontWeight
(
.
regular
)
.
font
(
.
system
(
size
:
14
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
leading
)
.
padding
(
.
horizontal
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.02
)
Text
(
"Κωδικός Κουπονιού"
)
.
fontWeight
(
.
medium
)
.
font
(
.
system
(
size
:
16
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.05
)
.
padding
(
.
horizontal
)
.
frame
(
maxWidth
:
.
infinity
)
VStack
(
alignment
:
.
center
)
{
VStack
{
Text
(
"1A2C378"
)
.
fontWeight
(
.
bold
)
.
font
(
.
system
(
size
:
27
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
horizontal
)
.
padding
(
.
vertical
,
10
)
// .padding(.all)
}
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.8
)
.
background
(
Color
(
red
:
0.9333333333333333
,
green
:
0.9686274509803922
,
blue
:
1.0
))
.
cornerRadius
(
10
)
}
.
frame
(
maxWidth
:
.
infinity
)
if
(
CharacterSet
.
decimalDigits
.
isSuperset
(
of
:
CharacterSet
(
charactersIn
:
"123456789101112"
)))
{
VStack
(
alignment
:
.
center
)
{
VStack
{}
.
frame
(
height
:
1
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.9
)
.
background
(
Color
(
red
:
0.9019607843137255
,
green
:
0.9019607843137255
,
blue
:
0.9019607843137255
))
}
.
frame
(
maxWidth
:
.
infinity
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.015
)
// TODO: Add the barcode
// generateBarcode(from: "1234567891234")
// ?
// .resizable()
// .aspectRatio(contentMode: .fit)
// .frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1)
Text
(
"123456789101112"
)
.
fontWeight
(
.
regular
)
.
font
(
.
system
(
size
:
22
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
vertical
,
self
.
uiscreen
.
height
*
0.01
)
.
padding
(
.
horizontal
)
.
frame
(
maxWidth
:
.
infinity
)
VStack
(
alignment
:
.
center
)
{
VStack
{}
.
frame
(
height
:
1
)
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.9
)
.
background
(
Color
(
red
:
0.9019607843137255
,
green
:
0.9019607843137255
,
blue
:
0.9019607843137255
))
}
.
frame
(
maxWidth
:
.
infinity
)
}
Text
(
"Το κουπόνι ισχύει έως "
+
CouponBarcodeView
.
couponContainer
.
convertDateFormat
(
inputDate
:
coupon
[
"expiration"
]
as?
String
??
""
))
.
fontWeight
(
.
medium
)
.
font
(
.
system
(
size
:
14
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.03
)
.
padding
(
.
horizontal
)
.
frame
(
maxWidth
:
.
infinity
)
}
.
frame
(
maxWidth
:
.
infinity
)
.
frame
(
width
:
self
.
uiscreen
.
width
)
Text
(
"Το κουπόνι ισχύει έως "
+
CouponBarcodeView
.
couponContainer
.
convertDateFormat
(
inputDate
:
coupon
[
"img_preview"
]
as?
String
??
""
))
.
fontWeight
(
.
medium
)
.
font
(
.
system
(
size
:
14
))
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.03
)
.
padding
(
.
horizontal
)
.
frame
(
maxWidth
:
.
infinity
)
Spacer
()
...
...
@@ -130,35 +211,39 @@ extension CouponBarcodeView {
.
foregroundColor
(
Color
(
red
:
0.3137254901960784
,
green
:
0.6196078431372549
,
blue
:
0.1843137254901961
))
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
all
)
// TODO: Add gift icon
}
.
frame
(
maxWidth
:
.
infinity
)
}
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.8
)
.
background
(
Color
(
red
:
0.9019607843137255
,
green
:
0.9019607843137255
,
blue
:
0.9019607843137255
))
.
cornerRadius
(
7
)
}
.
frame
(
maxWidth
:
.
infinity
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.
1
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.
05
)
VStack
(
alignment
:
.
center
)
{
Button
{
// Button Action
print
(
"Shops Map Button tapped!"
)
}
label
:
{
HStack
{
Text
(
"Χάρτης Καταστημάτων"
)
.
fontWeight
(
.
medium
)
.
font
(
.
system
(
size
:
16
))
.
foregroundColor
(
Color
.
white
)
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
all
)
}
}
.
frame
(
width
:
self
.
uiscreen
.
width
*
0.8
)
.
background
(
Color
(
red
:
0.4745098039215686
,
green
:
0.7490196078431373
,
blue
:
0.0784313725490196
))
.
cornerRadius
(
7
)
}
.
frame
(
maxWidth
:
.
infinity
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.02
)
// VStack(alignment: .center) {
// Button {
// // Button Action
// print("Shops Map Button tapped!")
// } label: {
// HStack {
// Text("Χάρτης Καταστημάτων")
// .fontWeight(.medium)
// .font(.system(size: 16))
// .foregroundColor(Color.white)
// .multilineTextAlignment(.center)
// .padding(.all)
// }
// .frame(maxWidth: .infinity)
// }
// .frame(width: self.uiscreen.width * 0.8)
// .background(Color(red: 0.4745098039215686, green: 0.7490196078431373, blue: 0.0784313725490196))
// .cornerRadius(7)
// }
// .frame(maxWidth: .infinity)
// .padding(.top, self.uiscreen.height * 0.015)
Button
{
// Button Action
...
...
@@ -170,7 +255,8 @@ extension CouponBarcodeView {
.
foregroundColor
(
Color
(
red
:
0.2549019607843137
,
green
:
0.3333333333333333
,
blue
:
0.39215686274509803
))
.
underline
()
.
multilineTextAlignment
(
.
center
)
.
padding
(
.
vertical
,
self
.
uiscreen
.
height
*
0.03
)
.
padding
(
.
top
,
self
.
uiscreen
.
height
*
0.025
)
.
padding
(
.
bottom
,
self
.
uiscreen
.
height
*
0.03
)
.
padding
(
.
horizontal
)
.
frame
(
maxWidth
:
.
infinity
)
}
...
...
Please
register
or
login
to post a comment