Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
08a4f9e1
Commit
08a4f9e1
authored
Sep 12, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-155: strikethrough on the purchase buttons.
parent
e5ea3459
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
8 deletions
+40
-8
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionPurchaseButton.swift
+40
-8
No files found.
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionPurchaseButton.swift
View file @
08a4f9e1
...
...
@@ -30,8 +30,18 @@ class SubscriptionPurchaseButton: UIButton {
super
.
init
(
frame
:
.
zero
)
self
.
translatesAutoresizingMaskIntoConstraints
=
false
self
.
setAttributedTitle
(
buildTitle
(),
for
:
.
normal
)
self
.
backgroundColor
=
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
,
for
:
.
normal
)
if
type
==
.
yearly
{
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
,
for
:
.
normal
)
self
.
backgroundColor
=
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
}
else
{
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
,
for
:
.
normal
)
self
.
backgroundColor
=
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
}
self
.
layer
.
borderWidth
=
1
self
.
layer
.
borderColor
=
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
.
cgColor
self
.
clipsToBounds
=
true
self
.
layer
.
cornerRadius
=
6
self
.
snp
.
makeConstraints
{
make
in
...
...
@@ -52,17 +62,39 @@ class SubscriptionPurchaseButton: UIButton {
let
template
=
"subscription.button.
\(
showUpgradeText
?
"upgrade"
:
"buy"
)
.
\(
subscriptionType
.
rawValue
)
"
.
localized
()
var
withPrices
=
template
.
replacingOccurrences
(
of
:
"#PRICE#"
,
with
:
price
)
let
priceAttributes
:
[
NSAttributedString
.
Key
:
Any
]
if
showUpgradeText
{
priceAttributes
=
[
NSAttributedString
.
Key
.
font
:
AppFont
.
SFPro
.
light
(
size
:
18
),
NSAttributedString
.
Key
.
strikethroughStyle
:
NSUnderlineStyle
.
single
.
rawValue
]
}
else
{
priceAttributes
=
[
NSAttributedString
.
Key
.
font
:
AppFont
.
SFPro
.
semibold
(
size
:
18
)
]
}
let
priceValue
=
NSAttributedString
(
string
:
price
,
attributes
:
priceAttributes
)
let
resultAttributes
=
[
NSAttributedString
.
Key
.
font
:
AppFont
.
SFPro
.
semibold
(
size
:
18
)
]
let
result
=
NSMutableAttributedString
(
string
:
template
,
attributes
:
resultAttributes
)
result
.
replaceCharacters
(
in
:
(
result
.
string
as
NSString
)
.
range
(
of
:
"#PRICE#"
),
with
:
priceValue
)
if
let
discountSubscription
=
self
.
discountSubscription
{
guard
let
discountPrice
=
discountSubscription
.
localizedPrice
else
{
return
NSAttributedString
()
}
withPrices
=
withPrices
.
replacingOccurrences
(
of
:
"#DISCOUNT_PRICE#"
,
with
:
discountPrice
)
let
discountPriceRange
=
(
result
.
string
as
NSString
)
.
range
(
of
:
"#DISCOUNT_PRICE#"
)
guard
discountPriceRange
.
location
!=
NSNotFound
else
{
return
NSAttributedString
()
}
result
.
replaceCharacters
(
in
:
discountPriceRange
,
with
:
discountPrice
)
}
var
result
=
NSMutableAttributedString
(
string
:
withPrices
)
#warning("Not implemented markup!")
//TODO: implement markup
return
result
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment