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
7b9c9f69
Commit
7b9c9f69
authored
Sep 14, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished subscriptions UI
parent
616e3d2e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
138 additions
and
33 deletions
+138
-33
1Weather.xcodeproj/xcshareddata/xcschemes/1Weather.xcscheme
+0
-3
1Weather/Resources/Assets.xcassets/subscriptions/subscription_cross.imageset/Contents.json
+15
-0
1Weather/Resources/Assets.xcassets/subscriptions/subscription_cross.imageset/subscription_cross.pdf
+0
-0
1Weather/Resources/en.lproj/Localizable.strings
+7
-0
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionDescriptionView.swift
+2
-0
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionProDescriptionView.swift
+91
-21
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionPurchaseButton.swift
+21
-2
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionTopView.swift
+1
-1
1Weather/ViewModels/SubscriptionViewModel.swift
+1
-6
No files found.
1Weather.xcodeproj/xcshareddata/xcschemes/1Weather.xcscheme
View file @
7b9c9f69
...
...
@@ -50,9 +50,6 @@
ReferencedContainer =
"container:1Weather.xcodeproj"
>
</BuildableReference>
</BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier =
"../1Weather/InApps/Configuration.storekit"
>
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration =
"Release"
...
...
1Weather/Resources/Assets.xcassets/subscriptions/subscription_cross.imageset/Contents.json
0 → 100644
View file @
7b9c9f69
{
"images"
:
[
{
"filename"
:
"subscription_cross.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
}
}
1Weather/Resources/Assets.xcassets/subscriptions/subscription_cross.imageset/subscription_cross.pdf
0 → 100644
View file @
7b9c9f69
File added
1Weather/Resources/en.lproj/Localizable.strings
View file @
7b9c9f69
...
...
@@ -227,12 +227,19 @@
"subscription.description.items.youGet" = "You get:";
"subscription.description.items.adFree" = "Ad free experience";
"subscription.description.items.adFree.forever" = "Forever";
"subscription.description.items.hourly" = " 48 hours of Hourly forecasts";
"subscription.description.items.hourly.pro" = "Hourly forecasts";
"subscription.description.items.hourly.crossed" = "24 hours";
"subscription.description.items.hourly.pro.opt" = "12 hours";
"subscription.description.items.hourly.premium.opt" = "48 hours";
"subscription.description.items.daily" = " 10 Days of Daily forecasts";
"subscription.description.items.daily.pro" = "Daily forecasts";
"subscription.description.items.daily.crossed" = "7 days";
"subscription.description.items.daily.pro.opt" = "7 days";
"subscription.description.items.daily.premium.opt" = "10 days";
"subscription.description.items.aqi" = "AQI card";
"subscription.description.items.comingSoon" = "Coming Soon";
"subscription.description.items.minutely" = "Minutely Forecast";
...
...
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionDescriptionView.swift
View file @
7b9c9f69
...
...
@@ -193,6 +193,8 @@ extension SubscriptionDescriptionView {
}
textView
.
attributedText
=
attributedText
textView
.
adjustsFontSizeToFitWidth
=
true
textView
.
minimumScaleFactor
=
0.2
iconView
.
image
=
image
addSubview
(
iconView
)
...
...
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionProDescriptionView.swift
View file @
7b9c9f69
...
...
@@ -43,6 +43,8 @@ private extension SubscriptionProDescriptionView {
addSubview
(
proMemeberContainer
)
proMemberTopLabel
.
text
=
"subscription.proMember.already.top"
.
localized
()
proMemberTopLabel
.
lineBreakMode
=
.
byWordWrapping
proMemberTopLabel
.
numberOfLines
=
0
proMemberTopLabel
.
font
=
AppFont
.
SFPro
.
semibold
(
size
:
16
)
proMemberTopLabel
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
proMemeberContainer
.
addSubview
(
proMemberTopLabel
)
...
...
@@ -59,7 +61,7 @@ private extension SubscriptionProDescriptionView {
}
proMemberTopLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
inset
(
14
)
make
.
left
.
right
.
equalToSuperview
()
.
inset
(
14
)
make
.
top
.
equalToSuperview
()
.
inset
(
14
)
}
...
...
@@ -122,14 +124,14 @@ private extension SubscriptionProDescriptionView {
func
prepareHorizontalStackView
()
{
horizontalStackView
.
axis
=
.
horizontal
horizontalStackView
.
distribution
=
.
fill
horizontalStackView
.
distribution
=
.
fill
Proportionally
horizontalStackView
.
spacing
=
20
addSubview
(
horizontalStackView
)
horizontalStackView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
proUsersContainer
.
snp
.
bottom
)
.
offset
(
25
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
26
)
make
.
bottom
.
equalToSuperview
()
}
}
...
...
@@ -137,7 +139,9 @@ private extension SubscriptionProDescriptionView {
let
namesStackView
=
UIStackView
()
namesStackView
.
spacing
=
22
namesStackView
.
axis
=
.
vertical
namesStackView
.
distribution
=
.
fillProportionally
namesStackView
.
distribution
=
.
fillEqually
namesStackView
.
isLayoutMarginsRelativeArrangement
=
true
namesStackView
.
layoutMargins
=
.
init
(
top
:
34
,
left
:
0
,
bottom
:
0
,
right
:
0
)
namesStackView
.
addArrangedSubview
(
DescriptionItemView
(
textShortLocalizedKey
:
"items.adFree"
))
namesStackView
.
addArrangedSubview
(
DescriptionItemView
(
textShortLocalizedKey
:
"items.aqi"
))
namesStackView
.
addArrangedSubview
(
DescriptionItemView
(
textShortLocalizedKey
:
"items.hourly.pro"
))
...
...
@@ -148,41 +152,58 @@ private extension SubscriptionProDescriptionView {
let
proStackView
=
UIStackView
()
proStackView
.
spacing
=
22
proStackView
.
axis
=
.
vertical
proStackView
.
distribution
=
.
fillProportionally
proStackView
.
distribution
=
.
fillEqually
proStackView
.
alignment
=
.
center
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withHeader
:
"PRO"
))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_cross"
)))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withText
:
"subscription.description.items.hourly.pro.opt"
.
localized
(),
isBold
:
false
))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withText
:
"subscription.description.items.daily.pro.opt"
.
localized
(),
isBold
:
false
))
proStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_cross"
)))
proStackView
.
setCustomSpacing
(
13
,
after
:
proStackView
.
arrangedSubviews
[
0
])
horizontalStackView
.
addArrangedSubview
(
proStackView
)
let
premiumStackView
=
UIStackView
()
premiumStackView
.
spacing
=
22
premiumStackView
.
axis
=
.
vertical
premiumStackView
.
distribution
=
.
fillProportionally
premiumStackView
.
distribution
=
.
fillEqually
premiumStackView
.
alignment
=
.
center
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withHeader
:
"PREMIUM"
))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withImage
:
UIImage
(
named
:
"subscription_checkmark"
)))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withText
:
"subscription.description.items.hourly.premium.opt"
.
localized
(),
isBold
:
true
))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withText
:
"subscription.description.items.daily.premium.opt"
.
localized
(),
isBold
:
true
))
premiumStackView
.
addArrangedSubview
(
DescriptionItemView
(
withMarker
:
"subscription.description.items.comingSoon"
.
localized
()))
premiumStackView
.
setCustomSpacing
(
13
,
after
:
premiumStackView
.
arrangedSubviews
[
0
])
horizontalStackView
.
addArrangedSubview
(
premiumStackView
)
}
}
private
extension
SubscriptionProDescriptionView
{
private
class
DescriptionItemView
:
UIView
{
init
(
textShortLocalizedKey
:
String
)
{
init
()
{
super
.
init
(
frame
:
.
zero
)
self
.
snp
.
makeConstraints
{
make
in
make
.
height
.
equalTo
(
20
)
}
}
convenience
init
(
textShortLocalizedKey
:
String
)
{
self
.
init
()
let
label
=
UILabel
()
label
.
adjustsFontSizeToFitWidth
=
true
label
.
minimumScaleFactor
=
0.2
label
.
font
=
AppFont
.
SFPro
.
medium
(
size
:
16
)
label
.
textColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
label
.
text
=
(
"subscription.description."
+
textShortLocalizedKey
)
.
localized
()
addSubview
(
label
)
self
.
snp
.
makeConstraints
{
make
in
make
.
height
.
equalTo
(
20
)
}
label
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
...
...
@@ -190,8 +211,8 @@ private extension SubscriptionProDescriptionView {
}
}
init
(
withImage
:
UIImage
?)
{
s
uper
.
init
(
frame
:
.
zero
)
convenience
init
(
withImage
:
UIImage
?)
{
s
elf
.
init
(
)
let
imageView
=
UIImageView
()
imageView
.
image
=
withImage
...
...
@@ -200,12 +221,34 @@ private extension SubscriptionProDescriptionView {
imageView
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
20
)
make
.
edges
.
equalToSuperview
()
make
.
center
.
equalToSuperview
()
}
}
init
(
withHeader
:
String
)
{
super
.
init
(
frame
:
.
zero
)
convenience
init
(
withText
:
String
,
isBold
:
Bool
)
{
self
.
init
()
let
label
=
UILabel
()
label
.
textAlignment
=
.
center
label
.
text
=
withText
label
.
textColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
if
isBold
{
label
.
font
=
AppFont
.
SFPro
.
bold
(
size
:
14
)
}
else
{
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
14
)
}
addSubview
(
label
)
label
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
make
.
centerY
.
equalToSuperview
()
}
}
convenience
init
(
withHeader
:
String
)
{
self
.
init
()
let
label
=
UILabel
()
label
.
textAlignment
=
.
center
...
...
@@ -215,7 +258,6 @@ private extension SubscriptionProDescriptionView {
addSubview
(
label
)
self
.
snp
.
makeConstraints
{
make
in
make
.
height
.
equalTo
(
20
)
make
.
width
.
equalTo
(
70
)
}
...
...
@@ -225,6 +267,34 @@ private extension SubscriptionProDescriptionView {
}
}
convenience
init
(
withMarker
text
:
String
)
{
self
.
init
()
let
container
=
UIView
()
container
.
backgroundColor
=
UIColor
(
hex
:
0xffb820
)
.
withAlphaComponent
(
0.3
)
container
.
layer
.
cornerRadius
=
4
addSubview
(
container
)
let
label
=
UILabel
()
label
.
text
=
text
label
.
font
=
AppFont
.
SFPro
.
semibold
(
size
:
10
)
label
.
textColor
=
.
black
label
.
adjustsFontSizeToFitWidth
=
true
label
.
minimumScaleFactor
=
0.2
container
.
addSubview
(
label
)
//Contraints
container
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
}
label
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
equalToSuperview
()
.
inset
(
6
)
make
.
top
.
bottom
.
equalToSuperview
()
.
inset
(
3
)
}
}
@available(*, unavailable)
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
...
...
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionPurchaseButton.swift
View file @
7b9c9f69
...
...
@@ -28,8 +28,13 @@ class SubscriptionPurchaseButton: UIButton {
self
.
subscription
=
subscription
self
.
subscriptionType
=
type
super
.
init
(
frame
:
.
zero
)
self
.
titleLabel
?
.
adjustsFontSizeToFitWidth
=
true
self
.
titleLabel
?
.
minimumScaleFactor
=
0.2
self
.
translatesAutoresizingMaskIntoConstraints
=
false
self
.
setAttributedTitle
(
buildTitle
(),
for
:
.
normal
)
self
.
titleEdgeInsets
=
.
init
(
top
:
0
,
left
:
16
,
bottom
:
0
,
right
:
16
)
self
.
setAttributedTitle
(
buildTitle
(
forType
:
type
),
for
:
.
normal
)
if
type
==
.
yearly
{
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
,
for
:
.
normal
)
self
.
backgroundColor
=
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
...
...
@@ -55,7 +60,7 @@ class SubscriptionPurchaseButton: UIButton {
fatalError
(
"init(coder:) has not been implemented"
)
}
private
func
buildTitle
()
->
NSAttributedString
{
private
func
buildTitle
(
forType
type
:
SubscriptionPurchaseButton
.
SubscriptionType
)
->
NSAttributedString
{
guard
let
price
=
subscription
.
localizedPrice
else
{
return
NSAttributedString
()
}
...
...
@@ -95,6 +100,20 @@ class SubscriptionPurchaseButton: UIButton {
}
result
.
replaceCharacters
(
in
:
discountPriceRange
,
with
:
discountPrice
)
}
if
type
==
.
yearly
{
result
.
addAttribute
(
.
foregroundColor
,
value
:
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
,
range
:
.
init
(
location
:
0
,
length
:
result
.
string
.
count
))
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseColor
,
for
:
.
normal
)
}
else
{
result
.
addAttribute
(
.
foregroundColor
,
value
:
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
,
range
:
.
init
(
location
:
0
,
length
:
result
.
string
.
count
))
self
.
setTitleColor
(
ThemeManager
.
currentTheme
.
subscriptionPurchaseBackgroundColor
,
for
:
.
normal
)
}
return
result
}
...
...
1Weather/UI/View controllers/Subscriptions/Views/SubscriptionTopView.swift
View file @
7b9c9f69
...
...
@@ -31,9 +31,9 @@ class SubscriptionTopView: UIView {
logoView
.
image
=
UIImage
(
named
:
"subscription_logo"
)
logoView
.
contentMode
=
.
scaleAspectFit
addSubview
(
logoView
)
addSubview
(
oneWeatherLabel
)
addSubview
(
premiumLabel
)
addSubview
(
logoView
)
oneWeatherLabel
.
snp
.
makeConstraints
{
make
in
make
.
leading
.
equalToSuperview
()
.
offset
(
28
)
...
...
1Weather/ViewModels/SubscriptionViewModel.swift
View file @
7b9c9f69
...
...
@@ -22,12 +22,7 @@ class SubscriptionViewModel: ViewModelProtocol {
}
public
var
isProUser
:
Bool
{
#if DEBUG
return
true
#else
fatalError
(
"Remove in production"
)
#endif
// storeManager.removeAdsPurchased
storeManager
.
removeAdsPurchased
}
public
func
purchase
(
subscription
:
SKProduct
)
{
...
...
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