Skip to content

Commit

Permalink
Onboarding Intro - Add choose address bar position (#3340)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1206329551987282/1208084960726997/f

**Description**:
Add Address Bar position selection screen to the onboarding.
  • Loading branch information
alessandroboron authored Sep 11, 2024
1 parent 568e052 commit 29e2b79
Show file tree
Hide file tree
Showing 15 changed files with 729 additions and 28 deletions.
82 changes: 82 additions & 0 deletions Core/NSAttributedStringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,86 @@ extension NSAttributedString {
newString.setAttributes([.font: newFont], range: string.fullRange)
return newString
}

/// Creates a new `NSAttributedString` initialized with the characters and attributes of the current attributed string plus the specified font.
///
/// - Parameter font: The `UIFont` to apply to the text in the `NSAttributedString`.
/// - Returns: A new `NSAttributedString`initialized with characters and attributes of the current attributed string plus the specified font.
public func withFont(_ font: UIFont) -> NSAttributedString {
with(attribute: .font, value: font)
}

/// Creates a new `NSAttributedString` initialized with the characters and attributes of the current attributed string plus the specified text color
///
/// - Parameter color: The color to apply to the text
/// - Returns: A new `NSAttributedString` initialized with characters and attributes of the current attributed string plus the text color
public func withTextColor(_ color: UIColor) -> NSAttributedString {
with(attribute: .foregroundColor, value: color)
}

/// Creates a new `NSAttributedString` initialized with the characters and attributes of the current attributed string plus the specified attribute
///
/// - Parameters:
/// - key: The attribute key to apply. This should be one of the keys defined in `NSAttributedString.Key`.
/// - value: The value associated with the attribute key. This can be any object compatible with the attribute.
/// - range: An optional `NSRange` specifying the range within the `NSAttributedString` to apply the attribute.
/// If `nil`, the attribute is applied to the entire `NSAttributedString`.
/// - Returns: A new `NSAttributedString` with the specified attribute applied.
public func with(attribute key: NSAttributedString.Key, value: Any, in range: NSRange? = nil) -> NSAttributedString {
with(attributes: [key: value], in: range)
}

/// Creates a new `NSAttributedString` initialized with the characters and attributes of the current attributed string plus the specified attributes
///
/// - Parameters:
/// - attributes: A dictionary of attributes to apply, where the keys are of type `NSAttributedString.Key` and the values
/// are objects compatible with the attributes (e.g., `UIFont`, `UIColor`).
/// - range: An optional `NSRange` specifying the range within the `NSAttributedString` to apply the attributes.
/// If `nil`, the attributes are applied to the entire `NSAttributedString`.
/// - Returns: A new `NSAttributedString` with the specified attributes applied.
public func with(attributes: [NSAttributedString.Key: Any], in range: NSRange? = nil) -> NSAttributedString {
let mutableString = NSMutableAttributedString(attributedString: self)
mutableString.addAttributes(attributes, range: range ?? string.nsRange)
return mutableString
}
}

/// Concatenates two `NSAttributedString` instances, returning a new `NSAttributedString`.
///
/// - Parameters:
/// - lhs: The left-hand side `NSAttributedString` to which the `rhs` `NSAttributedString` will be appended.
/// - rhs: The `NSAttributedString` to append to the `lhs` `NSAttributedString`.
/// - Returns: A new `NSAttributedString` that is the result of concatenating `lhs` and `rhs`.
public func + (lhs: NSAttributedString, rhs: NSAttributedString) -> NSAttributedString {
let mutable = NSMutableAttributedString(attributedString: lhs)
mutable.append(rhs)
return mutable
}

/// Concatenates an `NSAttributedString` with a `String`, returning a new `NSAttributedString`.
///
/// - Parameters:
/// - lhs: The left-hand side `NSAttributedString` to which the `String` will be appended.
/// - rhs: The `String` to append to the `lhs` `NSAttributedString`.
/// - Returns: A new `NSAttributedString` which is the result of concatenating `lhs` with `rhs`.
public func + (lhs: NSAttributedString, rhs: String) -> NSAttributedString {
lhs + NSAttributedString(string: rhs)
}

