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
4f586371
Commit
4f586371
authored
Oct 14, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IOS-288]: Working on custom presentation
parent
93ec42aa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
21 deletions
+137
-21
1Weather.xcodeproj/project.pbxproj
+20
-0
1Weather/Coordinators/SubscriptionCoordinator.swift
+28
-6
1Weather/Coordinators/SubscriptionPopUpCoordinator.swift
+27
-0
1Weather/UI/View controllers/Subscriptions/Animators/StoreDismissAnimator.swift
+8
-0
1Weather/UI/View controllers/Subscriptions/Animators/StorePresentationAnimator.swift
+38
-0
1Weather/UI/View controllers/Subscriptions/SubscriptionStoreViewController.swift
+16
-15
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
4f586371
...
...
@@ -180,6 +180,9 @@
CDB0D4CA2670CAD00081C773
/* ShortsCollectionViewCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDB0D4C92670CAD00081C773
/* ShortsCollectionViewCell.swift */
;
};
CDB0D4CC2670D12F0081C773
/* TodayShortsCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDB0D4CB2670D12F0081C773
/* TodayShortsCell.swift */
;
};
CDB0D4CE2670DABF0081C773
/* UIImage+AverageColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDB0D4CD2670DABF0081C773
/* UIImage+AverageColor.swift */
;
};
CDC2E23F27184C4F002B6826
/* SubscriptionPopUpCoordinator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC2E23E27184C4F002B6826
/* SubscriptionPopUpCoordinator.swift */
;
};
CDC2E242271854D0002B6826
/* StorePresentationAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC2E241271854D0002B6826
/* StorePresentationAnimator.swift */
;
};
CDC2E244271854EA002B6826
/* StoreDismissAnimator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC2E243271854EA002B6826
/* StoreDismissAnimator.swift */
;
};
CDC3F858269460E600AAE3BF
/* PromotionMediumWidgetView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC3F857269460E600AAE3BF
/* PromotionMediumWidgetView.swift */
;
};
CDC6124F25E7964700188DA7
/* TodayDayTimesCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC6124E25E7964700188DA7
/* TodayDayTimesCell.swift */
;
};
CDC6125325E79C8F00188DA7
/* DayTimeView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC6125225E79C8F00188DA7
/* DayTimeView.swift */
;
};
...
...
@@ -541,6 +544,9 @@
CDB0D4C92670CAD00081C773
/* ShortsCollectionViewCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ShortsCollectionViewCell.swift
;
sourceTree
=
"<group>"
;
};
CDB0D4CB2670D12F0081C773
/* TodayShortsCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TodayShortsCell.swift
;
sourceTree
=
"<group>"
;
};
CDB0D4CD2670DABF0081C773
/* UIImage+AverageColor.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UIImage+AverageColor.swift"
;
sourceTree
=
"<group>"
;
};
CDC2E23E27184C4F002B6826
/* SubscriptionPopUpCoordinator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SubscriptionPopUpCoordinator.swift
;
sourceTree
=
"<group>"
;
};
CDC2E241271854D0002B6826
/* StorePresentationAnimator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StorePresentationAnimator.swift
;
sourceTree
=
"<group>"
;
};
CDC2E243271854EA002B6826
/* StoreDismissAnimator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StoreDismissAnimator.swift
;
sourceTree
=
"<group>"
;
};
CDC3F857269460E600AAE3BF
/* PromotionMediumWidgetView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PromotionMediumWidgetView.swift
;
sourceTree
=
"<group>"
;
};
CDC6124E25E7964700188DA7
/* TodayDayTimesCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TodayDayTimesCell.swift
;
sourceTree
=
"<group>"
;
};
CDC6125225E79C8F00188DA7
/* DayTimeView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DayTimeView.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -859,6 +865,7 @@
CD8579692671FA8100CC4CDA
/* ShortsCoordinator.swift */
,
CE6E410726EBA7C0009829AE
/* SubscriptionCoordinator.swift */
,
CED4D66A26ED6A5E00ECF479
/* SubscriptionOverviewCoordinator.swift */
,
CDC2E23E27184C4F002B6826
/* SubscriptionPopUpCoordinator.swift */
,
);
path
=
Coordinators
;
sourceTree
=
"<group>"
;
...
...
@@ -1327,6 +1334,15 @@
path
=
SharedCells
;
sourceTree
=
"<group>"
;
};
CDC2E240271854AE002B6826
/* Animators */
=
{
isa
=
PBXGroup
;
children
=
(
CDC2E241271854D0002B6826
/* StorePresentationAnimator.swift */
,
CDC2E243271854EA002B6826
/* StoreDismissAnimator.swift */
,
);
path
=
Animators
;
sourceTree
=
"<group>"
;
};
CDC6124D25E7960D00188DA7
/* TodayDayTimesCell */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -1561,6 +1577,7 @@
CE6E410126EBA386009829AE
/* Subscriptions */
=
{
isa
=
PBXGroup
;
children
=
(
CDC2E240271854AE002B6826
/* Animators */
,
CE6E410426EBA3B4009829AE
/* Views */
,
CE6E410226EBA3B0009829AE
/* SubscriptionStoreViewController.swift */
,
CE6E410526EBA3EB009829AE
/* SubscriptionOverviewViewController.swift */
,
...
...
@@ -2257,6 +2274,7 @@
CD8B60B626381E0F0055CB3F
/* AdsUserDefaultsWrapper.swift in Sources */
,
CD9B6B1425DBCDE2001D9B80
/* GraphView.swift in Sources */
,
CD866A6F260F67F200E96A5C
/* SettingsDetailsViewModel.swift in Sources */
,
CDC2E242271854D0002B6826
/* StorePresentationAnimator.swift in Sources */
,
CD71709025FA317700A63C27
/* ForecastTimePeriodView.swift in Sources */
,
CE13B812262480B3007CBD4D
/* NativeAdItem.swift in Sources */
,
CE6E410826EBA7C0009829AE
/* SubscriptionCoordinator.swift in Sources */
,
...
...
@@ -2300,6 +2318,7 @@
CE578FE725FB415F00E8B85D
/* LocationsViewModel.swift in Sources */
,
CD82300A25D6B2AF00A05501
/* AppTabBarController.swift in Sources */
,
CE3A9CE326E64F2800E2CB4B
/* StoreManager.swift in Sources */
,
CDC2E23F27184C4F002B6826
/* SubscriptionPopUpCoordinator.swift in Sources */
,
CD85797126721D9800CC4CDA
/* UIViewController+Alert.swift in Sources */
,
CDC6126225E8DAB800188DA7
/* MoonPhaseCell.swift in Sources */
,
CD37D3D6260C93B3002669D6
/* MenuCellFactory.swift in Sources */
,
...
...
@@ -2385,6 +2404,7 @@
CD86246C25E6826A0097F3FB
/* InnerShadowLayer.swift in Sources */
,
CD85797F267221C500CC4CDA
/* CACornerMask+All.swift in Sources */
,
CE578FE525FB415F00E8B85D
/* CityCell.swift in Sources */
,
CDC2E244271854EA002B6826
/* StoreDismissAnimator.swift in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
1Weather/Coordinators/SubscriptionCoordinator.swift
View file @
4f586371
...
...
@@ -8,26 +8,37 @@
import
UIKit
import
OneWeatherCore
class
SubscriptionCoordinator
:
Coordinator
{
class
SubscriptionCoordinator
:
NSObject
,
Coordinator
{
//Private
private
let
parentViewController
:
UIViewController
private
let
storeManager
:
StoreManager
private
let
viewModel
:
SubscriptionViewModel
private
var
activeViewController
:
UIViewController
?
//Public
public
var
childCoordinators
=
[
Coordinator
]()
public
var
parentCoordinator
:
Coordinator
?
private
let
storeManager
:
StoreManager
public
init
(
parentViewController
:
UIViewController
,
storeManager
:
StoreManager
=
StoreManager
.
shared
)
{
self
.
parentViewController
=
parentViewController
self
.
storeManager
=
storeManager
self
.
viewModel
=
SubscriptionViewModel
(
storeManager
:
storeManager
)
super
.
init
()
self
.
viewModel
.
delegate
=
self
}
public
func
start
()
{
let
viewModel
=
SubscriptionViewModel
(
storeManager
:
storeManager
)
let
vc
=
SubscriptionStoreViewController
(
coordinator
:
self
,
viewModel
:
viewModel
)
activeViewController
=
SubscriptionStoreViewController
(
viewModel
:
self
.
viewModel
)
self
.
parentViewController
.
present
(
activeViewController
!
,
animated
:
true
)
}
public
func
startPopUp
()
{
self
.
parentViewController
.
present
(
vc
,
animated
:
true
)
}
p
ublic
func
openOverview
()
{
p
rivate
func
openOverview
()
{
let
overviewCoordinator
=
SubscriptionOverviewCoordinator
(
parentViewController
:
self
.
parentViewController
)
overviewCoordinator
.
parentCoordinator
=
self
childCoordinators
.
append
(
overviewCoordinator
)
...
...
@@ -38,3 +49,14 @@ class SubscriptionCoordinator: Coordinator {
parentCoordinator
?
.
childDidFinish
(
child
:
self
)
}
}
//MARK: Subscription View Model
extension
SubscriptionCoordinator
:
SubscriptionViewModelDelegate
{
func
viewModel
(
_
vm
:
SubscriptionViewModel
,
finishedSubscriptionPurchaseWithResult
result
:
Bool
)
{
if
result
{
self
.
activeViewController
?
.
dismiss
(
animated
:
true
,
completion
:
{
self
.
openOverview
()
})
}
}
}
1Weather/Coordinators/SubscriptionPopUpCoordinator.swift
0 → 100644
View file @
4f586371
//
// SubscriptionPopUpCoordinator.swift
// 1Weather
//
// Created by Dmitry Stepanets on 14.10.2021.
//
import
Foundation
import
UIKit
class
SubscriptionPopUpCoordinator
:
Coordinator
{
private
let
parentViewController
:
UIViewController
public
var
childCoordinators
=
[
Coordinator
]()
public
var
parentCoordinator
:
Coordinator
?
public
init
(
parentViewController
:
UIViewController
,
storeManager
:
StoreManager
=
StoreManager
.
shared
)
{
self
.
parentViewController
=
parentViewController
}
public
func
start
()
{
}
func
viewControllerDidEnd
(
controller
:
UIViewController
)
{
parentCoordinator
?
.
childDidFinish
(
child
:
self
)
}
}
1Weather/UI/View controllers/Subscriptions/Animators/StoreDismissAnimator.swift
0 → 100644
View file @
4f586371
//
// StoreDismissAnimator.swift
// 1Weather
//
// Created by Dmitry Stepanets on 14.10.2021.
//
import
Foundation
1Weather/UI/View controllers/Subscriptions/Animators/StorePresentationAnimator.swift
0 → 100644
View file @
4f586371
//
// StorePresentationAnimator.swift
// 1Weather
//
// Created by Dmitry Stepanets on 14.10.2021.
//
import
UIKit
class
StorePresentationAnimator
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
func
transitionDuration
(
using
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0.25
}
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
guard
let
toViewController
=
transitionContext
.
viewController
(
forKey
:
.
to
)
else
{
return
}
let
container
=
transitionContext
.
containerView
let
heightDiff
=
container
.
bounds
.
height
*
0.3
//30% from container height
let
widthDiff
=
container
.
bounds
.
width
*
0.124
//12.4% from container width
let
targetHeight
=
container
.
bounds
.
height
-
heightDiff
let
targetWidth
=
container
.
bounds
.
width
-
widthDiff
toViewController
.
view
.
frame
=
.
init
(
x
:
(
container
.
bounds
.
width
-
targetWidth
)
/
2
,
y
:
container
.
bounds
.
height
,
width
:
targetWidth
,
height
:
targetHeight
)
container
.
addSubview
(
toViewController
.
view
)
UIView
.
animate
(
withDuration
:
transitionDuration
(
using
:
transitionContext
))
{
toViewController
.
view
.
frame
.
origin
.
y
=
(
container
.
bounds
.
height
-
targetHeight
)
/
2
}
completion
:
{
finished
in
transitionContext
.
completeTransition
(
finished
)
}
}
}
1Weather/UI/View controllers/Subscriptions/SubscriptionStoreViewController.swift
View file @
4f586371
...
...
@@ -15,7 +15,6 @@ import OneWeatherAnalytics
/// For users who previously purchased an in-app to disable ads: https://zpl.io/anzPMKr
/// For usual users: https://zpl.io/bLJ8rOd
public
class
SubscriptionStoreViewController
:
UIViewController
{
private
let
coordinator
:
SubscriptionCoordinator
private
let
viewModel
:
SubscriptionViewModel
private
var
localizationObserver
:
LocalizationChangeObserver
!
...
...
@@ -25,11 +24,11 @@ public class SubscriptionStoreViewController: UIViewController {
private
let
dynamicContentView
=
UIView
()
init
(
coordinator
:
SubscriptionCoordinator
,
viewModel
:
SubscriptionViewModel
)
{
self
.
coordinator
=
coordinator
init
(
viewModel
:
SubscriptionViewModel
)
{
self
.
viewModel
=
viewModel
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
self
.
viewModel
.
delegate
=
self
modalPresentationStyle
=
.
custom
transitioningDelegate
=
self
}
@available(*, unavailable)
...
...
@@ -45,8 +44,8 @@ public class SubscriptionStoreViewController: UIViewController {
}
//MARK: - UI Setup
extension
SubscriptionStoreViewController
{
private
func
prepareViewController
()
{
private
extension
SubscriptionStoreViewController
{
func
prepareViewController
()
{
view
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
topHeaderView
.
delegate
=
self
localizationObserver
=
LocalizationChangeObserver
{
[
weak
self
]
in
...
...
@@ -54,7 +53,7 @@ extension SubscriptionStoreViewController {
}
}
private
func
prepareScrollView
()
{
func
prepareScrollView
()
{
view
.
addSubview
(
scrollView
)
scrollView
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
...
...
@@ -79,7 +78,7 @@ extension SubscriptionStoreViewController {
}
}
private
func
rebuildUI
()
{
func
rebuildUI
()
{
for
subview
in
dynamicContentView
.
subviews
{
subview
.
removeFromSuperview
()
}
...
...
@@ -159,12 +158,14 @@ extension SubscriptionStoreViewController: SubscriptionPurchaseButtonDelegate {
viewModel
.
purchase
(
subscription
:
product
)
}
}
extension
SubscriptionStoreViewController
:
SubscriptionViewModelDelegate
{
func
viewModel
(
_
vm
:
SubscriptionViewModel
,
finishedSubscriptionPurchaseWithResult
result
:
Bool
)
{
if
result
{
self
.
dismiss
(
animated
:
true
)
{
self
.
coordinator
.
openOverview
()
}
}
//MARK: Transitioning Delegate
extension
SubscriptionStoreViewController
:
UIViewControllerTransitioningDelegate
{
public
func
animationController
(
forPresented
presented
:
UIViewController
,
presenting
:
UIViewController
,
source
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
StorePresentationAnimator
()
}
public
func
animationController
(
forDismissed
dismissed
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
nil
}
}
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