-
-
Notifications
You must be signed in to change notification settings - Fork 51
Add collapsible 'what's included' disclosure to onboarding template cards #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import Foundation | ||
|
|
||
| /// File overview: | ||
| /// Pure description of which behaviors each `OnboardingTemplate` turns on or off. The onboarding | ||
| /// template card uses this to render a collapsible "what's included" section so the user can see | ||
| /// exactly what they're opting into before tapping a card. | ||
| /// | ||
| /// Keeping this list as a pure helper (instead of inlining it in the SwiftUI view) means the same | ||
| /// summary is unit-testable and stays in lock-step with the source-of-truth properties on | ||
| /// `OnboardingTemplate`. If a template gains a new behavior flag, the row order here is the only | ||
| /// place to extend — the UI walks whatever rows this returns. | ||
|
|
||
| enum OnboardingTemplateFeatureValue: Equatable, Sendable { | ||
| /// Toggled on by the template. UI renders a positive affordance (e.g., a check). | ||
| case enabled | ||
| /// Explicitly off under the template. UI renders a neutral/negative affordance (e.g., a dash). | ||
| case disabled | ||
| /// A non-boolean setting that takes a value (e.g., suggestion length preset). UI shows the | ||
| /// trailing text alongside the row title. | ||
| case detail(String) | ||
| } | ||
|
|
||
| struct OnboardingTemplateFeatureRow: Equatable, Sendable, Identifiable { | ||
| let title: String | ||
| let value: OnboardingTemplateFeatureValue | ||
|
|
||
| /// `title` is unique within a template's row list, so it doubles as the SwiftUI identity key. | ||
| var id: String { title } | ||
| } | ||
|
|
||
| enum OnboardingTemplateFeatureList { | ||
| /// Returns the ordered rows shown in the template card's disclosure section. | ||
| /// Order matters: the most user-visible knob (suggestion length) comes first, then behavior | ||
| /// flags. Adding a new row here automatically surfaces it in the UI. | ||
| static func rows(for template: OnboardingTemplate) -> [OnboardingTemplateFeatureRow] { | ||
| [ | ||
| OnboardingTemplateFeatureRow( | ||
| title: "Suggestion length", | ||
| value: .detail(template.wordCountPreset.displayLabel) | ||
| ), | ||
| OnboardingTemplateFeatureRow( | ||
| title: "Fast mode (skip screen context)", | ||
| value: template.enablesFastMode ? .enabled : .disabled | ||
| ), | ||
| OnboardingTemplateFeatureRow( | ||
| title: "Clipboard context", | ||
| value: template.enablesClipboardContext ? .enabled : .disabled | ||
| ) | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import XCTest | ||
| @testable import Cotabby | ||
|
|
||
| final class OnboardingTemplateFeatureListTests: XCTestCase { | ||
| func testQuickShowsShortLengthAndFastModeOnAndClipboardOff() { | ||
| let rows = OnboardingTemplateFeatureList.rows(for: .quick) | ||
| XCTAssertEqual(rows.map(\.title), [ | ||
| "Suggestion length", | ||
| "Fast mode (skip screen context)", | ||
| "Clipboard context" | ||
| ]) | ||
| XCTAssertEqual(rows[0].value, .detail(OnboardingTemplate.quick.wordCountPreset.displayLabel)) | ||
| XCTAssertEqual(rows[1].value, .enabled) | ||
| XCTAssertEqual(rows[2].value, .disabled) | ||
| } | ||
|
|
||
| func testEverydayShowsMediumLengthFastModeOffAndClipboardOn() { | ||
| let rows = OnboardingTemplateFeatureList.rows(for: .everyday) | ||
| XCTAssertEqual(rows[0].value, .detail(OnboardingTemplate.everyday.wordCountPreset.displayLabel)) | ||
| XCTAssertEqual(rows[1].value, .disabled) | ||
| XCTAssertEqual(rows[2].value, .enabled) | ||
| } | ||
|
|
||
| func testPowerfulShowsLongLengthFastModeOffAndClipboardOn() { | ||
| let rows = OnboardingTemplateFeatureList.rows(for: .powerful) | ||
| XCTAssertEqual(rows[0].value, .detail(OnboardingTemplate.powerful.wordCountPreset.displayLabel)) | ||
| XCTAssertEqual(rows[1].value, .disabled) | ||
| XCTAssertEqual(rows[2].value, .enabled) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.