|
1 | 1 | #if !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS) |
| 2 | + |
2 | 3 | import UIKit |
3 | 4 |
|
4 | 5 | public class FeaturesViewController: UIViewController { |
@@ -45,90 +46,38 @@ public class FeaturesViewController: UIViewController { |
45 | 46 |
|
46 | 47 | @objc func resetDefaults() { |
47 | 48 | SentrySDKOverrides.resetDefaults() |
| 49 | + SentrySDKWrapper.shared.startSentry() |
48 | 50 | tableView.reloadData() |
49 | 51 | } |
50 | 52 | } |
51 | 53 |
|
52 | 54 | extension FeaturesViewController: UITableViewDataSource { |
53 | 55 | public func numberOfSections(in tableView: UITableView) -> Int { |
54 | | - 6 |
| 56 | + SentrySDKOverrides.allCases.count |
55 | 57 | } |
56 | 58 |
|
57 | 59 | public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { |
58 | | - if section == 0 { |
59 | | - return "Special" |
60 | | - } else if section == 1 { |
61 | | - return "Performance" |
62 | | - } else if section == 2 { |
63 | | - return "Tracing" |
64 | | - } else if section == 3 { |
65 | | - return "Profiling" |
66 | | - } else if section == 4 { |
67 | | - return "Feedback" |
68 | | - } else if section == 5 { |
69 | | - return "Other" |
70 | | - } |
71 | | - return nil |
| 60 | + SentrySDKOverrides.allCases[section].rawValue |
72 | 61 | } |
73 | 62 |
|
74 | 63 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
75 | | - if section == 0 { |
76 | | - return SentrySDKOverrides.Special.allCases.count |
77 | | - } else if section == 1 { |
78 | | - return SentrySDKOverrides.Performance.allCases.count |
79 | | - } else if section == 2 { |
80 | | - return SentrySDKOverrides.Tracing.allCases.count |
81 | | - } else if section == 3 { |
82 | | - return SentrySDKOverrides.Profiling.allCases.count |
83 | | - } else if section == 4 { |
84 | | - return SentrySDKOverrides.Feedback.allCases.count |
85 | | - } else if section == 5 { |
86 | | - return SentrySDKOverrides.Other.allCases.count |
87 | | - } |
88 | | - return 0 |
| 64 | + SentrySDKOverrides.allCases[section].featureFlags.count |
89 | 65 | } |
90 | 66 |
|
91 | 67 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
92 | | - if indexPath.section == 2 { |
93 | | - if SentrySDKOverrides.Tracing.boolValues.contains(SentrySDKOverrides.Tracing.allCases[indexPath.row]) { |
94 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "launchArgumentCell", for: indexPath) as! LaunchArgumentTableViewCell |
95 | | - cell.configure(with: SentrySDKOverrides.Tracing.allCases[indexPath.row]) |
96 | | - return cell |
97 | | - } else { |
98 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "environmentVariableCell", for: indexPath) as! EnvironmentVariableTableViewCell |
99 | | - cell.configure(with: SentrySDKOverrides.Tracing.allCases[indexPath.row], float: true) |
100 | | - return cell |
101 | | - } |
102 | | - } else if indexPath.section == 3 { |
103 | | - if SentrySDKOverrides.Profiling.boolValues.contains(SentrySDKOverrides.Profiling.allCases[indexPath.row]) { |
104 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "launchArgumentCell", for: indexPath) as! LaunchArgumentTableViewCell |
105 | | - cell.configure(with: SentrySDKOverrides.Profiling.allCases[indexPath.row]) |
106 | | - return cell |
107 | | - } else { |
108 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "environmentVariableCell", for: indexPath) as! EnvironmentVariableTableViewCell |
109 | | - cell.configure(with: SentrySDKOverrides.Profiling.allCases[indexPath.row], float: true) |
110 | | - return cell |
111 | | - } |
112 | | - } else if indexPath.section == 5 { |
113 | | - if SentrySDKOverrides.Other.boolValues.contains(SentrySDKOverrides.Other.allCases[indexPath.row]) { |
114 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "launchArgumentCell", for: indexPath) as! LaunchArgumentTableViewCell |
115 | | - cell.configure(with: SentrySDKOverrides.Other.allCases[indexPath.row]) |
116 | | - return cell |
117 | | - } else { |
118 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "environmentVariableCell", for: indexPath) as! EnvironmentVariableTableViewCell |
119 | | - cell.configure(with: SentrySDKOverrides.Other.allCases[indexPath.row], float: false) |
120 | | - return cell |
121 | | - } |
| 68 | + let featureType = SentrySDKOverrides.allCases[indexPath.section] |
| 69 | + let featureFlag = featureType.featureFlags[indexPath.row] |
| 70 | + |
| 71 | + let reuseIdentifier: String |
| 72 | + switch featureFlag.overrideType { |
| 73 | + case .boolean: |
| 74 | + reuseIdentifier = "launchArgumentCell" |
| 75 | + case .float, .string: |
| 76 | + reuseIdentifier = "environmentVariableCell" |
122 | 77 | } |
123 | 78 |
|
124 | | - let cell = tableView.dequeueReusableCell(withIdentifier: "launchArgumentCell", for: indexPath) as! LaunchArgumentTableViewCell |
125 | | - if indexPath.section == 0 { |
126 | | - cell.configure(with: SentrySDKOverrides.Special.allCases[indexPath.row]) |
127 | | - } else if indexPath.section == 1 { |
128 | | - cell.configure(with: SentrySDKOverrides.Performance.allCases[indexPath.row]) |
129 | | - } else if indexPath.section == 4 { |
130 | | - cell.configure(with: SentrySDKOverrides.Feedback.allCases[indexPath.row]) |
131 | | - } |
| 79 | + let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as! FeatureFlagCell |
| 80 | + cell.configure(with: featureFlag) |
132 | 81 | return cell |
133 | 82 | } |
134 | 83 | } |
|
0 commit comments