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
2023-03-15 16:43:59 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9537ccc494bcd3e65ed61c8e2615d6dd7f970ff4
9537ccc4
1 parent
c041ba9f
Add merchant description to CouponBarcodeVC
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
2 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/CouponBarcodeViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
9537ccc
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/CouponBarcodeViewController.swift
View file @
9537ccc
...
...
@@ -10,7 +10,7 @@ import UIKit
import
AVFoundation
// import SwiftEventBus
@objc
public
class
CouponBarcodeViewController
:
UIViewController
{
@objc
public
class
CouponBarcodeViewController
:
UIViewController
,
UITextViewDelegate
{
@IBOutlet
weak
var
mainView
:
UIView
!
@IBOutlet
weak
var
backgroundImage
:
UIImageView
!
@IBOutlet
weak
var
scrollView
:
UIScrollView
!
...
...
@@ -19,6 +19,9 @@ import AVFoundation
@IBOutlet
weak
var
couponImageHeight
:
NSLayoutConstraint
!
@IBOutlet
weak
var
nameLabel
:
UILabel
!
@IBOutlet
weak
var
discriptionLabel
:
UILabel
!
@IBOutlet
weak
var
merchantDescrTextView
:
UnselectableTappableTextView
!
@IBOutlet
weak
var
merchantDescrTextViewHeight
:
NSLayoutConstraint
!
@IBOutlet
weak
var
merchantDescrTextViewTopSpace
:
NSLayoutConstraint
!
@IBOutlet
weak
var
couponView
:
UIView
!
@IBOutlet
weak
var
couponNumberLabel
:
CopyableLabel
!
@IBOutlet
weak
var
barcodeImage
:
UIImageView
!
...
...
@@ -29,7 +32,7 @@ import AVFoundation
@IBOutlet
weak
var
expirationLabel
:
UILabel
!
@IBOutlet
weak
var
redeemButton
:
UIButton
!
@IBOutlet
weak
var
termsButton
:
UIButton
!
@IBOutlet
weak
var
termsTextView
:
U
I
TextView
!
@IBOutlet
weak
var
termsTextView
:
U
nselectableTappable
TextView
!
@IBOutlet
weak
var
termsTextViewHeight
:
NSLayoutConstraint
!
@IBOutlet
weak
var
borderViewHeight
:
NSLayoutConstraint
!
@IBOutlet
weak
var
borderView2Height
:
NSLayoutConstraint
!
...
...
@@ -60,6 +63,8 @@ import AVFoundation
super
.
viewDidLoad
()
self
.
hidesBottomBarWhenPushed
=
true
merchantDescrTextView
.
delegate
=
self
termsTextView
.
delegate
=
self
// Do any additional setup after loading the view.
setBackButton
()
...
...
@@ -101,6 +106,38 @@ import AVFoundation
nameLabel
.
text
=
couponSetData
?
.
name
??
""
discriptionLabel
.
text
=
couponSetData
?
.
short_description
??
""
merchantDescrTextView
.
text
=
""
merchantDescrTextViewTopSpace
.
constant
=
CGFloat
(
0
)
merchantDescrTextViewHeight
.
constant
=
CGFloat
(
0
)
merchantDescrTextView
.
isHidden
=
true
let
merchantList
:
Array
<
swiftApi
.
MerchantModel
>
=
swiftApi
()
.
getMerchantList
()
for
merchant
in
merchantList
{
if
(
merchant
.
_uuid
==
couponSetData
?
.
merchant_uuid
)
{
let
htmlMerchDescrText
=
merchant
.
_body
if
(
htmlMerchDescrText
!=
""
)
{
merchantDescrTextView
.
attributedText
=
htmlMerchDescrText
.
htmlToAttributedString
merchantDescrTextView
.
font
=
UIFont
(
name
:
"PFSquareSansPro-Regular"
,
size
:
17
)
merchantDescrTextView
.
textColor
=
UIColor
(
red
:
0.25
,
green
:
0.33
,
blue
:
0.39
,
alpha
:
1.00
)
merchantDescrTextView
.
textAlignment
=
.
center
merchantDescrTextView
.
isScrollEnabled
=
false
merchantDescrTextView
.
isUserInteractionEnabled
=
true
merchantDescrTextView
.
isEditable
=
false
merchantDescrTextView
.
isSelectable
=
true
merchantDescrTextView
.
dataDetectorTypes
=
[
.
link
]
merchantDescrTextView
.
isHidden
=
false
merchantDescrTextViewTopSpace
.
constant
=
CGFloat
(
15
)
let
targetSize
=
CGSize
(
width
:
merchantDescrTextView
.
frame
.
width
,
height
:
CGFloat
(
MAXFLOAT
))
merchantDescrTextViewHeight
.
constant
=
merchantDescrTextView
.
sizeThatFits
(
targetSize
)
.
height
}
break
;
}
}
couponView
.
layer
.
cornerRadius
=
8
couponNumberLabel
.
text
=
coupon
?
.
coupon
??
""
couponView
.
frame
=
CGRect
(
x
:
0.0
,
y
:
0.0
,
width
:
couponView
.
intrinsicContentSize
.
width
,
height
:
55
)
...
...
@@ -246,6 +283,11 @@ import AVFoundation
termsTextView
.
textAlignment
=
.
center
termsTextView
.
isScrollEnabled
=
false
termsTextView
.
isUserInteractionEnabled
=
true
termsTextView
.
isEditable
=
false
termsTextView
.
isSelectable
=
true
termsTextView
.
dataDetectorTypes
=
[
.
link
]
// Uncomment if Barcode Section is active again
// toggleTerms()
toggleBarcode
()
...
...
@@ -265,6 +307,14 @@ import AVFoundation
}
public
func
textView
(
_
textView
:
UITextView
,
shouldInteractWith
URL
:
URL
,
in
characterRange
:
NSRange
,
interaction
:
UITextItemInteraction
)
->
Bool
{
UIApplication
.
shared
.
open
(
URL
)
// Disable `.preview` by 3D Touch and other interactions
return
false
}
// MARK: - Functions
func
toggleTerms
()
{
if
(
termsVisible
)
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
View file @
9537ccc
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/ViewControllerExtensions.swift
View file @
9537ccc
...
...
@@ -490,3 +490,35 @@ extension UINavigationController {
return
nil
}
}
/// Class to allow links but no selection.
/// Basically, it disables unwanted UIGestureRecognizer from UITextView.
class
UnselectableTappableTextView
:
UITextView
{
// required to prevent blue background selection from any situation
override
var
selectedTextRange
:
UITextRange
?
{
get
{
return
nil
}
set
{}
}
override
func
gestureRecognizerShouldBegin
(
_
gestureRecognizer
:
UIGestureRecognizer
)
->
Bool
{
if
gestureRecognizer
is
UIPanGestureRecognizer
{
// required for compatibility with isScrollEnabled
return
super
.
gestureRecognizerShouldBegin
(
gestureRecognizer
)
}
if
let
tapGestureRecognizer
=
gestureRecognizer
as?
UITapGestureRecognizer
,
tapGestureRecognizer
.
numberOfTapsRequired
==
1
{
// required for compatibility with links
return
super
.
gestureRecognizerShouldBegin
(
gestureRecognizer
)
}
// allowing smallDelayRecognizer for links
if
let
longPressGestureRecognizer
=
gestureRecognizer
as?
UILongPressGestureRecognizer
,
// comparison value is used to distinguish between 0.12 (smallDelayRecognizer) and 0.5 (textSelectionForce and textLoupe)
longPressGestureRecognizer
.
minimumPressDuration
<
0.325
{
return
super
.
gestureRecognizerShouldBegin
(
gestureRecognizer
)
}
// preventing selection from loupe/magnifier (_UITextSelectionForceGesture), multi tap, tap and a half, etc.
gestureRecognizer
.
isEnabled
=
false
return
false
}
}
...
...
Please
register
or
login
to post a comment