diff --git a/ios/.swift-format b/ios/.swift-format index 5c39f4314db71e..c116fe90be68fd 100644 --- a/ios/.swift-format +++ b/ios/.swift-format @@ -17,11 +17,11 @@ "respectsExistingLineBreaks" : true, "rules" : { "AllPublicDeclarationsHaveDocumentation" : false, - "AlwaysUseLowerCamelCase" : false, + "AlwaysUseLowerCamelCase" : true, "AmbiguousTrailingClosureOverload" : true, "BeginDocumentationCommentWithOneLineSummary" : false, "DoNotUseSemicolons" : true, - "DontRepeatTypeInStaticProperties" : false, + "DontRepeatTypeInStaticProperties" : true, "FileScopedDeclarationPrivacy" : true, "FullyIndirectEnum" : true, "GroupNumericLiterals" : true, diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_image_view.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_image_view.swift index 1f39b7903614e4..d7ae5eae14f6d0 100644 --- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_image_view.swift +++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_image_view.swift @@ -8,7 +8,7 @@ import SwiftUI struct PopupMatchImageView: View { enum Dimension { /// The width and height of all images. - static let imageDimension: CGFloat = 30 + static let image: CGFloat = 30 } /// The image model object for this view. @@ -34,7 +34,7 @@ struct PopupMatchImageView: View { image.iconImage?.foregroundColor(image.iconImageTintColor) } } - .frame(width: Dimension.imageDimension, height: Dimension.imageDimension) + .frame(width: Dimension.image, height: Dimension.image) } } diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_action_button.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_action_button.swift index 6720f2e0f6347b..cfe03db597c7dc 100644 --- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_action_button.swift +++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_action_button.swift @@ -7,7 +7,7 @@ import SwiftUI /// A button view to trigger the pedal/action associated with an Omnibox popup row. struct PopupMatchRowActionButton: View { enum Colors { - static let foregroundColor = Color.cr_blue + static let foregroundColor = Color.chromeBlue static let backgroundColor = Color(red: 0.933, green: 0.933, blue: 0.941) } diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_view.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_view.swift index 9cd0299972f1d8..4a4a1db67d74e6 100644 --- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_view.swift +++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_row_view.swift @@ -68,7 +68,7 @@ struct PopupMatchRowView: View { /// Enable this to tell the row it should display its own custom separator at the bottom. let shouldDisplayCustomSeparator: Bool var customSeparatorColor: Color { - uiVariation == .one ? .cr_separator : .cr_grey700 + uiVariation == .one ? .separator : .grey700 } @ViewBuilder var customSeparator: some View { @@ -93,7 +93,7 @@ struct PopupMatchRowView: View { if isHighlighted { LinearGradient(gradient: Colors.highlightingGradient, startPoint: .top, endPoint: .bottom) } else if self.isPressed { - Color.cr_tableRowViewHighlight + Color.tableRowViewHighlight } button @@ -142,7 +142,7 @@ struct PopupMatchRowView: View { Spacer() if match.isAppendable || match.isTabMatch { PopupMatchTrailingButton(match: match, action: trailingButtonHandler) - .foregroundColor(isHighlighted ? foregroundColorPrimary : .cr_blue) + .foregroundColor(isHighlighted ? foregroundColorPrimary : .chromeBlue) } } .padding(Dimensions.padding) @@ -155,7 +155,7 @@ struct PopupMatchRowView: View { case .one: return Color(toolbarConfiguration.backgroundColor) case .two: - return .cr_groupedSecondaryBackground + return .groupedSecondaryBackground } } diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift index c02e4fca59f6b4..8983d584af88e7 100644 --- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift +++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift @@ -271,7 +271,7 @@ struct PopupView: View { } else if index == 1 { // Spacing and separator below the top (pedal) section is inserted as // a header in the second section. - let separatorColor = (colorScheme == .dark) ? Color.cr_grey700 : Color.cr_grey200 + let separatorColor = (colorScheme == .dark) ? Color.grey700 : Color.grey200 let pedalSectionSeparator = separatorColor .frame(width: geometry.size.width, height: 0.5) @@ -327,7 +327,7 @@ struct PopupView: View { case .one: backgroundColor = Color(toolbarConfiguration.backgroundColor) case .two: - backgroundColor = .cr_groupedPrimaryBackground + backgroundColor = .groupedPrimaryBackground } } else { switch popupUIVariation { diff --git a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/external_defines.swift b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/external_defines.swift index 1becde6076b06e..bf7a70cbd4d0ef 100644 --- a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/external_defines.swift +++ b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/external_defines.swift @@ -24,7 +24,11 @@ public class OmniboxPopupAccessibilityIdentifierHelper { } } +// These constants are needed for the previews project, but named in C++ code, +// so they shouldn't be linted. +// swift-format-ignore: AlwaysUseLowerCamelCase let IDS_IOS_OMNIBOX_POPUP_SWITCH_TO_OPEN_TAB = 1 +// swift-format-ignore: AlwaysUseLowerCamelCase let IDS_IOS_OMNIBOX_POPUP_APPEND = 2 public class L10NUtils { diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/Color+overflow_menu.swift b/ios/chrome/browser/ui/popup_menu/overflow_menu/Color+overflow_menu.swift index bb8cb79ece4d5a..ad5f9d30d98634 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/Color+overflow_menu.swift +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/Color+overflow_menu.swift @@ -5,7 +5,7 @@ import SwiftUI extension Color { - static var overflowMenuSeparatorColor: Color { + static var overflowMenuSeparator: Color { let uiColor = UIColor { traitCollection in let color = traitCollection.userInterfaceStyle == .dark diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_action_row.swift b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_action_row.swift index 061d3209ef8551..63f5012df727a4 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_action_row.swift +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_action_row.swift @@ -29,7 +29,7 @@ struct OverflowMenuActionRow: View { ) .accessibilityIdentifier(action.accessibilityIdentifier) .disabled(!action.enabled || action.enterpriseDisabled) - .accentColor(.cr_textPrimaryColor) - .listRowSeparatorTint(.overflowMenuSeparatorColor) + .accentColor(.textPrimary) + .listRowSeparatorTint(.overflowMenuSeparator) } } diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_destination_view.swift b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_destination_view.swift index 15ad4594b73eb3..2efd5502f305a2 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_destination_view.swift +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_destination_view.swift @@ -72,7 +72,7 @@ struct OverflowMenuDestinationButton: ButtonStyle { /// Background color for the icon. func backgroundColor(configuration: Configuration) -> Color { - return configuration.isPressed ? Color(.systemGray4) : .cr_groupedSecondaryBackground + return configuration.isPressed ? Color(.systemGray4) : .groupedSecondaryBackground } /// View representing the background of the icon. @@ -103,7 +103,7 @@ struct OverflowMenuDestinationButton: ButtonStyle { ) // Pad the color circle by 0.5, otherwise the color shows up faintly // around the border. - .background(Circle().foregroundColor(.cr_blue500).padding(0.5)) + .background(Circle().foregroundColor(.blue500).padding(0.5)) .frame(width: Dimensions.badgeWidth, height: Dimensions.badgeWidth) .offset(x: Dimensions.iconWidth / 2, y: -Dimensions.iconWidth / 2) } diff --git a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_footer_row.swift b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_footer_row.swift index 8c0a496585aecf..7a5014722606d6 100644 --- a/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_footer_row.swift +++ b/ios/chrome/browser/ui/popup_menu/overflow_menu/overflow_menu_footer_row.swift @@ -31,13 +31,13 @@ struct OverflowMenuFooterRow: View { spacing: Dimensions.iconLineSpacing ) { Rectangle() - .foregroundColor(.overflowMenuSeparatorColor) + .foregroundColor(.overflowMenuSeparator) .frame(height: Dimensions.iconLineDividerHeight) footer.image .fixedSize() - .foregroundColor(.cr_grey500) + .foregroundColor(.grey500) Rectangle() - .foregroundColor(.overflowMenuSeparatorColor) + .foregroundColor(.overflowMenuSeparator) .frame(height: Dimensions.iconLineDividerHeight) } .padding([.top], Dimensions.iconLineExtraVerticalSpacing) @@ -46,7 +46,7 @@ struct OverflowMenuFooterRow: View { .font(.footnote) Text(footer.link) .font(.caption2) - .foregroundColor(.cr_blue) + .foregroundColor(.chromeBlue) .onTapGesture(perform: footer.handler) .accessibilityIdentifier(footer.accessibilityIdentifier) } diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.mm b/ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.mm index 79c52ac6f28a75..155054c9419577 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.mm +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.mm @@ -5,9 +5,6 @@ #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h" #import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h" -#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" -#include "ios/chrome/browser/ui/util/ui_util.h" -#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #if !defined(__has_feature) || !__has_feature(objc_arc) diff --git a/ios/chrome/common/ui/colors/Color+Chrome.swift b/ios/chrome/common/ui/colors/Color+Chrome.swift index d80485d45f2fef..cc3634599e0e12 100644 --- a/ios/chrome/common/ui/colors/Color+Chrome.swift +++ b/ios/chrome/common/ui/colors/Color+Chrome.swift @@ -7,77 +7,77 @@ import SwiftUI // Adds easy SwiftUI access to the Chrome color palette. extension Color { /// The background color. - public static var cr_background: Color { + public static var background: Color { return Color(kBackgroundColor) } /// The primary text color. - public static var cr_textPrimaryColor: Color { + public static var textPrimary: Color { return Color(kTextPrimaryColor) } /// The tertiary background color - public static var cr_tertiaryBackgroundColor: Color { + public static var tertiaryBackground: Color { return Color(kTertiaryBackgroundColor) } /// The primary grouped background color. - public static var cr_groupedPrimaryBackground: Color { + public static var groupedPrimaryBackground: Color { return Color(kGroupedPrimaryBackgroundColor) } /// The secondary grouped background color. - public static var cr_groupedSecondaryBackground: Color { + public static var groupedSecondaryBackground: Color { return Color(kGroupedSecondaryBackgroundColor) } /// The primary background color. - public static var cr_primaryBackground: Color { + public static var primaryBackground: Color { return Color(kPrimaryBackgroundColor) } /// The secondary background color. - public static var cr_secondaryBackground: Color { + public static var secondaryBackground: Color { return Color(kSecondaryBackgroundColor) } /// The grey200 color. - public static var cr_grey200: Color { + public static var grey200: Color { return Color(kGrey200Color) } /// The grey300 color. - public static var cr_grey300: Color { + public static var grey300: Color { return Color(kGrey300Color) } /// The grey500 color - public static var cr_grey500: Color { + public static var grey500: Color { return Color(kGrey500Color) } /// The grey700 color - public static var cr_grey700: Color { + public static var grey700: Color { return Color(kGrey700Color) } /// The blue color. - public static var cr_blue: Color { + public static var chromeBlue: Color { return Color(kBlueColor) } /// The blue500 color. - public static var cr_blue500: Color { + public static var blue500: Color { return Color(kBlue500Color) } /// The table row view highlight color. - public static var cr_tableRowViewHighlight: Color { + public static var tableRowViewHighlight: Color { return Color(kTableViewRowHighlightColor) } /// The table view sseparator color. - public static var cr_separator: Color { + public static var separator: Color { return Color(kSeparatorColor) } }