/// Concatenates a `String` with an `NSAttributedString`, returning a new `NSAttributedString`.
///
/// - Parameters:
/// - lhs: The `String` to prepend to the `rhs` `NSAttributedString`.
/// - rhs: The right-hand side `NSAttributedString` that will be appended to the `lhs` `String`.
/// - Returns: A new `NSAttributedString` which is the result of concatenating `lhs` with `rhs`.
public func + (lhs: String, rhs: NSAttributedString) -> NSAttributedString {
NSAttributedString(string: lhs) + rhs
}

private extension String {

var nsRange: NSRange {
NSRange(startIndex..., in: self)
}

}
24 changes: 24 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@
9F7CFF762C86BB8F0012833E /* OnboardingView+AppIconPickerContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F7CFF752C86BB8F0012833E /* OnboardingView+AppIconPickerContent.swift */; };
9F7CFF782C86E3E10012833E /* OnboardingManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F7CFF772C86E3E10012833E /* OnboardingManagerTests.swift */; };
9F7CFF7D2C89B69A0012833E /* AppIconPickerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F7CFF7C2C89B69A0012833E /* AppIconPickerViewModelTests.swift */; };
9F7CFF7F2C8A94F70012833E /* OnboardingView+AddressBarPositionContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F7CFF7E2C8A94F70012833E /* OnboardingView+AddressBarPositionContent.swift */; };
9F8007262C5261AF003EDAF4 /* MockPrivacyDataReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F8007252C5261AF003EDAF4 /* MockPrivacyDataReporter.swift */; };
9F8FE9492BAE50E50071E372 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 9F8FE9482BAE50E50071E372 /* Lottie */; };
9F9A922E2C86A56B001D036D /* OnboardingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F9A922D2C86A56B001D036D /* OnboardingManager.swift */; };
Expand All @@ -717,7 +718,10 @@
9FCFCD802C6AF56D006EB7A0 /* LaunchOptionsHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFCD7F2C6AF56D006EB7A0 /* LaunchOptionsHandlerTests.swift */; };
9FCFCD812C6B020D006EB7A0 /* LaunchOptionsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFCD7D2C6AF52A006EB7A0 /* LaunchOptionsHandler.swift */; };
9FCFCD852C75C91A006EB7A0 /* ProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FCFCD842C75C91A006EB7A0 /* ProgressBarView.swift */; };
9FDEC7B42C8FD62F00C7A692 /* OnboardingAddressBarPositionPickerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDEC7B32C8FD62F00C7A692 /* OnboardingAddressBarPositionPickerViewModelTests.swift */; };
9FDEC7BC2C91204900C7A692 /* AppIconPickerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDEC7BB2C91204900C7A692 /* AppIconPickerViewModel.swift */; };
9FDEC7BF2C91264C00C7A692 /* OnboardingAddressBarPositionPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDEC7BE2C91264C00C7A692 /* OnboardingAddressBarPositionPicker.swift */; };
9FDEC7C12C9127F100C7A692 /* OnboardingAddressBarPositionPickerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDEC7C02C9127F100C7A692 /* OnboardingAddressBarPositionPickerViewModel.swift */; };
9FE05CEE2C36424E00D9046B /* OnboardingPixelReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FE05CED2C36424E00D9046B /* OnboardingPixelReporter.swift */; };
9FE05CF12C36468A00D9046B /* OnboardingPixelReporterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FE05CEF2C3642F900D9046B /* OnboardingPixelReporterTests.swift */; };
9FE08BD32C2A5B88001D5EBC /* OnboardingTextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FE08BD22C2A5B88001D5EBC /* OnboardingTextStyles.swift */; };
Expand Down Expand Up @@ -2485,6 +2489,7 @@
9F7CFF752C86BB8F0012833E /* OnboardingView+AppIconPickerContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OnboardingView+AppIconPickerContent.swift"; sourceTree = "<group>"; };
9F7CFF772C86E3E10012833E /* OnboardingManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingManagerTests.swift; sourceTree = "<group>"; };
9F7CFF7C2C89B69A0012833E /* AppIconPickerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconPickerViewModelTests.swift; sourceTree = "<group>"; };
9F7CFF7E2C8A94F70012833E /* OnboardingView+AddressBarPositionContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OnboardingView+AddressBarPositionContent.swift"; sourceTree = "<group>"; };
9F8007252C5261AF003EDAF4 /* MockPrivacyDataReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPrivacyDataReporter.swift; sourceTree = "<group>"; };
9F9A922D2C86A56B001D036D /* OnboardingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingManager.swift; sourceTree = "<group>"; };
9F9A92302C86AAE9001D036D /* OnboardingDebugView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingDebugView.swift; sourceTree = "<group>"; };
Expand All @@ -2500,7 +2505,10 @@
9FCFCD7D2C6AF52A006EB7A0 /* LaunchOptionsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LaunchOptionsHandler.swift; path = ../DuckDuckGo/LaunchOptionsHandler.swift; sourceTree = "<group>"; };
9FCFCD7F2C6AF56D006EB7A0 /* LaunchOptionsHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchOptionsHandlerTests.swift; sourceTree = "<group>"; };
9FCFCD842C75C91A006EB7A0 /* ProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarView.swift; sourceTree = "<group>"; };
9FDEC7B32C8FD62F00C7A692 /* OnboardingAddressBarPositionPickerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingAddressBarPositionPickerViewModelTests.swift; sourceTree = "<group>"; };
9FDEC7BB2C91204900C7A692 /* AppIconPickerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconPickerViewModel.swift; sourceTree = "<group>"; };
9FDEC7BE2C91264C00C7A692 /* OnboardingAddressBarPositionPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingAddressBarPositionPicker.swift; sourceTree = "<group>"; };
9FDEC7C02C9127F100C7A692 /* OnboardingAddressBarPositionPickerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingAddressBarPositionPickerViewModel.swift; sourceTree = "<group>"; };
9FE05CED2C36424E00D9046B /* OnboardingPixelReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingPixelReporter.swift; sourceTree = "<group>"; };
9FE05CEF2C3642F900D9046B /* OnboardingPixelReporterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingPixelReporterTests.swift; sourceTree = "<group>"; };
9FE08BD22C2A5B88001D5EBC /* OnboardingTextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTextStyles.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4671,6 +4679,7 @@
9FB027112C2526DD009EA190 /* OnboardingView+IntroDialogContent.swift */,
9FB027132C252E0C009EA190 /* OnboardingView+BrowsersComparisonContent.swift */,
9F7CFF752C86BB8F0012833E /* OnboardingView+AppIconPickerContent.swift */,
9F7CFF7E2C8A94F70012833E /* OnboardingView+AddressBarPositionContent.swift */,
);
path = OnboardingIntro;
sourceTree = "<group>";
Expand All @@ -4690,6 +4699,7 @@
9F69331A2C5A16E200CD6A5D /* OnboardingDaxFavouritesTests.swift */,
9F7CFF772C86E3E10012833E /* OnboardingManagerTests.swift */,
9F7CFF7C2C89B69A0012833E /* AppIconPickerViewModelTests.swift */,
9FDEC7B32C8FD62F00C7A692 /* OnboardingAddressBarPositionPickerViewModelTests.swift */,
);
name = Onboarding;
sourceTree = "<group>";
Expand Down Expand Up @@ -4756,6 +4766,15 @@
path = BrowsersComparison;
sourceTree = "<group>";
};
9FDEC7BD2C9125EC00C7A692 /* AddressBarPositionPicker */ = {
isa = PBXGroup;
children = (
9FDEC7BE2C91264C00C7A692 /* OnboardingAddressBarPositionPicker.swift */,
9FDEC7C02C9127F100C7A692 /* OnboardingAddressBarPositionPickerViewModel.swift */,
);
path = AddressBarPositionPicker;
sourceTree = "<group>";
};
9FE05CEC2C36423C00D9046B /* Pixels */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4784,6 +4803,7 @@
9FF7E9802C22A19800902BE5 /* OnboardingExperiment */ = {
isa = PBXGroup;
children = (
9FDEC7BD2C9125EC00C7A692 /* AddressBarPositionPicker */,
9F9A92322C86B419001D036D /* AppIconPicker */,
9F9A922C2C86A560001D036D /* Manager */,
9FE05CEC2C36423C00D9046B /* Pixels */,
Expand Down Expand Up @@ -7350,6 +7370,7 @@
986DA94A24884B18004A7E39 /* WebViewTransition.swift in Sources */,
31B524572715BB23002225AB /* WebJSAlert.swift in Sources */,
C1641EB32BC2F53C0012607A /* ImportPasswordsViewModel.swift in Sources */,
9FDEC7BF2C91264C00C7A692 /* OnboardingAddressBarPositionPicker.swift in Sources */,
8536A1FD2ACF114B003AC5BA /* Theme+DesignSystem.swift in Sources */,
F114C55B1E66EB020018F95F /* NibLoading.swift in Sources */,
D6BFCB612B7525160051FF81 /* SubscriptionPIRViewModel.swift in Sources */,
Expand Down Expand Up @@ -7466,6 +7487,7 @@
9F9A92312C86AAE9001D036D /* OnboardingDebugView.swift in Sources */,
1EFDCBC127D2393C00916BC5 /* DownloadsDeleteHelper.swift in Sources */,
C1836CE12C359EC90016D057 /* AutofillBreakageReportCellContentView.swift in Sources */,
9FDEC7C12C9127F100C7A692 /* OnboardingAddressBarPositionPickerViewModel.swift in Sources */,
6F9FFE282C579DEA00A238BE /* NewTabPageSectionsSettingsStorage.swift in Sources */,
85374D3C21AC41E700FF5A1E /* FavoritesHomeViewSectionRenderer.swift in Sources */,
85DFEDF124C7EEA400973FE7 /* LargeOmniBarState.swift in Sources */,
Expand Down Expand Up @@ -7709,6 +7731,7 @@
8590CB67268A2E520089F6BF /* RootDebugViewController.swift in Sources */,
1DEAADEA2BA4539800E25A97 /* SettingsAppearanceView.swift in Sources */,
B623C1C22862CA9E0043013E /* DownloadSession.swift in Sources */,
9F7CFF7F2C8A94F70012833E /* OnboardingView+AddressBarPositionContent.swift in Sources */,
F16390821E648B7A005B4550 /* HomeViewController.swift in Sources */,
985892522260B1B200EEB31B /* ProgressView.swift in Sources */,
85BA585A1F3506AE00C6E8CA /* AppSettings.swift in Sources */,
Expand Down Expand Up @@ -7782,6 +7805,7 @@
C14882E327F20D9A00D59F0C /* BookmarksExporterTests.swift in Sources */,
85C29708247BDD060063A335 /* DaxDialogsBrowsingSpecTests.swift in Sources */,
9FE05CF12C36468A00D9046B /* OnboardingPixelReporterTests.swift in Sources */,
9FDEC7B42C8FD62F00C7A692 /* OnboardingAddressBarPositionPickerViewModelTests.swift in Sources */,
85BA58581F34F72F00C6E8CA /* AppUserDefaultsTests.swift in Sources */,
F1134EBC1F40D45700B73467 /* MockStatisticsStore.swift in Sources */,
9FCFCD802C6AF56D006EB7A0 /* LaunchOptionsHandlerTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "address-bar-bottom.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "address-bar-top.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Shape.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Loading

0 comments on commit 29e2b79

Please sign in to comment.