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
a4f79190
Commit
a4f79190
authored
Aug 12, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-211: Added initial onboarding experience with basic sliding UI
parent
68df3bed
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
446 additions
and
125 deletions
+446
-125
1Weather-Icons.sketch
+0
-0
1Weather.xcodeproj/project.pbxproj
+4
-16
1Weather/AppDelegate.swift
+2
-9
1Weather/Coordinators/AppCoordinator.swift
+24
-2
1Weather/Coordinators/InitialOnboardingCoordinator.swift
+0
-31
1Weather/Resources/Assets.xcassets/onboarding-alerts.imageset/Contents.json
+15
-0
1Weather/Resources/Assets.xcassets/onboarding-alerts.imageset/onboarding-alerts.pdf
+0
-0
1Weather/Resources/Assets.xcassets/onboarding-close.imageset/Contents.json
+16
-0
1Weather/Resources/Assets.xcassets/onboarding-close.imageset/onboarding-close.pdf
+0
-0
1Weather/Resources/Assets.xcassets/onboarding-forecast.imageset/Contents.json
+15
-0
1Weather/Resources/Assets.xcassets/onboarding-forecast.imageset/onboarding-forecast.pdf
+0
-0
1Weather/Resources/Assets.xcassets/onboarding-next.imageset/Contents.json
+16
-0
1Weather/Resources/Assets.xcassets/onboarding-next.imageset/onboarding-next.pdf
+0
-0
1Weather/Resources/Assets.xcassets/onboarding-radar.imageset/Contents.json
+15
-0
1Weather/Resources/Assets.xcassets/onboarding-radar.imageset/onboarding-radar.pdf
+0
-0
1Weather/Resources/en.lproj/Localizable.strings
+10
-0
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingAlertsController.swift
+0
-17
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingContentController.swift
+77
-0
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingForecastsController.swift
+0
-17
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingPageController.swift
+249
-16
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingRadarController.swift
+0
-17
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
+3
-0
No files found.
1Weather-Icons.sketch
View file @
a4f79190
No preview for this file type
1Weather.xcodeproj/project.pbxproj
View file @
a4f79190
...
...
@@ -154,10 +154,7 @@
CDC6126625E9085600188DA7
/* GraphLine.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC6126525E9085600188DA7
/* GraphLine.swift */
;
};
CDC6126A25E90C8800188DA7
/* GraphLineSettings.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC6126925E90C8800188DA7
/* GraphLineSettings.swift */
;
};
CDC62C4526C13B9200156643
/* OnboardingPageController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4426C13B9200156643
/* OnboardingPageController.swift */
;
};
CDC62C4726C13BE300156643
/* OnboardingForecastsController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4626C13BE300156643
/* OnboardingForecastsController.swift */
;
};
CDC62C4926C13BFE00156643
/* OnboardingAlertsController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4826C13BFE00156643
/* OnboardingAlertsController.swift */
;
};
CDC62C4B26C13C1700156643
/* OnboardingRadarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4A26C13C1700156643
/* OnboardingRadarController.swift */
;
};
CDC62C4D26C13E6600156643
/* InitialOnboardingCoordinator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4C26C13E6600156643
/* InitialOnboardingCoordinator.swift */
;
};
CDC62C4726C13BE300156643
/* OnboardingContentController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDC62C4626C13BE300156643
/* OnboardingContentController.swift */
;
};
CDD0F1E52572425200CF5017
/* SF-Pro.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD0F1E42572425200CF5017
/* SF-Pro.ttf */
;
};
CDD0F1E82572429E00CF5017
/* AppFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD0F1E72572429E00CF5017
/* AppFont.swift */
;
};
CDD0F1EE25725BCF00CF5017
/* ThemeManager.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD0F1ED25725BCF00CF5017
/* ThemeManager.swift */
;
};
...
...
@@ -414,10 +411,7 @@
CDC6126525E9085600188DA7
/* GraphLine.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GraphLine.swift
;
sourceTree
=
"<group>"
;
};
CDC6126925E90C8800188DA7
/* GraphLineSettings.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GraphLineSettings.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4426C13B9200156643
/* OnboardingPageController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OnboardingPageController.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4626C13BE300156643
/* OnboardingForecastsController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OnboardingForecastsController.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4826C13BFE00156643
/* OnboardingAlertsController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OnboardingAlertsController.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4A26C13C1700156643
/* OnboardingRadarController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OnboardingRadarController.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4C26C13E6600156643
/* InitialOnboardingCoordinator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
InitialOnboardingCoordinator.swift
;
sourceTree
=
"<group>"
;
};
CDC62C4626C13BE300156643
/* OnboardingContentController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OnboardingContentController.swift
;
sourceTree
=
"<group>"
;
};
CDD0F1E42572425200CF5017
/* SF-Pro.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"SF-Pro.ttf"
;
sourceTree
=
"<group>"
;
};
CDD0F1E72572429E00CF5017
/* AppFont.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppFont.swift
;
sourceTree
=
"<group>"
;
};
CDD0F1ED25725BCF00CF5017
/* ThemeManager.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ThemeManager.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -626,7 +620,6 @@
CD7BF1572620410800A30DF5
/* RadarCoordinator.swift */
,
CEC8FBB1263976240001A6BF
/* OnboardingCoordinator.swift */
,
CD8579692671FA8100CC4CDA
/* ShortsCoordinator.swift */
,
CDC62C4C26C13E6600156643
/* InitialOnboardingCoordinator.swift */
,
);
path
=
Coordinators
;
sourceTree
=
"<group>"
;
...
...
@@ -1037,9 +1030,7 @@
isa
=
PBXGroup
;
children
=
(
CDC62C4426C13B9200156643
/* OnboardingPageController.swift */
,
CDC62C4626C13BE300156643
/* OnboardingForecastsController.swift */
,
CDC62C4826C13BFE00156643
/* OnboardingAlertsController.swift */
,
CDC62C4A26C13C1700156643
/* OnboardingRadarController.swift */
,
CDC62C4626C13BE300156643
/* OnboardingContentController.swift */
,
);
path
=
InitialOnboarding
;
sourceTree
=
"<group>"
;
...
...
@@ -1648,7 +1639,6 @@
CD9B6B1425DBCDE2001D9B80
/* GraphView.swift in Sources */
,
CD866A6F260F67F200E96A5C
/* SettingsDetailsViewModel.swift in Sources */
,
CD71709025FA317700A63C27
/* ForecastTimePeriodView.swift in Sources */
,
CDC62C4D26C13E6600156643
/* InitialOnboardingCoordinator.swift in Sources */
,
CE13B812262480B3007CBD4D
/* NativeAdItem.swift in Sources */
,
CD37D3E5260CB05C002669D6
/* MenuFooterView.swift in Sources */
,
CDE18DD825D16CB200C80ED9
/* NavigationCityButton.swift in Sources */
,
...
...
@@ -1692,14 +1682,13 @@
CD37D3FA260DF714002669D6
/* SettingsThemeCell.swift in Sources */
,
CD6B303E25726960004B34B3
/* ThemeProtocol.swift in Sources */
,
CD6B303B2572680C004B34B3
/* SelfSizingButton.swift in Sources */
,
CDC62C4726C13BE300156643
/* Onboarding
Forecasts
Controller.swift in Sources */
,
CDC62C4726C13BE300156643
/* Onboarding
Content
Controller.swift in Sources */
,
CD9B6B1125DBC723001D9B80
/* CubicCurveAlgorithm.swift in Sources */
,
CD8B60B4263819790055CB3F
/* NotificationsViewController.swift in Sources */
,
CD67617026259D220079D273
/* RadarMapLayersController.swift in Sources */
,
CEC8FBAF2639756A0001A6BF
/* OnboardingViewController.swift in Sources */
,
CD866A65260F642600E96A5C
/* SettingsDetailsViewController.swift in Sources */
,
CD647D0225ED07D60034578B
/* TodayViewModel.swift in Sources */
,
CDC62C4926C13BFE00156643
/* OnboardingAlertsController.swift in Sources */
,
CD593BD32608BC3F00C93428
/* ForecastDayCell.swift in Sources */
,
CD8B60AB263819400055CB3F
/* NWSAlertCellFactory.swift in Sources */
,
CDAC9B8526319B0500AC1BF4
/* MapTimeControlItem.swift in Sources */
,
...
...
@@ -1722,7 +1711,6 @@
CD8B60B3263819790055CB3F
/* NWSAlertCell.swift in Sources */
,
CE13B81C262480B3007CBD4D
/* Interstitial.swift in Sources */
,
CDDE8D7C262EED3C00267931
/* MapLegendSevereView.swift in Sources */
,
CDC62C4B26C13C1700156643
/* OnboardingRadarController.swift in Sources */
,
CD6761882625C3360079D273
/* RadarViewModel.swift in Sources */
,
CDF8F12A262089A200DB384A
/* MapTimeView.swift in Sources */
,
CE81A422266E289E00800EFF
/* NativeAdView.swift in Sources */
,
...
...
1Weather/AppDelegate.swift
View file @
a4f79190
...
...
@@ -80,15 +80,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
FirebaseApp
.
configure
()
ConfigManager
.
shared
.
updateConfig
()
#if !DEBUG
fatalError
(
"This code only for Debug"
)
#else
let
onboarding
=
OnboardingPageController
()
window
?
.
rootViewController
=
onboarding
window
?
.
makeKeyAndVisible
()
// let appCoordinator = AppCoordinator(window: self.window!)
// appCoordinator.start()
#endif
let
appCoordinator
=
AppCoordinator
(
window
:
self
.
window
!
)
appCoordinator
.
start
()
ThemeManager
.
setBaseTheme
()
...
...
1Weather/Coordinators/AppCoordinator.swift
View file @
a4f79190
...
...
@@ -98,11 +98,33 @@ class AppCoordinator: Coordinator {
public
func
finishAnimation
()
{
DispatchQueue
.
main
.
async
{
self
.
window
.
rootViewController
=
self
.
tabBarController
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
)
}
}
}
public
func
finishInitialOnboarding
()
{
DispatchQueue
.
main
.
async
{
Settings
.
shared
.
initialOnboardingShowed
=
true
self
.
window
.
rootViewController
=
self
.
tabBarController
UIView
.
transition
(
with
:
self
.
window
,
duration
:
0.3
,
options
:
.
transitionCrossDissolve
,
animations
:
nil
,
completion
:
{
_
in
//Search the TodayCoordinator
let
todayCoordinator
=
(
self
.
childCoordinators
.
first
{
$0
is
TodayCoordinator
}
as?
TodayCoordinator
)
let
todayCoordinator
=
(
self
.
childCoordinators
.
first
{
$0
is
TodayCoordinator
}
as?
TodayCoordinator
)
todayCoordinator
?
.
showOnboardingOrPrivacyNoticeIfNeeded
()
})
}
}
...
...
1Weather/Coordinators/InitialOnboardingCoordinator.swift
deleted
100644 → 0
View file @
68df3bed
//
// InitialOnboardingCoordinator.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.08.2021.
//
import
UIKit
class
InitialOnboardingCoordinator
:
Coordinator
{
//Public
var
childCoordinators
=
[
Coordinator
]()
var
parentCoordinator
:
Coordinator
?
//Private
private
let
parentViewController
:
UIViewController
init
(
parentViewController
:
UIViewController
)
{
self
.
parentViewController
=
parentViewController
}
func
start
()
{
let
onboardingController
=
OnboardingPageController
()
parentViewController
.
present
(
onboardingController
,
animated
:
false
)
}
func
viewControllerDidEnd
(
controller
:
UIViewController
)
{
parentCoordinator
?
.
childDidFinish
(
child
:
self
)
}
}
1Weather/Resources/Assets.xcassets/onboarding-alerts.imageset/Contents.json
0 → 100644
View file @
a4f79190
{
"images"
:
[
{
"filename"
:
"onboarding-alerts.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
}
}
1Weather/Resources/Assets.xcassets/onboarding-alerts.imageset/onboarding-alerts.pdf
0 → 100644
View file @
a4f79190
File added
1Weather/Resources/Assets.xcassets/onboarding-close.imageset/Contents.json
0 → 100644
View file @
a4f79190
{
"images"
:
[
{
"filename"
:
"onboarding-close.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
,
"template-rendering-intent"
:
"template"
}
}
1Weather/Resources/Assets.xcassets/onboarding-close.imageset/onboarding-close.pdf
0 → 100644
View file @
a4f79190
File added
1Weather/Resources/Assets.xcassets/onboarding-forecast.imageset/Contents.json
0 → 100644
View file @
a4f79190
{
"images"
:
[
{
"filename"
:
"onboarding-forecast.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
}
}
1Weather/Resources/Assets.xcassets/onboarding-forecast.imageset/onboarding-forecast.pdf
0 → 100644
View file @
a4f79190
File added
1Weather/Resources/Assets.xcassets/onboarding-next.imageset/Contents.json
0 → 100644
View file @
a4f79190
{
"images"
:
[
{
"filename"
:
"onboarding-next.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
,
"template-rendering-intent"
:
"template"
}
}
1Weather/Resources/Assets.xcassets/onboarding-next.imageset/onboarding-next.pdf
0 → 100644
View file @
a4f79190
File added
1Weather/Resources/Assets.xcassets/onboarding-radar.imageset/Contents.json
0 → 100644
View file @
a4f79190
{
"images"
:
[
{
"filename"
:
"onboarding-radar.pdf"
,
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
},
"properties"
:
{
"preserves-vector-representation"
:
true
}
}
1Weather/Resources/Assets.xcassets/onboarding-radar.imageset/onboarding-radar.pdf
0 → 100644
View file @
a4f79190
File added
1Weather/Resources/en.lproj/Localizable.strings
View file @
a4f79190
...
...
@@ -278,3 +278,13 @@
// Ads
"ads.native.sponsored" = "Sponsored";
"ads.placeholder" = "Advertisement";
//Onboarding
"onboarding.skip" = "Skip";
"onboarding.done" = "Done";
"onboarding.forecast.title" = "Extended forecast";
"onboarding.forecast.subtitle" = "<Description>";
"onboarding.alerts.title" = "Weather alerts";
"onboarding.alerts.subtitle" = "<Description>";
"onboarding.radar.title" = "Live doppler radar";
"onboarding.radar.subtitle" = "<Description>";
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingAlertsController.swift
deleted
100644 → 0
View file @
68df3bed
//
// OnboardingAlertsController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.08.2021.
//
import
UIKit
class
OnboardingAlertsController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
view
.
backgroundColor
=
.
red
}
}
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingContentController.swift
0 → 100644
View file @
a4f79190
//
// OnboardingContentController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.08.2021.
//
import
UIKit
class
OnboardingContentController
:
UIViewController
{
//Private
private
let
mainImageView
=
UIImageView
()
private
let
titleLabel
=
UILabel
()
private
let
subtitleLabel
=
UILabel
()
init
(
type
:
OnboardingControllerType
)
{
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
mainImageView
.
image
=
type
.
image
titleLabel
.
text
=
type
.
title
subtitleLabel
.
text
=
type
.
subtitle
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareImageView
()
prepareLables
()
updateUI
()
}
override
func
traitCollectionDidChange
(
_
previousTraitCollection
:
UITraitCollection
?)
{
super
.
traitCollectionDidChange
(
previousTraitCollection
)
updateUI
()
}
private
func
updateUI
()
{
view
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
subtitleLabel
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
}
}
private
extension
OnboardingContentController
{
func
prepareImageView
()
{
mainImageView
.
contentMode
=
.
scaleAspectFit
view
.
addSubview
(
mainImageView
)
mainImageView
.
snp
.
makeConstraints
{
make
in
make
.
bottom
.
equalToSuperview
()
.
multipliedBy
(
0.56
)
make
.
centerX
.
equalToSuperview
()
make
.
left
.
right
.
equalToSuperview
()
.
inset
(
30
)
}
}
func
prepareLables
()
{
titleLabel
.
font
=
AppFont
.
SFPro
.
semibold
(
size
:
24
)
titleLabel
.
textColor
=
ThemeManager
.
currentTheme
.
graphTintColor
view
.
addSubview
(
titleLabel
)
subtitleLabel
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
14
)
view
.
addSubview
(
subtitleLabel
)
//Constraints
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
inset
(
30
)
make
.
bottom
.
equalToSuperview
()
.
multipliedBy
(
0.7
)
}
subtitleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
inset
(
30
)
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
10
)
}
}
}
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingForecastsController.swift
deleted
100644 → 0
View file @
68df3bed
//
// OnboardingForecastsController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.08.2021.
//
import
UIKit
class
OnboardingForecastsController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
view
.
backgroundColor
=
.
yellow
}
}
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingPageController.swift
View file @
a4f79190
...
...
@@ -7,22 +7,64 @@
import
UIKit
enum
OnboardingControllerType
{
case
forecast
case
alerts
case
radar
var
image
:
UIImage
?
{
switch
self
{
case
.
forecast
:
return
UIImage
(
named
:
"onboarding-forecast"
)
case
.
alerts
:
return
UIImage
(
named
:
"onboarding-alerts"
)
case
.
radar
:
return
UIImage
(
named
:
"onboarding-radar"
)
}
}
var
title
:
String
?
{
switch
self
{
case
.
forecast
:
return
"onboarding.forecast.title"
.
localized
()
case
.
alerts
:
return
"onboarding.alerts.title"
.
localized
()
case
.
radar
:
return
"onboarding.radar.title"
.
localized
()
}
}
var
subtitle
:
String
?
{
switch
self
{
case
.
forecast
:
return
"onboarding.forecast.subtitle"
.
localized
()
case
.
alerts
:
return
"onboarding.alerts.subtitle"
.
localized
()
case
.
radar
:
return
"onboarding.radar.subtitle"
.
localized
()
}
}
}
class
OnboardingPageController
:
UIPageViewController
{
private
let
forecastsController
=
OnboardingForecastsController
()
private
let
alertsController
=
OnboardingAlertsController
()
private
let
radarController
=
OnboardingAlertsController
()
private
let
coordinator
:
AppCoordinator
private
let
pageControl
=
UIPageControl
()
private
let
closeButton
=
UIButton
()
private
var
pages
=
[
UIViewController
]()
private
let
skipButton
=
SelfSizingButton
()
private
let
nextButton
=
UIButton
()
private
let
doneButton
=
UIButton
()
init
(
coordinator
:
AppCoordinator
)
{
self
.
coordinator
=
coordinator
super
.
init
(
transitionStyle
:
.
scroll
,
navigationOrientation
:
.
horizontal
,
options
:
nil
)
override
init
(
transitionStyle
style
:
UIPageViewController
.
TransitionStyle
,
navigationOrientation
:
UIPageViewController
.
NavigationOrientation
,
options
:
[
UIPageViewController
.
OptionsKey
:
Any
]?
=
nil
)
{
super
.
init
(
transitionStyle
:
.
scroll
,
navigationOrientation
:
.
horizontal
,
options
:
nil
)
modalPresentationStyle
=
.
fullScreen
pages
=
[
OnboardingContentController
(
type
:
.
forecast
),
OnboardingContentController
(
type
:
.
alerts
),
OnboardingContentController
(
type
:
.
radar
)]
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
...
...
@@ -30,16 +72,207 @@ class OnboardingPageController: UIPageViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
view
.
backgroundColor
=
.
lightGray
prepareController
()
prepareCloseButton
()
preparePageControl
()
prepareSkipButton
()
prepareNextButton
()
prepareDoneButton
()
updateUI
()
}
override
func
traitCollectionDidChange
(
_
previousTraitCollection
:
UITraitCollection
?)
{
super
.
traitCollectionDidChange
(
previousTraitCollection
)
updateUI
()
}
@objc
private
func
handleCloseButton
()
{
coordinator
.
finishInitialOnboarding
()
}
@objc
private
func
handleSkipButton
()
{
coordinator
.
finishInitialOnboarding
()
}
@objc
private
func
handleDoneButton
()
{
coordinator
.
finishInitialOnboarding
()
}
@objc
private
func
handleNextButton
()
{
guard
let
currentViewController
=
viewControllers
?
.
first
,
let
currentIndex
=
pages
.
firstIndex
(
of
:
currentViewController
)
else
{
return
}
let
nextIndex
=
currentIndex
+
1
guard
nextIndex
<
pages
.
count
else
{
return
}
setViewControllers
([
pages
[
nextIndex
]],
direction
:
.
forward
,
animated
:
true
)
{[
weak
self
]
_
in
self
?
.
pageControl
.
currentPage
=
nextIndex
self
?
.
showDoneIfNeeded
(
for
:
nextIndex
)
}
}
private
func
updateUI
()
{
closeButton
.
backgroundColor
=
ThemeManager
.
currentTheme
.
containerBackgroundColor
switch
view
.
interfaceStyle
{
case
.
light
:
let
color
=
UIColor
(
hex
:
0x756a6a
)
closeButton
.
tintColor
=
color
skipButton
.
setTitleColor
(
color
,
for
:
.
normal
)
nextButton
.
tintColor
=
color
pageControl
.
pageIndicatorTintColor
=
UIColor
(
hex
:
0xd0d0d0
)
case
.
dark
:
let
color
=
ThemeManager
.
currentTheme
.
primaryTextColor
closeButton
.
tintColor
=
color
skipButton
.
setTitleColor
(
color
,
for
:
.
normal
)
nextButton
.
tintColor
=
color
pageControl
.
pageIndicatorTintColor
=
UIColor
.
white
}
}
private
func
showDoneIfNeeded
(
for
pageIndex
:
Int
)
{
UIView
.
animate
(
withDuration
:
0.2
)
{
if
pageIndex
==
self
.
pages
.
count
-
1
{
self
.
nextButton
.
isHidden
=
true
self
.
doneButton
.
isHidden
=
false
}
else
{
self
.
doneButton
.
isHidden
=
true
self
.
nextButton
.
isHidden
=
false
}
}
}
}
//MARK:- Prepare
private
extension
OnboardingPageController
{
func
prepareController
()
{
view
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
dataSource
=
self
delegate
=
self
setViewControllers
([
forecastsController
],
direction
:
.
forward
,
animated
:
false
)
setViewControllers
([
pages
[
0
]],
direction
:
.
forward
,
animated
:
false
)
}
func
preparePageControl
()
{
pageControl
.
currentPageIndicatorTintColor
=
.
blue
pageControl
.
currentPage
=
0
pageControl
.
numberOfPages
=
pages
.
count
view
.
addSubview
(
pageControl
)
pageControl
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
inset
(
20
)
make
.
bottom
.
equalTo
(
view
.
safeAreaLayoutGuide
.
snp
.
bottom
)
.
offset
(
-
32
)
}
}
func
prepareCloseButton
()
{
closeButton
.
setImage
(
UIImage
(
named
:
"onboarding-close"
),
for
:
.
normal
)
closeButton
.
addTarget
(
self
,
action
:
#selector(
handleCloseButton
)
,
for
:
.
touchUpInside
)
closeButton
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
closeButton
.
imageView
?
.
contentMode
=
.
scaleAspectFit
closeButton
.
layer
.
shadowPath
=
CGPath
(
rect
:
.
init
(
origin
:
.
zero
,
size
:
.
init
(
width
:
35
,
height
:
35
)),
transform
:
nil
)
closeButton
.
layer
.
shadowColor
=
UIColor
(
hex
:
0x2c304c
)
.
cgColor
closeButton
.
layer
.
shadowOpacity
=
0.21
closeButton
.
layer
.
shadowOffset
=
.
init
(
width
:
0
,
height
:
11
)
closeButton
.
layer
.
shadowRadius
=
5
closeButton
.
layer
.
cornerRadius
=
5
closeButton
.
imageEdgeInsets
=
.
init
(
top
:
6
,
left
:
6
,
bottom
:
6
,
right
:
6
)
view
.
addSubview
(
closeButton
)
closeButton
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
35
)
make
.
top
.
equalTo
(
view
.
safeAreaLayoutGuide
.
snp
.
top
)
.
inset
(
16
)
make
.
left
.
equalTo
(
18
)
}
}
func
prepareSkipButton
()
{
let
attrString
=
NSAttributedString
(
string
:
"onboarding.skip"
.
localized
(),
attributes
:
[
.
underlineStyle
:
NSUnderlineStyle
.
single
.
rawValue
])
skipButton
.
setAttributedTitle
(
attrString
,
for
:
.
normal
)
skipButton
.
titleLabel
?
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
14
)
skipButton
.
addTarget
(
self
,
action
:
#selector(
handleSkipButton
)
,
for
:
.
touchUpInside
)
view
.
addSubview
(
skipButton
)
skipButton
.
snp
.
makeConstraints
{
make
in
make
.
centerX
.
equalToSuperview
()
make
.
centerY
.
equalTo
(
pageControl
)
}
}
func
prepareNextButton
()
{
nextButton
.
setImage
(
UIImage
(
named
:
"onboarding-next"
),
for
:
.
normal
)
nextButton
.
addTarget
(
self
,
action
:
#selector(
handleNextButton
)
,
for
:
.
touchUpInside
)
nextButton
.
imageEdgeInsets
=
.
init
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
view
.
addSubview
(
nextButton
)
nextButton
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
30
)
make
.
right
.
equalToSuperview
()
.
inset
(
24
)
make
.
centerY
.
equalTo
(
skipButton
)
}
}
func
prepareDoneButton
()
{
doneButton
.
isHidden
=
true
doneButton
.
addTarget
(
self
,
action
:
#selector(
handleDoneButton
)
,
for
:
.
touchUpInside
)
doneButton
.
backgroundColor
=
ThemeManager
.
currentTheme
.
graphTintColor
doneButton
.
setTitle
(
"onboarding.done"
.
localized
(),
for
:
.
normal
)
doneButton
.
setTitleColor
(
.
white
,
for
:
.
normal
)
doneButton
.
titleLabel
?
.
font
=
AppFont
.
SFPro
.
bold
(
size
:
21
)
doneButton
.
layer
.
cornerRadius
=
27
doneButton
.
layer
.
shadowPath
=
UIBezierPath
(
roundedRect
:
.
init
(
origin
:
.
zero
,
size
:
.
init
(
width
:
105
,
height
:
54
)),
cornerRadius
:
27
)
.
cgPath
doneButton
.
layer
.
shadowColor
=
UIColor
(
hex
:
0x1186cf
)
.
withAlphaComponent
(
0.5
)
.
cgColor
doneButton
.
layer
.
shadowOffset
=
.
init
(
width
:
3
,
height
:
3
)
doneButton
.
layer
.
shadowRadius
=
7
doneButton
.
layer
.
shadowOpacity
=
1
view
.
addSubview
(
doneButton
)
doneButton
.
snp
.
makeConstraints
{
make
in
make
.
width
.
equalTo
(
105
)
make
.
height
.
equalTo
(
54
)
make
.
right
.
equalToSuperview
()
.
inset
(
20
)
make
.
centerY
.
equalTo
(
pageControl
)
}
}
}
extension
OnboardingPageController
:
UIPageViewControllerDelegate
{
//MARK:- UIPageViewController Data Source
extension
OnboardingPageController
:
UIPageViewControllerDataSource
{
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerBefore
viewController
:
UIViewController
)
->
UIViewController
?
{
guard
let
viewControllerIndex
=
pages
.
firstIndex
(
of
:
viewController
)
else
{
return
nil
}
let
previousIndex
=
viewControllerIndex
-
1
guard
previousIndex
>=
0
else
{
return
nil
}
return
pages
[
previousIndex
]
}
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
viewControllerAfter
viewController
:
UIViewController
)
->
UIViewController
?
{
guard
let
viewControllerIndex
=
pages
.
firstIndex
(
of
:
viewController
)
else
{
return
nil
}
let
nextIndex
=
viewControllerIndex
+
1
guard
nextIndex
<
pages
.
count
else
{
return
nil
}
return
pages
[
nextIndex
]
}
}
//MARK:- UIPageViewController Delegate
extension
OnboardingPageController
:
UIPageViewControllerDelegate
{
func
pageViewController
(
_
pageViewController
:
UIPageViewController
,
didFinishAnimating
finished
:
Bool
,
previousViewControllers
:
[
UIViewController
],
transitionCompleted
completed
:
Bool
)
{
guard
let
currentPageVC
=
pageViewController
.
viewControllers
?
.
first
,
let
currentPageIndex
=
pages
.
firstIndex
(
of
:
currentPageVC
)
else
{
return
}
pageControl
.
currentPage
=
currentPageIndex
showDoneIfNeeded
(
for
:
currentPageIndex
)
}
}
1Weather/UI/View controllers/Onboarding/InitialOnboarding/OnboardingRadarController.swift
deleted
100644 → 0
View file @
68df3bed
//
// OnboardingRadarController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.08.2021.
//
import
UIKit
class
OnboardingRadarController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
view
.
backgroundColor
=
.
blue
}
}
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
View file @
a4f79190
...
...
@@ -95,6 +95,9 @@ public class Settings {
@UserDefaultsBasicValue(key: "locationDidAdded")
public
var
locationDidAdded
:
Bool
=
false
@UserDefaultsBasicValue(key: "initial_onboarding_showed")
public
var
initialOnboardingShowed
=
false
@UserDefaultsBasicValue(key: "shorts_showed_swipeUp_count")
public
var
shortsSwipeUpNudgeShowedCount
=
0
...
...
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