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
3e7303ac
Commit
3e7303ac
authored
Aug 14, 2021
by
Dmitry Stepanets
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added code to wait until ConfigManager finishes updating app configuration
parent
f08763a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
14 deletions
+64
-14
1Weather/Coordinators/AppCoordinator.swift
+13
-8
1Weather/Network/ConfigManager.swift
+27
-4
1Weather/UI/View controllers/SplashAnimation/SplashAnimationViewController.swift
+24
-2
No files found.
1Weather/Coordinators/AppCoordinator.swift
View file @
3e7303ac
...
...
@@ -98,16 +98,21 @@ class AppCoordinator: Coordinator {
public
func
finishAnimation
()
{
DispatchQueue
.
main
.
async
{
if
Settings
.
shared
.
initialOnboardingShowed
{
self
.
finishInitialOnboarding
()
if
ConfigManager
.
shared
.
config
.
showOnboarding
{
if
Settings
.
shared
.
initialOnboardingShowed
{
self
.
finishInitialOnboarding
()
}
else
{
let
initialOnboarding
=
OnboardingPageController
(
coordinator
:
self
)
self
.
window
.
rootViewController
=
initialOnboarding
UIView
.
transition
(
with
:
self
.
window
,
duration
:
0.3
,
options
:
.
transitionCrossDissolve
,
animations
:
nil
)
}
}
else
{
let
initialOnboarding
=
OnboardingPageController
(
coordinator
:
self
)
self
.
window
.
rootViewController
=
initialOnboarding
UIView
.
transition
(
with
:
self
.
window
,
duration
:
0.3
,
options
:
.
transitionCrossDissolve
,
animations
:
nil
)
self
.
finishInitialOnboarding
()
}
}
}
...
...
1Weather/Network/ConfigManager.swift
View file @
3e7303ac
...
...
@@ -21,8 +21,18 @@ public struct AppConfig: Codable {
public
let
shortsLeftBelowCount
:
Int
public
let
shortsLastNudgeEnabled
:
Bool
public
let
shortsSwipeUpNudgeCount
:
Int
public
let
showOnboarding
:
Bool
public
init
(
popularCities
:
[
GeoNamesPlace
]?,
adConfig
:
AdConfig
,
ccpaUpdateInterval
:
TimeInterval
?,
nwsAlertsViaMoEngageEnabled
:
Bool
,
showAttPrompt
:
Bool
,
shortsLeftBelowCountKey
:
Int
,
shortsLastNudgeEnabledKey
:
Bool
,
shortsSwipeUpNudgeCountKey
:
Int
)
{
public
init
(
popularCities
:
[
GeoNamesPlace
]?,
adConfig
:
AdConfig
,
ccpaUpdateInterval
:
TimeInterval
?,
nwsAlertsViaMoEngageEnabled
:
Bool
,
showAttPrompt
:
Bool
,
shortsLeftBelowCountKey
:
Int
,
shortsLastNudgeEnabledKey
:
Bool
,
shortsSwipeUpNudgeCountKey
:
Int
,
showOnboarding
:
Bool
)
{
self
.
popularCities
=
popularCities
self
.
adConfig
=
adConfig
self
.
ccpaUpdateInterval
=
ccpaUpdateInterval
...
...
@@ -31,6 +41,7 @@ public struct AppConfig: Codable {
self
.
shortsLeftBelowCount
=
shortsLeftBelowCountKey
self
.
shortsLastNudgeEnabled
=
shortsLastNudgeEnabledKey
self
.
shortsSwipeUpNudgeCount
=
shortsSwipeUpNudgeCountKey
self
.
showOnboarding
=
showOnboarding
}
}
...
...
@@ -47,6 +58,7 @@ public class ConfigManager {
private
static
let
shortsLeftBelowCountKey
=
"shorts_left_below_nudge_every_x_cards"
private
static
let
shortsLastNudgeEnabledKey
=
"shorts_swipe_down_nudge_enabled"
private
static
let
shortsSwipeUpNudgeCountKey
=
"shorts_swipe_up_nudge_on_x_cards"
private
static
let
showOnboardingKey
=
"ios_show_onboarding"
private
let
delegates
=
MulticastDelegate
<
ConfigManagerDelegate
>
()
...
...
@@ -61,7 +73,7 @@ public class ConfigManager {
}()
public
static
let
shared
=
ConfigManager
()
public
private(set)
var
isUpdating
=
false
public
var
config
:
AppConfig
=
AppConfig
(
popularCities
:
nil
,
adConfig
:
AdConfig
(),
ccpaUpdateInterval
:
nil
,
...
...
@@ -69,12 +81,19 @@ public class ConfigManager {
showAttPrompt
:
false
,
shortsLeftBelowCountKey
:
0
,
shortsLastNudgeEnabledKey
:
false
,
shortsSwipeUpNudgeCountKey
:
0
)
shortsSwipeUpNudgeCountKey
:
0
,
showOnboarding
:
false
)
public
func
updateConfig
()
{
log
.
info
(
"update config"
)
isUpdating
=
true
remoteConfig
.
fetchAndActivate
{
[
weak
self
]
(
status
,
error
)
in
guard
let
self
=
self
else
{
return
}
defer
{
self
.
isUpdating
=
false
}
switch
status
{
case
.
successFetchedFromRemote
:
self
.
parseConfigFromFirebase
(
source
:
"remote"
)
...
...
@@ -152,6 +171,9 @@ public class ConfigManager {
let
shortsSwipeNudgeCountValue
=
remoteConfig
.
configValue
(
forKey
:
ConfigManager
.
shortsSwipeUpNudgeCountKey
)
let
shortsSwipeNudgeCount
=
shortsSwipeNudgeCountValue
.
numberValue
.
intValue
let
showOnboardingValue
=
remoteConfig
.
configValue
(
forKey
:
ConfigManager
.
showOnboardingKey
)
let
showOnboarding
=
showOnboardingValue
.
boolValue
DispatchQueue
.
main
.
async
{
self
.
config
=
AppConfig
(
popularCities
:
popularCities
,
adConfig
:
adConfig
,
...
...
@@ -160,7 +182,8 @@ public class ConfigManager {
showAttPrompt
:
showAttPrompt
,
shortsLeftBelowCountKey
:
shortsLeftBelowCount
,
shortsLastNudgeEnabledKey
:
shortsLastNudgeEnabled
,
shortsSwipeUpNudgeCountKey
:
shortsSwipeNudgeCount
)
shortsSwipeUpNudgeCountKey
:
shortsSwipeNudgeCount
,
showOnboarding
:
showOnboarding
)
self
.
notifyAboutConfigUpdate
()
DispatchQueue
.
global
()
.
async
{
let
encoder
=
JSONEncoder
()
...
...
1Weather/UI/View controllers/SplashAnimation/SplashAnimationViewController.swift
View file @
3e7303ac
...
...
@@ -11,11 +11,13 @@ import OneWeatherCore
import
OneWeatherAnalytics
class
SplashAnimationViewController
:
UIViewController
{
private
let
kAttemptsCount
=
3
private
let
appCoordinator
:
AppCoordinator
private
let
backgroundImageView
=
UIImageView
()
private
let
animation
=
Animation
.
named
(
"splash"
)
private
var
animationView
:
AnimationView
?
private
let
playButton
=
UIButton
()
private
var
currentAttempt
=
0
init
(
appCoordinator
:
AppCoordinator
)
{
self
.
appCoordinator
=
appCoordinator
...
...
@@ -59,12 +61,32 @@ class SplashAnimationViewController: UIViewController {
}
}
private
func
finish
()
{
//We need to wait, until ConfigManager finishes updating configuration
//But this is given 3 attempts with a duration of 1 second
if
ConfigManager
.
shared
.
isUpdating
{
if
currentAttempt
<
kAttemptsCount
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
1
)
{
self
.
currentAttempt
+=
1
self
.
finish
()
}
}
else
{
self
.
appCoordinator
.
finishAnimation
()
}
}
else
{
self
.
appCoordinator
.
finishAnimation
()
}
}
private
func
noCityAnimation
()
{
analytics
(
log
:
.
ANALYTICS_FTUE_SPLASH_SEEN
)
analytics
(
set
:
.
splashFTUE
,
to
:
true
)
self
.
animationView
?
.
play
(
completion
:
{[
weak
self
]
_
in
DispatchQueue
.
global
()
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
)
{
self
?
.
appCoordinator
.
finishAnimation
()
self
?
.
finish
()
}
})
}
...
...
@@ -76,7 +98,7 @@ class SplashAnimationViewController: UIViewController {
self
.
animationView
?
.
alpha
=
1
}
completion
:
{
_
in
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.3
)
{
self
.
appCoordinator
.
finishAnimation
()
self
.
finish
()
}
}
}
...
...
Dmitriy Stepanets
@DStepanets
mentioned in commit
797a623a
Aug 30, 2021
mentioned in commit
797a623a
mentioned in commit 797a623ab6562184d0391bc8484e0d446e6f5b9f
Toggle commit list
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