forked from mozilla-mobile/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mozilla-mobile:main' into main
- Loading branch information
Showing
135 changed files
with
2,499 additions
and
583 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
.github/workflows/firefox-ios-autofill-playwrite-tests.yml
This file contains 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,41 @@ | ||
name: Build and Run Autofill Automation | ||
permissions: read-all | ||
on: | ||
pull_request: | ||
paths: | ||
- 'firefox-ios/Client/Assets/CC_Script/**' | ||
push: | ||
branches: ['main'] | ||
paths: | ||
- 'firefox-ios/Client/Assets/CC_Script/**' | ||
jobs: | ||
build: | ||
runs-on: macos-13 | ||
timeout-minutes: 40 | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
xcode: ["15.2"] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Clone repository | ||
run: | | ||
git clone https://github.com/issammani/test-playwright.git | ||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- run: | | ||
echo "Install dependencies and run tests" | ||
npm i | ||
npm install --save concurrently | ||
npm i -D @playwright/test | ||
cd test-playwright | ||
echo "Install playwright" | ||
npx playwright install | ||
echo "Run tests" | ||
npm test |
This file contains 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 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 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 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 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
84 changes: 84 additions & 0 deletions
84
BrowserKit/Sources/ToolbarKit/BrowserNavigationToolbar.swift
This file contains 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,84 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import UIKit | ||
import Common | ||
|
||
/// Navigation toolbar implementation. | ||
public class BrowserNavigationToolbar: UIView, NavigationToolbar, ThemeApplicable { | ||
private enum UX { | ||
static let horizontalEdgeSpace: CGFloat = 16 | ||
static let buttonSize = CGSize(width: 48, height: 48) | ||
static let borderHeight: CGFloat = 1 | ||
} | ||
|
||
private lazy var actionStack: UIStackView = .build { view in | ||
view.distribution = .equalSpacing | ||
} | ||
private lazy var toolbarBorderView: UIView = .build() | ||
private var toolbarBorderHeightConstraint: NSLayoutConstraint? | ||
private var theme: Theme? | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: .zero) | ||
setupLayout() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public func configure(state: NavigationToolbarState) { | ||
updateActionStack(toolbarElements: state.actions) | ||
|
||
// Update border | ||
toolbarBorderHeightConstraint?.constant = state.shouldDisplayBorder ? UX.borderHeight : 0 | ||
} | ||
|
||
// MARK: - Private | ||
private func setupLayout() { | ||
addSubview(toolbarBorderView) | ||
addSubview(actionStack) | ||
|
||
toolbarBorderHeightConstraint = toolbarBorderView.heightAnchor.constraint(equalToConstant: 0) | ||
toolbarBorderHeightConstraint?.isActive = true | ||
|
||
NSLayoutConstraint.activate([ | ||
toolbarBorderView.leadingAnchor.constraint(equalTo: leadingAnchor), | ||
toolbarBorderView.topAnchor.constraint(equalTo: topAnchor), | ||
toolbarBorderView.trailingAnchor.constraint(equalTo: trailingAnchor), | ||
|
||
actionStack.leadingAnchor.constraint(equalTo: leadingAnchor, constant: UX.horizontalEdgeSpace), | ||
actionStack.topAnchor.constraint(equalTo: toolbarBorderView.bottomAnchor), | ||
actionStack.bottomAnchor.constraint(equalTo: bottomAnchor), | ||
actionStack.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -UX.horizontalEdgeSpace), | ||
]) | ||
} | ||
|
||
private func updateActionStack(toolbarElements: [ToolbarElement]) { | ||
actionStack.removeAllArrangedViews() | ||
toolbarElements.forEach { toolbarElement in | ||
let button = ToolbarButton() | ||
button.configure(element: toolbarElement) | ||
actionStack.addArrangedSubview(button) | ||
|
||
NSLayoutConstraint.activate([ | ||
button.widthAnchor.constraint(equalToConstant: UX.buttonSize.width), | ||
button.heightAnchor.constraint(equalToConstant: UX.buttonSize.height), | ||
]) | ||
|
||
if let theme { | ||
// As we recreate the buttons we need to apply the theme for them to be displayed correctly | ||
button.applyTheme(theme: theme) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - ThemeApplicable | ||
public func applyTheme(theme: Theme) { | ||
backgroundColor = theme.colors.layer1 | ||
toolbarBorderView.backgroundColor = theme.colors.borderPrimary | ||
self.theme = theme | ||
} | ||
} |
This file contains 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
Oops, something went wrong.