[iOS] Make SwiftUI omnibox popup RTL behavior consistent with legacy popup
This CL changes the layout of the SwiftUI omnibox popup so as to ensure
variation one of the UI is consistent with the legacy popup. Broader
modifications are made which also apply to treatment two.
1. Layout direction is forced to LTR on most views of the popup, or set
explicitly to the passed-on environment value for elements such as
trailing button icons.
2. The popup is set to always explicitly align with the omnibox
(including the leading image/favicon and the suggestion title with
the omnibox text field leading edge), even on iPhone. This means the
popup width will be smaller in RTL mode, since the cancel button of
the omnibox is on the left, which is consistent with legacy.
The alignment is done within the row for treatment one, which means
the row will take the whole width but only the content of the row is
aligned with the omnibox. For treatment two, the whole list itself
is aligned with the omnibox.
3. Padding/margin values are updated to achieve consistency with legacy
in treatment one and consistency with mocks in treatment two.
4. GradientTextViews now always align text to the left in treatment one.
5. PopupUIConfiguration published fields will now be properly published,
a `setupPublishedChildren` method is called in the constructor to
ensure these fields notify the object when their value changes.
6. Content shape of trailing buttons is fixed to center them properly.
7. The SwiftUI previews project is updated.
Fixed: 1322080
Change-Id: I8ba3b28c152e2d009c189f41e2aa810af9ffe200
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3634803
Commit-Queue: Quentin Pubert <qpubert@google.com>
Reviewed-by: Mark Cogan <marq@chromium.org>
Reviewed-by: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/main@{#1001508}
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_provider.swift b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_provider.swift
index c9587c1..9842f93 100644
--- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_provider.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_provider.swift
@@ -60,15 +60,33 @@
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
- guard let guide = NamedGuide(name: kOmniboxGuide, view: view) else {
+ let safeAreaGuide = view.safeAreaLayoutGuide
+ guard let omniboxGuide = NamedGuide(name: kOmniboxGuide, view: view),
+ let omniboxLeadingImageGuide = NamedGuide(name: kOmniboxLeadingImageGuide, view: view),
+ let omniboxTextFieldGuide = NamedGuide(name: kOmniboxTextFieldGuide, view: view)
+ else {
return
}
// Calculate the leading and trailing space here in UIKit world so SwiftUI
// gets accurate spacing.
- let frameInView = guide.constrainedView.convert(guide.constrainedView.bounds, to: view)
- uiConfiguration.omniboxLeadingSpace = frameInView.minX
- uiConfiguration.omniboxTrailingSpace = view.bounds.width - frameInView.width - frameInView.minX
+ let omniboxFrameInView = omniboxGuide.constrainedView.convert(
+ omniboxGuide.constrainedView.bounds, to: view)
+ uiConfiguration.omniboxLeadingSpace = omniboxFrameInView.minX
+ uiConfiguration.omniboxTrailingSpace = view.bounds.width - omniboxFrameInView.maxX
+
+ let safeAreaFrame = safeAreaGuide.layoutFrame
+ uiConfiguration.safeAreaTrailingSpace = view.bounds.width - safeAreaFrame.maxX
+
+ let omniboxLeadingImageFrameInView = omniboxLeadingImageGuide.constrainedView.convert(
+ omniboxLeadingImageGuide.constrainedView.bounds, to: view)
+ uiConfiguration.omniboxLeadingImageLeadingSpace =
+ omniboxLeadingImageFrameInView.midX - omniboxFrameInView.minX
+
+ let omniboxTextFieldFrameInView = omniboxTextFieldGuide.constrainedView.convert(
+ omniboxTextFieldGuide.constrainedView.bounds, to: view)
+ uiConfiguration.omniboxTextFieldLeadingSpace =
+ omniboxTextFieldFrameInView.minX - omniboxFrameInView.minX
}
var hasContent: Bool {
diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/gradient_text_view.swift b/ios/chrome/browser/ui/omnibox/popup/shared/gradient_text_view.swift
index 1e6ebcb..58b6e23 100644
--- a/ios/chrome/browser/ui/omnibox/popup/shared/gradient_text_view.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/shared/gradient_text_view.swift
@@ -71,9 +71,11 @@
}
+ @Environment(\.popupUIVariation) var uiVariation: PopupUIVariation
+
var body: some View {
// This is equivalent to left/right since the locale is ignored below.
- let alignment: Alignment = isTextLTR ? .leading : .trailing
+ let variationTwoAlignment: Alignment = isTextLTR ? .leading : .trailing
ZStack {
// Render text at full size inside a fixed-size container.
@@ -99,7 +101,10 @@
// Wrap the text in a container with a fixed frame. The `text` is rendered
// at fixedSize inside of it, therefore this acts as a way to clip it.
let contents = VStack { text }
- .frame(width: geometry.size.width, alignment: alignment)
+ .frame(
+ width: geometry.size.width,
+ alignment: uiVariation == .one ? .leading : variationTwoAlignment
+ )
// Force LTR layout direction to prevent incorrect behavior in RTL locales.
// The goal is to deal with the text language, not the user's locale.
.environment(\.layoutDirection, .leftToRight)
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 de2902b..d02ac5ae 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
@@ -17,18 +17,26 @@
enum Dimensions {
static let actionButtonOffset = CGSize(width: -5, height: 0)
static let actionButtonOuterPadding = EdgeInsets(top: 2, leading: 0, bottom: 2, trailing: 0)
- static let leadingSpacing: CGFloat = 60
static let minHeight: CGFloat = 58
- static let padding = EdgeInsets(top: 9, leading: 0, bottom: 9, trailing: 16)
+
+ enum VariationOne {
+ static let padding = EdgeInsets(top: 9, leading: 0, bottom: 9, trailing: 0)
+ }
+
+ enum VariationTwo {
+ static let padding = EdgeInsets(top: 9, leading: 0, bottom: 9, trailing: 10)
+ }
}
@Environment(\.popupUIVariation) var uiVariation: PopupUIVariation
+ @Environment(\.horizontalSizeClass) var sizeClass
let match: PopupMatch
let isHighlighted: Bool
let toolbarConfiguration: ToolbarConfiguration
let selectionHandler: () -> Void
let trailingButtonHandler: () -> Void
+ let uiConfiguration: PopupUIConfiguration
@State var isPressed = false
@State var childView = CGSize.zero
@@ -71,8 +79,30 @@
@ViewBuilder
var customSeparator: some View {
HStack(spacing: 0) {
- Spacer().frame(width: Dimensions.leadingSpacing)
+ Spacer().frame(width: uiConfiguration.omniboxTextFieldLeadingSpace + omniboxLeadingSpace)
customSeparatorColor.frame(height: 0.5)
+ }.environment(\.layoutDirection, .leftToRight)
+ }
+
+ @Environment(\.layoutDirection) var layoutDirection: LayoutDirection
+
+ /// Leading spacing before the content of the row, within the row.
+ var omniboxLeadingSpace: CGFloat {
+ switch uiVariation {
+ case .one:
+ return uiConfiguration.omniboxLeadingSpace
+ case .two:
+ return 0
+ }
+ }
+
+ /// Traling spacing after the content of the row, within the row.
+ var omniboxTrailingSpace: CGFloat {
+ switch uiVariation {
+ case .one:
+ return uiConfiguration.safeAreaTrailingSpace + kExpandedLocationBarLeadingMarginRefreshedPopup
+ case .two:
+ return 0
}
}
@@ -100,8 +130,11 @@
// The content is in front of the button, for proper hit testing.
HStack(alignment: .center, spacing: 0) {
+ Color.clear.frame(width: omniboxLeadingSpace)
HStack(alignment: .center, spacing: 0) {
- Spacer()
+ Color.clear.frame(
+ width: uiConfiguration.omniboxLeadingImageLeadingSpace
+ - PopupMatchImageView.Dimension.image / 2)
match.image
.map { image in
PopupMatchImageView(
@@ -111,7 +144,7 @@
.clipShape(RoundedRectangle(cornerRadius: 7, style: .continuous))
}
Spacer()
- }.frame(width: Dimensions.leadingSpacing)
+ }.frame(width: uiConfiguration.omniboxTextFieldLeadingSpace)
VStack(alignment: .leading, spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
GradientTextView(match.text, highlightColor: highlightColor)
@@ -138,13 +171,18 @@
}
.allowsHitTesting(false)
}
- Spacer()
+ Spacer(minLength: 0)
if match.isAppendable || match.isTabMatch {
PopupMatchTrailingButton(match: match, action: trailingButtonHandler)
.foregroundColor(isHighlighted ? foregroundColorPrimary : .chromeBlue)
+ .environment(\.layoutDirection, layoutDirection)
}
+ Color.clear.frame(width: omniboxTrailingSpace)
}
- .padding(Dimensions.padding)
+ .padding(
+ uiVariation == .one ? Dimensions.VariationOne.padding : Dimensions.VariationTwo.padding
+ )
+ .environment(\.layoutDirection, .leftToRight)
}
.frame(maxWidth: .infinity, minHeight: Dimensions.minHeight)
}
diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_trailing_button.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_trailing_button.swift
index 3f4518b..2915c96 100644
--- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_trailing_button.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_match_trailing_button.swift
@@ -8,13 +8,15 @@
struct PopupMatchTrailingButton: View {
enum Dimensions {
static let extendedTouchTargetDiameter: CGFloat = 44
- static let trailingButtonSize: CGFloat = 17
+ static let trailingButtonIconSize: CGFloat = 17
+ static let trailingButtonSize: CGFloat = 24
}
let match: PopupMatch
let action: () -> Void
@Environment(\.popupUIVariation) var uiVariation: PopupUIVariation
+ @Environment(\.layoutDirection) var layoutDirection: LayoutDirection
@ViewBuilder
var image: some View {
@@ -27,9 +29,10 @@
.renderingMode(.template)
.flipsForRightToLeftLayoutDirection(true)
} else {
- let uiImage = NativeReversableImage(IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND, true)
+ let uiImage = NativeImage(IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND)
Image(uiImage: uiImage!)
.renderingMode(.template)
+ .flipsForRightToLeftLayoutDirection(true)
}
case .two:
Image(systemName: match.isTabMatch ? "arrow.right.circle" : "arrow.up.backward")
@@ -40,7 +43,10 @@
var body: some View {
Button(action: action) {
image
- .font(.system(size: Dimensions.trailingButtonSize, weight: .medium))
+ // Make the image know about the environment layout direction as we
+ // override it on the body as a whole.
+ .environment(\.layoutDirection, layoutDirection)
+ .font(.system(size: Dimensions.trailingButtonIconSize, weight: .medium))
.aspectRatio(contentMode: .fit)
.frame(
width: Dimensions.trailingButtonSize, height: Dimensions.trailingButtonSize,
@@ -49,7 +55,11 @@
.contentShape(
Circle().size(
width: Dimensions.extendedTouchTargetDiameter,
- height: Dimensions.extendedTouchTargetDiameter)
+ height: Dimensions.extendedTouchTargetDiameter
+ )
+ .offset(
+ x: (Dimensions.trailingButtonSize - Dimensions.extendedTouchTargetDiameter) / 2,
+ y: (Dimensions.trailingButtonSize - Dimensions.extendedTouchTargetDiameter) / 2)
)
}
.buttonStyle(.plain)
@@ -59,6 +69,8 @@
.accessibilityIdentifier(
match.isTabMatch
? kOmniboxPopupRowSwitchTabAccessibilityIdentifier
- : kOmniboxPopupRowAppendAccessibilityIdentifier)
+ : kOmniboxPopupRowAppendAccessibilityIdentifier
+ )
+ .environment(\.layoutDirection, .leftToRight)
}
}
diff --git a/ios/chrome/browser/ui/omnibox/popup/shared/popup_ui_configuration.swift b/ios/chrome/browser/ui/omnibox/popup/shared/popup_ui_configuration.swift
index b72ac9e..6135a037 100644
--- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_ui_configuration.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_ui_configuration.swift
@@ -2,10 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import Combine
+
+protocol PublishedWrapper {
+ var objectWillChange: ObservableObjectPublisher? { get set }
+}
+
/// An extension of `@Published` that only publishes a new value when there
/// is an actual change.
/// TODO(crbug.com/1315110): See if this should be moved to a shared location.
-@propertyWrapper class PublishedOnChange<Value: Equatable> {
+@propertyWrapper class PublishedOnChange<Value: Equatable>: PublishedWrapper {
+ weak var objectWillChange: ObservableObjectPublisher? = nil
@Published private var value: Value
public var projectedValue: Published<Value>.Publisher {
@@ -25,6 +32,7 @@
return
}
value = newValue
+ objectWillChange?.send()
}
}
init(wrappedValue value: Value) {
@@ -46,11 +54,40 @@
/// the edge of the popup view.
@PublishedOnChange var omniboxTrailingSpace: CGFloat = 0
+ /// Holds how much trailing space there is from where the safe area ends to
+ /// the edge of the popup view.
+ @PublishedOnChange var safeAreaTrailingSpace: CGFloat = 0
+
+ /// Holds how much leading space there is from where the omnibox starts to the center
+ /// of the leading image.
+ @PublishedOnChange var omniboxLeadingImageLeadingSpace: CGFloat = 0
+
+ /// Holds how much trailing space there is from where the omnibox starts to
+ /// where the text field starts.
+ @PublishedOnChange var omniboxTextFieldLeadingSpace: CGFloat = 0
+
/// The current toolbar configuration, used to color items that should match
/// the toolbar's color.
let toolbarConfiguration: ToolbarConfiguration
public init(toolbarConfiguration: ToolbarConfiguration) {
self.toolbarConfiguration = toolbarConfiguration
+
+ super.init()
+ setupPublishedChildren()
+ }
+
+ /// This function ensures all `@PublishedOnChange` fields are "observed" as
+ /// part of this observable object. This would be done automatically for
+ /// `@Published` fields, but this is needed for this custom wrapper, or views
+ /// which observe this model will not always be notified when the values
+ /// of its fields change.
+ func setupPublishedChildren() {
+ let mirror = Mirror(reflecting: self)
+ mirror.children.forEach { child in
+ if var observedProperty = child.value as? PublishedWrapper {
+ observedProperty.objectWillChange = self.objectWillChange
+ }
+ }
}
}
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 4b51234c..2121576 100644
--- a/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/shared/popup_view.swift
@@ -68,7 +68,8 @@
// Default list row insets. These are removed to inset the popup to the
// width of the omnibox.
- static let defaultInset: CGFloat = 16
+ static let defaultInsetWhenSelfSizing: CGFloat = 16
+ static let defaultInset: CGFloat = 20
static let selfSizingListBottomMargin: CGFloat = 16
}
@@ -188,6 +189,7 @@
model, didTapTrailingButtonForRow: UInt(matchIndex),
inSection: UInt(sectionIndex))
},
+ uiConfiguration: uiConfiguration,
shouldDisplayCustomSeparator: shouldDisplayCustomSeparator
)
.id(indexPath)
@@ -196,7 +198,9 @@
.listRowBackground(Color.clear)
.accessibilityElement(children: .combine)
.accessibilityIdentifier(
- OmniboxPopupAccessibilityIdentifierHelper.accessibilityIdentifierForRow(at: indexPath))
+ OmniboxPopupAccessibilityIdentifierHelper.accessibilityIdentifierForRow(at: indexPath)
+ )
+ .environment(\.layoutDirection, layoutDirection)
}
.onDelete { indexSet in
for matchIndex in indexSet {
@@ -243,46 +247,48 @@
.concat(ScrollOnChangeModifier(value: $model.sections, action: onNewSections))
.concat(ListStyleModifier())
.concat(EnvironmentValueModifier(\.defaultMinListHeaderHeight, 0))
+ .concat(omniboxPaddingModifier)
GeometryReader { geometry in
- if shouldSelfSize {
- let selfSizingListModifier =
- commonListModifier
- .concat(omniboxPaddingModifier)
- ZStack(alignment: .top) {
- listBackground.frame(height: selfSizingListHeight)
- SelfSizingList(
- bottomMargin: selfSizingListBottomMargin,
- listModifier: selfSizingListModifier,
- content: {
- listContent(geometry: geometry)
- },
- emptySpace: {
- PopupEmptySpaceView()
+ ZStack(alignment: .top) {
+ listBackground.frame(height: selfSizingListHeight)
+ if shouldSelfSize {
+ ZStack(alignment: .top) {
+ SelfSizingList(
+ bottomMargin: selfSizingListBottomMargin,
+ listModifier: commonListModifier,
+ content: {
+ listContent(geometry: geometry)
+ },
+ emptySpace: {
+ PopupEmptySpaceView()
+ }
+ )
+ .frame(width: geometry.size.width, height: geometry.size.height)
+ .onPreferenceChange(SelfSizingListHeightPreferenceKey.self) { height in
+ selfSizingListHeight = height
}
- )
- .frame(width: geometry.size.width, height: geometry.size.height)
- .onPreferenceChange(SelfSizingListHeightPreferenceKey.self) { height in
- selfSizingListHeight = height
+ bottomSeparator.offset(x: 0, y: selfSizingListHeight ?? 0)
}
+ } else {
+ List {
+ listContent(geometry: geometry)
+ }
+ // This fixes list section header internal representation from overlapping safe areas.
+ .padding([.leading, .trailing], 0.2)
+ .modifier(commonListModifier)
+ .ignoresSafeArea(.keyboard)
+ .ignoresSafeArea(.container, edges: [.leading, .trailing])
+ .frame(width: geometry.size.width, height: geometry.size.height)
}
- bottomSeparator.offset(x: 0, y: selfSizingListHeight ?? 0)
- } else {
- List {
- listContent(geometry: geometry)
- }
- // This fixes list section header internal representation from overlapping safe areas.
- .padding([.leading, .trailing], 0.2)
- .background(listBackground)
- .modifier(commonListModifier)
- .ignoresSafeArea(.keyboard)
- .frame(width: geometry.size.width, height: geometry.size.height)
}
}
}
var body: some View {
- listView.onAppear(perform: onAppear)
+ listView
+ .onAppear(perform: onAppear)
+ .environment(\.layoutDirection, .leftToRight)
}
@ViewBuilder
@@ -328,23 +334,38 @@
}
}
+ @Environment(\.layoutDirection) var layoutDirection: LayoutDirection
+
/// Returns a `ViewModifier` to correctly space the sides of the list based
/// on the current omnibox spacing
var omniboxPaddingModifier: some ViewModifier {
let leadingSpace: CGFloat
let trailingSpace: CGFloat
- if sizeClass == .compact {
+ let leadingHorizontalMargin: CGFloat
+ let trailingHorizontalMargin: CGFloat
+ switch popupUIVariation {
+ case .one:
leadingSpace = 0
trailingSpace = 0
- } else {
- leadingSpace = uiConfiguration.omniboxLeadingSpace
- trailingSpace = uiConfiguration.omniboxTrailingSpace
+ leadingHorizontalMargin = 0
+ trailingHorizontalMargin = 0
+ case .two:
+ leadingSpace =
+ uiConfiguration.omniboxLeadingSpace
+ - (shouldSelfSize
+ ? Dimensions.VariationTwo.defaultInsetWhenSelfSizing
+ : Dimensions.VariationTwo.defaultInset)
+ trailingSpace =
+ (shouldSelfSize && sizeClass != .compact
+ ? uiConfiguration.omniboxTrailingSpace : uiConfiguration.safeAreaTrailingSpace)
+ - (shouldSelfSize
+ ? Dimensions.VariationTwo.defaultInsetWhenSelfSizing
+ : Dimensions.VariationTwo.defaultInset)
+ leadingHorizontalMargin = 0
+ trailingHorizontalMargin = sizeClass == .compact ? kContractedLocationBarHorizontalMargin : 0
}
- let inset: CGFloat =
- (popupUIVariation == .one || sizeClass == .compact)
- ? 0 : -Dimensions.VariationTwo.defaultInset
- return PaddingModifier([.leading], leadingSpace + inset).concat(
- PaddingModifier([.trailing], trailingSpace + inset))
+ return PaddingModifier([.leading], leadingSpace + leadingHorizontalMargin).concat(
+ PaddingModifier([.trailing], trailingSpace + trailingHorizontalMargin))
}
var listBackground: some View {
diff --git a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup.xcodeproj/project.pbxproj b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup.xcodeproj/project.pbxproj
index 2f80b33..8216388 100644
--- a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup.xcodeproj/project.pbxproj
+++ b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
59CD2EFC27F5F58900D75B26 /* external_defines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CD2EFB27F5F58900D75B26 /* external_defines.swift */; };
59CE0D1E280473F900302248 /* omnibox_text.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CE0D1D280473F900302248 /* omnibox_text.swift */; };
8701451C27D24A8800C2D66F /* pressed_preference_key_button_style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8701451B27D24A8800C2D66F /* pressed_preference_key_button_style.swift */; };
+ 8726E4BD282941860057AE77 /* toolbar_constants.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8726E4BC282941860057AE77 /* toolbar_constants.mm */; };
87338E4B28217A55009434D1 /* popup_ui_configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87338E4A28217A55009434D1 /* popup_ui_configuration.swift */; };
87338E52282184C2009434D1 /* toolbar_configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 87338E51282184C2009434D1 /* toolbar_configuration.mm */; };
87338E5528218540009434D1 /* ntp_home_constant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 87338E5328218540009434D1 /* ntp_home_constant.mm */; };
@@ -110,6 +111,8 @@
59CD2EFB27F5F58900D75B26 /* external_defines.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = external_defines.swift; sourceTree = "<group>"; };
59CE0D1D280473F900302248 /* omnibox_text.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = omnibox_text.swift; path = ../../shared/omnibox_text.swift; sourceTree = "<group>"; };
8701451B27D24A8800C2D66F /* pressed_preference_key_button_style.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = pressed_preference_key_button_style.swift; path = ../../shared/pressed_preference_key_button_style.swift; sourceTree = "<group>"; };
+ 8726E4BB282940F20057AE77 /* toolbar_constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = toolbar_constants.h; path = ../../../../toolbar/public/toolbar_constants.h; sourceTree = "<group>"; };
+ 8726E4BC282941860057AE77 /* toolbar_constants.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = toolbar_constants.mm; path = ../../../../toolbar/public/toolbar_constants.mm; sourceTree = "<group>"; };
87338E48282178B6009434D1 /* toolbar_configuration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = toolbar_configuration.h; path = ../../../../toolbar/buttons/toolbar_configuration.h; sourceTree = "<group>"; };
87338E4928217914009434D1 /* toolbar_style.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = toolbar_style.h; path = ../../../../toolbar/buttons/toolbar_style.h; sourceTree = "<group>"; };
87338E4A28217A55009434D1 /* popup_ui_configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = popup_ui_configuration.swift; path = ../../shared/popup_ui_configuration.swift; sourceTree = "<group>"; };
@@ -210,6 +213,8 @@
879F659C27CD2BDC005B650F /* popup_match_row_action_button.swift */,
876011EA27D287A6004EB60B /* popup_match_trailing_button.swift */,
59C4A9BD27BFF04F0080C045 /* popup_match.swift */,
+ 8726E4BB282940F20057AE77 /* toolbar_constants.h */,
+ 8726E4BC282941860057AE77 /* toolbar_constants.mm */,
59C4A9BE27BFF04F0080C045 /* popup_model.swift */,
59C4A9BC27BFF04F0080C045 /* popup_view.swift */,
87338E5428218540009434D1 /* ntp_home_constant.h */,
@@ -479,6 +484,7 @@
93B3BBBA27B1C3900034ADF1 /* view_controller.swift in Sources */,
93BCA07127D2D4C300CE8602 /* fake_omnibox_icon.swift in Sources */,
59C4A9C227BFF04F0080C045 /* popup_match.swift in Sources */,
+ 8726E4BD282941860057AE77 /* toolbar_constants.mm in Sources */,
59CD2EFC27F5F58900D75B26 /* external_defines.swift in Sources */,
8781A7EC27DFF6950054D0B9 /* popup_empty_space_view.swift in Sources */,
9329C16027D26FE30032C244 /* crurl.swift in Sources */,
diff --git a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/Base.lproj/Main.storyboard b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/Base.lproj/Main.storyboard
index cd0432a..5ab924f 100644
--- a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/Base.lproj/Main.storyboard
+++ b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/Base.lproj/Main.storyboard
@@ -11,7 +11,7 @@
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
- <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="OmniboxPopup" customModuleProvider="target" sceneMemberID="viewController">
+ <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="omnibox_popup" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
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 9b243cb1..d45b2cc0 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
@@ -49,11 +49,11 @@
}
}
-public func NativeReversableImage(_ imageID: Int, _ reversable: Bool) -> UIImage? {
+public func NativeImage(_ imageID: Int) -> UIImage? {
switch imageID {
case IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND:
let uiImage = UIImage(named: "IDR_IOS_OMNIBOX_KEYBOARD_VIEW_APPEND")
- return uiImage!.imageFlippedForRightToLeftLayoutDirection()
+ return uiImage
default:
fatalError("This image ID is not available in the previews project")
}
diff --git a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/omnibox_popup-Bridging-Header.h b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/omnibox_popup-Bridging-Header.h
index 2b35680..b5e326a6 100644
--- a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/omnibox_popup-Bridging-Header.h
+++ b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/omnibox_popup-Bridging-Header.h
@@ -16,6 +16,7 @@
#import "omnibox_suggestion_commands.h"
#import "popup_mediator.h"
#import "toolbar_configuration.h"
+#import "toolbar_constants.h"
#import "toolbar_style.h"
#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_SWIFTUI_PREVIEWS_OMNIBOX_POPUP_OMNIBOX_POPUP_BRIDGING_HEADER_H_
diff --git a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/popup_coordinator.swift b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/popup_coordinator.swift
index d753485a..6d1965d 100644
--- a/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/popup_coordinator.swift
+++ b/ios/chrome/browser/ui/omnibox/popup/swiftui_previews/omnibox_popup/popup_coordinator.swift
@@ -31,11 +31,18 @@
let mediator = PopupMediator()
self.mediator = mediator
+ let uiConfiguration = PopupUIConfiguration(
+ toolbarConfiguration: ToolbarConfiguration(style: .NORMAL))
+ uiConfiguration.omniboxLeadingSpace = 10
+ uiConfiguration.omniboxTrailingSpace = 100
+ uiConfiguration.safeAreaTrailingSpace = 10
+ uiConfiguration.omniboxLeadingImageLeadingSpace = 22
+ uiConfiguration.omniboxTextFieldLeadingSpace = 51
+
let viewController = UIHostingController(
rootView: PopupView(
model: mediator.model,
- uiConfiguration: PopupUIConfiguration(
- toolbarConfiguration: ToolbarConfiguration(style: .NORMAL))
+ uiConfiguration: uiConfiguration
).environment(\.popupUIVariation, .one))
self.viewController = viewController
viewController.view.translatesAutoresizingMaskIntoConstraints = false
diff --git a/ios/chrome/browser/ui/util/uikit_ui_util.h b/ios/chrome/browser/ui/util/uikit_ui_util.h
index 2e96ff2..40c6ab8a 100644
--- a/ios/chrome/browser/ui/util/uikit_ui_util.h
+++ b/ios/chrome/browser/ui/util/uikit_ui_util.h
@@ -94,13 +94,13 @@
// |imageID|. If |reversable| is YES and RTL layout is in use, the image
// will be flipped for RTL.
UIImage* NativeReversableImage(int imageID, BOOL reversable);
-#ifdef __cplusplus
-}
-#endif // __cplusplus
// Convenience version of NativeReversableImage for images that are never
// reversable; equivalent to NativeReversableImage(imageID, NO).
UIImage* NativeImage(int imageID);
+#ifdef __cplusplus
+}
+#endif // __cplusplus
// Returns an output image where each pixel has RGB values equal to a color and
// the alpha value sampled from the given image. The RGB values of the image are