Skip to content

Commit 1fe8bc1

Browse files
authored
Add FXIOS-14757 [Stories Scroll Direction Experiment] Feature flag (#31861)
1 parent 12f5eac commit 1fe8bc1

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

firefox-ios/Client/FeatureFlags/LegacyFeatureFlagsManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ class LegacyFeatureFlagsManager: HasNimbusFeatureFlags, @unchecked Sendable {
8989
switch featureID {
9090
case .searchBarPosition: return SearchBarPosition(rawValue: userSetting) as? T
9191
case .startAtHome: return StartAtHome(rawValue: userSetting) as? T
92+
case .homepageStoriesScrollDirection: return ScrollDirection(rawValue: userSetting) as? T
9293
}
9394
}
9495

9596
private func convertCustomIDToStandard(_ featureID: NimbusFeatureFlagWithCustomOptionsID) -> NimbusFeatureFlagID {
9697
switch featureID {
9798
case .searchBarPosition: return .bottomSearchBar
9899
case .startAtHome: return .startAtHome
100+
case .homepageStoriesScrollDirection: return .homepageStoriesScrollDirection
99101
}
100102
}
101103

@@ -140,6 +142,8 @@ class LegacyFeatureFlagsManager: HasNimbusFeatureFlags, @unchecked Sendable {
140142
if let option = desiredState as? StartAtHome {
141143
feature.setUserPreference(to: option.rawValue)
142144
}
145+
default:
146+
break
143147
}
144148
}
145149

firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum NimbusFeatureFlagID: String, CaseIterable {
2626
case homepageBookmarksSectionDefault
2727
case homepageJumpBackinSectionDefault
2828
case homepageSearchBar
29+
case homepageStoriesScrollDirection
2930
case shouldUseBrandRefreshConfiguration
3031
case shouldUseJapanConfiguration
3132
case menuDefaultBrowserBanner
@@ -119,6 +120,7 @@ enum NimbusFeatureFlagID: String, CaseIterable {
119120
/// This enum is a constraint for any feature flag options that have more than
120121
/// just an ON or OFF setting. These option must also be added to `NimbusFeatureFlagID`
121122
enum NimbusFeatureFlagWithCustomOptionsID {
123+
case homepageStoriesScrollDirection
122124
case searchBarPosition
123125
case startAtHome
124126
}
@@ -158,6 +160,7 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar {
158160
.feltPrivacySimplifiedUI,
159161
.firefoxJpGuideDefaultSite,
160162
.homepageSearchBar,
163+
.homepageStoriesScrollDirection,
161164
.shouldUseBrandRefreshConfiguration,
162165
.shouldUseJapanConfiguration,
163166
.menuDefaultBrowserBanner,
@@ -259,6 +262,8 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar {
259262
switch featureID {
260263
case .bottomSearchBar:
261264
return nimbusSearchBar.getDefaultPosition().rawValue
265+
case .homepageStoriesScrollDirection:
266+
return FxNimbus.shared.features.homepageRedesignFeature.value().storiesScrollDirection.rawValue
262267
case .splashScreen:
263268
return nimbusSearchBar.getDefaultPosition().rawValue
264269
case .startAtHome:

firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ final class NimbusFeatureFlagLayer: Sendable {
5858
case .homepageSearchBar:
5959
return checkHomepageSearchBarFeature(from: nimbus)
6060

61+
case .homepageStoriesScrollDirection:
62+
return checkHomepageStoriesScrollDirectionFeature(from: nimbus) != .baseline
63+
6164
case .shouldUseBrandRefreshConfiguration:
6265
return checkShouldUseBrandRefreshConfigurationFeature(from: nimbus)
6366

@@ -247,6 +250,10 @@ final class NimbusFeatureFlagLayer: Sendable {
247250
return nimbus.features.homepageRedesignFeature.value().searchBar
248251
}
249252

253+
private func checkHomepageStoriesScrollDirectionFeature(from nimbus: FxNimbus) -> ScrollDirection {
254+
return nimbus.features.homepageRedesignFeature.value().storiesScrollDirection
255+
}
256+
250257
private func checkSnapKitRemovalRefactor(from nimbus: FxNimbus) -> Bool {
251258
let config = nimbus.features.snapkitRemovalRefactor.value()
252259
return config.enabled

firefox-ios/nimbus-features/homepageRedesignFeature.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ features:
99
If true, enables the search bar feature on homepage for users.
1010
type: Boolean
1111
default: false
12+
stories-scroll-direction:
13+
description: >
14+
Controls the layout direction for stories on the homepage.
15+
type: ScrollDirection
16+
default: baseline
1217
bookmarks-section-default:
1318
description: >
1419
If true, enables the bookmarks homepage section by default
@@ -24,11 +29,24 @@ features:
2429
- channel: beta
2530
value:
2631
search-bar: false
32+
stories-scroll-direction: baseline
2733
bookmarks-section-default: false
2834
jbi-section-default: false
2935

3036
- channel: developer
3137
value:
3238
search-bar: false
39+
stories-scroll-direction: baseline
3340
bookmarks-section-default: false
3441
jbi-section-default: false
42+
43+
enums:
44+
ScrollDirection:
45+
description: The layout direction for stories on the homepage.
46+
variants:
47+
baseline:
48+
description: Uses the current default stories layout.
49+
vertical:
50+
description: Shows stories in a vertical layout.
51+
horizontal:
52+
description: Shows stories in a horizontal layout.

0 commit comments

Comments
 (0)