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
abb22295
Commit
abb22295
authored
Sep 12, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-155: control feature availability based on Premium Subscription status.
parent
04542a02
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
4 deletions
+33
-4
1Weather/AppDelegate.swift
+5
-1
1Weather/Network/Configuration/ConfigManager.swift
+1
-1
1Weather/UI/Helpers/ForecastTimePeriod/ForecastTimePeriodView.swift
+12
-0
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
+1
-1
1Weather/ViewModels/ForecastViewModel.swift
+12
-1
OneWeatherCore/OneWeatherCore/Managers/FeatureAvailability/AppFeature.swift
+2
-0
No files found.
1Weather/AppDelegate.swift
View file @
abb22295
...
@@ -232,7 +232,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -232,7 +232,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
case
.
shorts
:
case
.
shorts
:
availabilityCheckers
[
feature
]
=
usOnly
&&
isPhone
availabilityCheckers
[
feature
]
=
usOnly
&&
isPhone
case
.
airQualityIndex
:
case
.
airQualityIndex
:
break
availabilityCheckers
[
feature
]
=
premium
case
.
attPrompt
:
case
.
attPrompt
:
break
// config only
break
// config only
case
.
nwsAlertsViaMoEngage
:
case
.
nwsAlertsViaMoEngage
:
...
@@ -245,6 +245,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -245,6 +245,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
break
// configOnly
break
// configOnly
case
.
subscriptionForPro
:
case
.
subscriptionForPro
:
availabilityCheckers
[
feature
]
=
premium
availabilityCheckers
[
feature
]
=
premium
case
.
extendedDailyForecast
:
availabilityCheckers
[
feature
]
=
premium
case
.
extendedHourlyForecast
:
availabilityCheckers
[
feature
]
=
premium
}
}
}
}
...
...
1Weather/Network/Configuration/ConfigManager.swift
View file @
abb22295
...
@@ -195,7 +195,7 @@ fileprivate extension AppFeature {
...
@@ -195,7 +195,7 @@ fileprivate extension AppFeature {
return
"shorts_swipe_down_nudge_enabled"
return
"shorts_swipe_down_nudge_enabled"
case
.
onboarding
:
case
.
onboarding
:
return
"ios_show_onboarding"
return
"ios_show_onboarding"
case
.
ads
,
.
airQualityIndex
,
.
minutelyForecast
,
.
shorts
,
.
subscription
,
.
subscriptionForPro
:
case
.
ads
,
.
airQualityIndex
,
.
minutelyForecast
,
.
shorts
,
.
subscription
,
.
subscriptionForPro
,
.
extendedDailyForecast
,
.
extendedHourlyForecast
:
return
nil
return
nil
// don't use 'default', so that we didn't add new features here in the future.
// don't use 'default', so that we didn't add new features here in the future.
}
}
...
...
1Weather/UI/Helpers/ForecastTimePeriod/ForecastTimePeriodView.swift
View file @
abb22295
...
@@ -30,6 +30,8 @@ protocol ForecastTimePeriodViewDelegate: AnyObject {
...
@@ -30,6 +30,8 @@ protocol ForecastTimePeriodViewDelegate: AnyObject {
class
ForecastTimePeriodView
:
UIView
{
class
ForecastTimePeriodView
:
UIView
{
//Private
//Private
private
let
storeManager
=
StoreManager
.
shared
private
let
featureAvailability
:
FeatureAvailabilityManager
=
FeatureAvailabilityManager
.
shared
private
let
scrollView
=
UIScrollView
()
private
let
scrollView
=
UIScrollView
()
private
let
stackView
=
UIStackView
()
private
let
stackView
=
UIStackView
()
private
let
graphView
=
GraphView
(
graphInsets
:
.
init
(
top
:
0
,
left
:
8
,
bottom
:
0
,
right
:
8
))
private
let
graphView
=
GraphView
(
graphInsets
:
.
init
(
top
:
0
,
left
:
8
,
bottom
:
0
,
right
:
8
))
...
@@ -63,12 +65,22 @@ class ForecastTimePeriodView: UIView {
...
@@ -63,12 +65,22 @@ class ForecastTimePeriodView: UIView {
//Public
//Public
public
func
set
(
daily
:[
DailyWeather
]?
=
nil
,
hourly
:[
HourlyWeather
]?
=
nil
)
{
public
func
set
(
daily
:[
DailyWeather
]?
=
nil
,
hourly
:[
HourlyWeather
]?
=
nil
)
{
if
let
inputDaily
=
daily
{
if
let
inputDaily
=
daily
{
if
featureAvailability
.
isAvailable
(
feature
:
.
extendedDailyForecast
)
{
self
.
daily
=
inputDaily
self
.
daily
=
inputDaily
}
}
else
{
self
.
daily
=
[
DailyWeather
](
inputDaily
.
prefix
(
7
))
}
}
if
let
inputHourly
=
hourly
{
if
let
inputHourly
=
hourly
{
if
featureAvailability
.
isAvailable
(
feature
:
.
extendedHourlyForecast
)
{
self
.
hourly
=
inputHourly
self
.
hourly
=
inputHourly
}
}
else
{
self
.
hourly
=
[
HourlyWeather
](
inputHourly
.
prefix
(
24
))
}
}
}
}
public
func
set
(
forecastType
:
ForecastType
,
buttonType
:
PeriodButtonProtocol
.
Type
)
{
public
func
set
(
forecastType
:
ForecastType
,
buttonType
:
PeriodButtonProtocol
.
Type
)
{
...
...
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
View file @
abb22295
...
@@ -241,7 +241,7 @@ class TodayCellFactory: CellFactory {
...
@@ -241,7 +241,7 @@ class TodayCellFactory: CellFactory {
rowsToHide
.
insert
(
.
alert
)
rowsToHide
.
insert
(
.
alert
)
}
}
if
location
?
.
health
?
.
airQuality
==
nil
{
if
location
?
.
health
?
.
airQuality
==
nil
||
!
featureAvailabilityManager
.
isAvailable
(
feature
:
.
airQualityIndex
)
{
rowsToHide
.
insert
(
.
airQuality
)
rowsToHide
.
insert
(
.
airQuality
)
}
}
...
...
1Weather/ViewModels/ForecastViewModel.swift
View file @
abb22295
...
@@ -33,16 +33,19 @@ class ForecastViewModel: ViewModelProtocol {
...
@@ -33,16 +33,19 @@ class ForecastViewModel: ViewModelProtocol {
//Private
//Private
private
var
locationManager
:
LocationManager
private
var
locationManager
:
LocationManager
private
let
storeManager
:
StoreManager
deinit
{
deinit
{
Settings
.
shared
.
delegate
.
remove
(
delegate
:
self
)
Settings
.
shared
.
delegate
.
remove
(
delegate
:
self
)
self
.
locationManager
.
remove
(
delegate
:
self
)
self
.
locationManager
.
remove
(
delegate
:
self
)
}
}
public
init
(
locationManager
:
LocationManager
)
{
public
init
(
locationManager
:
LocationManager
,
storeManager
:
StoreManager
=
StoreManager
.
shared
)
{
self
.
locationManager
=
locationManager
self
.
locationManager
=
locationManager
self
.
storeManager
=
storeManager
locationManager
.
add
(
delegate
:
self
)
locationManager
.
add
(
delegate
:
self
)
Settings
.
shared
.
delegate
.
add
(
delegate
:
self
)
Settings
.
shared
.
delegate
.
add
(
delegate
:
self
)
self
.
storeManager
.
add
(
observer
:
self
)
}
}
public
func
updateWeather
()
{
public
func
updateWeather
()
{
...
@@ -96,3 +99,11 @@ extension ForecastViewModel: SettingsDelegate {
...
@@ -96,3 +99,11 @@ extension ForecastViewModel: SettingsDelegate {
}
}
}
}
}
}
extension
ForecastViewModel
:
StoreManagerObserver
{
func
storeManagerUpdatedStatus
(
_
storeManager
:
StoreManager
)
{
onMain
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
}
}
OneWeatherCore/OneWeatherCore/Managers/FeatureAvailability/AppFeature.swift
View file @
abb22295
...
@@ -14,6 +14,8 @@ public enum AppFeature: String, Codable, CaseIterable {
...
@@ -14,6 +14,8 @@ public enum AppFeature: String, Codable, CaseIterable {
case
nwsAlertsViaMoEngage
case
nwsAlertsViaMoEngage
case
onboarding
case
onboarding
case
minutelyForecast
case
minutelyForecast
case
extendedHourlyForecast
case
extendedDailyForecast
case
shorts
case
shorts
case
shortsLastNudge
case
shortsLastNudge
/// Any kind of subscription
/// Any kind of subscription
...
...
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