Skip to content

Commit

Permalink
[iOS] Fix remaining ios/ swift-format naming issues
Browse files Browse the repository at this point in the history
Bug: none
Change-Id: I2410753fca6110cb327bd931c6a918b07064ab30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3615971
Reviewed-by: Mark Cogan <[email protected]>
Commit-Queue: Robbie Gibson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#997964}
  • Loading branch information
rkgibson2 authored and Chromium LUCI CQ committed Apr 29, 2022
1 parent caaaa68 commit cb2f550
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 38 deletions.
4 changes: 2 additions & 2 deletions ios/.swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -155,7 +155,7 @@ struct PopupMatchRowView: View {
case .one:
return Color(toolbarConfiguration.backgroundColor)
case .two:
return .cr_groupedSecondaryBackground
return .groupedSecondaryBackground
}
}

Expand Down
4 changes: 2 additions & 2 deletions ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -327,7 +327,7 @@ struct PopupView: View {
case .one:
backgroundColor = Color(toolbarConfiguration.backgroundColor)
case .two:
backgroundColor = .cr_groupedPrimaryBackground
backgroundColor = .groupedPrimaryBackground
}
} else {
switch popupUIVariation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct OverflowMenuActionRow: View {
)
.accessibilityIdentifier(action.accessibilityIdentifier)
.disabled(!action.enabled || action.enterpriseDisabled)
.accentColor(.cr_textPrimaryColor)
.listRowSeparatorTint(.overflowMenuSeparatorColor)
.accentColor(.textPrimary)
.listRowSeparatorTint(.overflowMenuSeparator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions ios/chrome/common/ui/colors/Color+Chrome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit cb2f550

Please sign in to comment.