Skip to content

Commit 2fa49d0

Browse files
committed
Release 2.6.0
1 parent 08bf24e commit 2fa49d0

File tree

10 files changed

+265
-95
lines changed

10 files changed

+265
-95
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.6.0] - 2019-12-24
8+
### Added
9+
Features are now grouped by section on `FeatureFlagsViewController` where sections are present.
10+
711
## [2.5.1] - 2019-12-23
812
### Changed
913
Fix for broken SPM build due to lack of specifity in Package.swift exclusion rule.

Example/FeatureFlags/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616

1717
func application(_ application: UIApplication, didFinishLaunchingWithOptions
1818
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
19+
FeatureFlags.deleteAllFeaturesFromCache()
1920
let navigationController = UINavigationController()
2021
window = UIWindow(frame: UIScreen.main.bounds)
2122
window?.rootViewController = navigationController

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FeatureFlags.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FeatureFlags'
3-
s.version = '2.5.1'
3+
s.version = '2.6.0'
44
s.swift_version = '5.0'
55
s.summary = 'Feature flagging, A/B testing, MVT and phased feature roll out for iOS.'
66
s.description = <<-DESC

FeatureFlags/Classes/Core/FeatureFlags.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public struct FeatureFlags {
4444
return .json // default
4545
}()
4646

47+
public static func deleteAllFeaturesFromCache() {
48+
FeatureFlags.clearCache()
49+
}
50+
4751
/// Removes the specified feature from the cache however the feature will remain in in-memory configuration.
4852
static func deleteFeatureFromCache(named name: Feature.Name) {
4953
// Load cached configuration, if exists
@@ -69,12 +73,15 @@ public struct FeatureFlags {
6973

7074
/// Returns only feature flags of the specified type. Used by `FeatureFlagsViewController` to provide
7175
/// filtering.
72-
public static func filter(_ section: String) -> [Feature]? {
76+
public static func filter(_ section: String?) -> [Feature]? {
77+
guard let filterSection = section else {
78+
return configuration?.filter { $0.section == nil }
79+
}
7380
return configuration?.filter {
7481
guard let featureSection = $0.section else {
7582
return false
7683
}
77-
return section == featureSection
84+
return filterSection == featureSection
7885
}
7986
}
8087

@@ -131,10 +138,14 @@ public struct FeatureFlags {
131138
}
132139

133140
/// Returns all sections titles for those features which have a section specified.
134-
public static func sections() -> [String] {
141+
public static func sections() -> [String?] {
135142
let allSections = configuration?.compactMap { $0.section }
136143
let distinctSections = allSections?.mapDistinct { $0 } ?? []
137-
return distinctSections.sorted()
144+
var sortedSections: [String?] = distinctSections.sorted()
145+
if FeatureFlags.filter(nil) != nil { // Check whether features without sections exist
146+
sortedSections.append(nil)
147+
}
148+
return sortedSections
138149
}
139150

140151
/// Transient update - will not be persisted

FeatureFlags/Classes/UI/Details/View Controller/FeatureDetailsViewController.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ class FeatureDetailsViewController: UITableViewController {
3636
case enabled
3737
case unlocked
3838
case labels
39+
case section
3940
case testVariations
4041
case testVariationAssignment
4142
}
4243

4344
private func cells(for featureType: FeatureType) -> [CellType] {
4445
switch featureType {
4546
case .featureFlag:
46-
return [.featureType, .enabled, .labels]
47+
return [.featureType, .enabled, .labels, .section]
4748
case .unlockFlag:
48-
return [.featureType, .enabled, .unlocked, .labels]
49+
return [.featureType, .enabled, .unlocked, .labels, .section]
4950
case .featureTest(.ab), .featureTest(.mvt), .featureTest(.featureFlagAB):
50-
return [.featureType, .enabled, .testVariations, .testVariationAssignment, .labels]
51+
return [.featureType, .enabled, .testVariations, .testVariationAssignment, .labels, .section]
5152
case .deprecated:
5253
return []
5354
}
@@ -91,6 +92,9 @@ class FeatureDetailsViewController: UITableViewController {
9192
bindTestVariationCell(cell, to: feature)
9293
case .testVariationAssignment:
9394
bindTestVariationAssignmentCell(cell, to: feature)
95+
case .section:
96+
cell.textLabel?.text = "Section"
97+
cell.detailTextLabel?.text = feature.section ?? "Uncategorized"
9498
}
9599
return cell
96100
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// FeatureFlagsViewController+UIViewControllerPreviewing.swift
3+
// FeatureFlags
4+
//
5+
// Created by Ross Butler on 23/12/2019.
6+
//
7+
8+
import Foundation
9+
10+
extension FeatureFlagsViewController: UIViewControllerPreviewingDelegate {
11+
12+
private func detailViewController(for indexPath: IndexPath) -> FeatureDetailsViewController {
13+
let viewController = FeatureDetailsViewController(style: .grouped)
14+
viewController.feature = viewModel.feature(for: indexPath)
15+
return viewController
16+
}
17+
18+
func previewingContext(_ previewingContext: UIViewControllerPreviewing,
19+
viewControllerForLocation location: CGPoint) -> UIViewController? {
20+
if let indexPath = tableView.indexPathForRow(at: location) {
21+
previewingContext.sourceRect = tableView.rectForRow(at: indexPath)
22+
return detailViewController(for: indexPath)
23+
}
24+
return nil
25+
}
26+
27+
func previewingContext(_ previewingContext: UIViewControllerPreviewing,
28+
commit viewControllerToCommit: UIViewController) {
29+
navigationController?.pushViewController(viewControllerToCommit, animated: true)
30+
}
31+
32+
}

0 commit comments

Comments
 (0)