Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI

import struct MozillaAppServices.CreditCard

struct CreditCardInputView: View {
struct CreditCardInputView: ThemeableView {
private struct UX {
static let cornerRadius: CGFloat = 24
static let blurRadius: CGFloat = 10
Expand All @@ -24,25 +24,24 @@ struct CreditCardInputView: View {

// Theming
let windowUUID: WindowUUID
@Environment(\.themeManager)
var themeManager
@State var backgroundColor: Color = .clear
@State var borderColor: Color = .clear
@State var textFieldBackgroundColor: Color = .clear
@State var barButtonColor: Color = .clear
@State var saveButtonDisabledColor: Color = .clear
var themeManager: ThemeManager
@State var theme: Theme

init(
viewModel: CreditCardInputViewModel,
windowUUID: WindowUUID,
themeManager: ThemeManager
) {
self.viewModel = viewModel
self.windowUUID = windowUUID
self.themeManager = themeManager
self.theme = themeManager.getCurrentTheme(for: windowUUID)
}

var body: some View {
NavigationView {
main
.blur(radius: isBlurred ? UX.blurRadius : 0)
.onAppear {
applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID))
}
.onReceive(NotificationCenter.default.publisher(for: .ThemeDidChange)) { notification in
guard let uuid = notification.windowUUID, uuid == windowUUID else { return }
applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID))
}
.onReceive(NotificationCenter.default.publisher(
for: UIApplication.willResignActiveNotification)
) { _ in
Expand All @@ -54,27 +53,28 @@ struct CreditCardInputView: View {
isBlurred = false
}
}
.listenToThemeChanges(theme: $theme, manager: themeManager, windowUUID: windowUUID)
}

private var main: some View {
return ZStack {
backgroundColor.ignoresSafeArea()
Color(theme.colors.layer1).ignoresSafeArea()
form
.navigationBarTitle(viewModel.state.title,
displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
rightBarButton()
.disabled(!viewModel.isRightBarButtonEnabled)
.foregroundColor(barButtonColor)
.foregroundColor(Color(theme.colors.actionPrimary))
}
ToolbarItem(placement: .navigationBarLeading) {
leftBarButton()
.foregroundColor(barButtonColor)
.foregroundColor(Color(theme.colors.actionPrimary))
}
}
.padding(.top, 0)
.background(backgroundColor.edgesIgnoringSafeArea(.bottom))
.background(Color(theme.colors.layer1).edgesIgnoringSafeArea(.bottom))
}
}

Expand All @@ -83,21 +83,21 @@ struct CreditCardInputView: View {
if #unavailable(iOS 26.0) {
Divider()
.frame(height: UX.dividerHeight)
.foregroundColor(borderColor)
.foregroundColor(.clear)
}

name
.background(textFieldBackgroundColor)
.background(Color(theme.colors.layer2))
.modifier(NewStyleRoundedCorners(topLeadingCorner: UX.cornerRadius,
topTrailingCorner: UX.cornerRadius,
bottomLeadingCorner: nil,
bottomTrailingCorner: nil))

number
.background(textFieldBackgroundColor)
.background(Color(theme.colors.layer2))

expiration
.background(textFieldBackgroundColor)
.background(Color(theme.colors.layer2))
.modifier(NewStyleRoundedCorners(topLeadingCorner: nil,
topTrailingCorner: nil,
bottomLeadingCorner: UX.cornerRadius,
Expand Down Expand Up @@ -127,7 +127,7 @@ struct CreditCardInputView: View {

Divider()
.frame(height: UX.dividerHeight)
.foregroundColor(borderColor)
.foregroundColor(.clear)
.padding(.top, UX.dividerPaddingTop)
}
}
Expand All @@ -142,7 +142,7 @@ struct CreditCardInputView: View {

Divider()
.frame(height: UX.dividerHeight)
.foregroundColor(borderColor)
.foregroundColor(.clear)
.padding(.top, UX.dividerPaddingTop)
}
}
Expand All @@ -158,20 +158,12 @@ struct CreditCardInputView: View {
if #unavailable(iOS 26.0) {
Divider()
.frame(height: UX.dividerHeight)
.foregroundColor(borderColor)
.foregroundColor(.clear)
.padding(.top, UX.dividerPaddingTop)
}
}
}

func applyTheme(theme: Theme) {
let color = theme.colors
backgroundColor = Color(color.layer1)
textFieldBackgroundColor = Color(color.layer2)
barButtonColor = Color(color.actionPrimary)
saveButtonDisabledColor = Color(color.textSecondary)
}

func rightBarButton() -> some View {
let btnState = viewModel.state.rightBarBtn
return Button(btnState.title) {
Expand Down Expand Up @@ -210,7 +202,13 @@ struct CreditCardInputView: View {
}
}
}
.foregroundColor(viewModel.isRightBarButtonEnabled ? barButtonColor : saveButtonDisabledColor)
.modifier(
CreditCardViewButtonStyle(
isEnabled: viewModel.isRightBarButtonEnabled,
theme: theme,
buttonState: btnState
)
)
.onDisappear {
viewModel.isRightBarButtonEnabled = false
}
Expand Down Expand Up @@ -250,6 +248,10 @@ struct CreditCardEditView_Previews: PreviewProvider {
creditCard: sampleCreditCard,
state: .view)

return CreditCardInputView(viewModel: viewModel, windowUUID: .XCTestDefaultUUID)
return CreditCardInputView(
viewModel: viewModel,
windowUUID: .XCTestDefaultUUID,
themeManager: DefaultThemeManager(sharedContainerIdentifier: "")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ class CreditCardSettingsViewController: SensitiveViewController, UIAdaptivePrese
viewModel.cardInputViewModel.creditCard = creditCard
}
viewModel.cardInputViewModel.updateState(state: editState)
creditCardEditView = CreditCardInputView(viewModel: viewModel.cardInputViewModel, windowUUID: windowUUID)
creditCardEditView = CreditCardInputView(
viewModel: viewModel.cardInputViewModel,
windowUUID: windowUUID,
themeManager: themeManager
)
viewModel.cardInputViewModel.dismiss = { [weak self] status, successVal in
DispatchQueue.main.async {
if successVal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,28 @@ final class BookmarksViewController: SiteTableViewController,
switch state {
case .bookmarks(state: .mainView), .bookmarks(state: .inFolder):
bottomRightButton.title = .BookmarksEdit
if #available(iOS 26.0, *) {
bottomRightButton.tintColor = currentTheme().colors.textPrimary
}
return [flexibleSpace, bottomRightButton]
case .bookmarks(state: .inFolderEditMode):
bottomRightButton.title = String.AppSettingsDone
if #available(iOS 26.0, *) {
bottomRightButton.tintColor = currentTheme().colors.textAccent
}
return [bottomLeftButton, flexibleSpace, bottomRightButton]
case .bookmarks(state: .itemEditMode):
bottomRightButton.title = String.AppSettingsDone
if #available(iOS 26.0, *) {
bottomRightButton.tintColor = currentTheme().colors.textAccent
}
bottomRightButton.isEnabled = true
return [flexibleSpace, bottomRightButton]
case .bookmarks(state: .itemEditModeInvalidField):
bottomRightButton.title = String.AppSettingsDone
if #available(iOS 26.0, *) {
bottomRightButton.tintColor = currentTheme().colors.textAccent
}
bottomRightButton.isEnabled = false
return [flexibleSpace, bottomRightButton]
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EditBookmarkViewController: UIViewController,
private lazy var saveBarButton: UIBarButtonItem = {
let button = UIBarButtonItem(
title: String.Bookmarks.Menu.EditBookmarkSave,
style: .done,
style: .plain,
target: self,
action: #selector(saveButtonAction)
)
Expand Down Expand Up @@ -180,6 +180,9 @@ class EditBookmarkViewController: UIViewController,
navigationController?.navigationBar.tintColor = theme.colors.actionPrimary
view.backgroundColor = theme.colors.layer1
tableView.backgroundColor = theme.colors.layer1
if #available(iOS 26.0, *) {
saveBarButton.tintColor = theme.colors.textAccent
}
}

// MARK: - Configure Table View Cells
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EditFolderViewController: UIViewController,
private lazy var saveBarButton: UIBarButtonItem = {
let button = UIBarButtonItem(
title: String.Bookmarks.Menu.EditBookmarkSave,
style: .done,
style: .plain,
target: self,
action: #selector(saveButtonAction)
)
Expand Down Expand Up @@ -158,6 +158,9 @@ class EditFolderViewController: UIViewController,
navigationController?.navigationBar.tintColor = theme.colors.actionPrimary
view.backgroundColor = theme.colors.layer1
tableView.backgroundColor = theme.colors.layer1
if #available(iOS 26.0, *) {
saveBarButton.tintColor = theme.colors.textAccent
}
}

// MARK: - UITableViewDataSource & UITableViewDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LibraryViewController: UIViewController, Themeable {
private lazy var topRightButton: UIBarButtonItem = {
let button = UIBarButtonItem(
title: String.AppSettingsDone,
style: .done,
style: .plain,
target: self,
action: #selector(topRightButtonAction)
)
Expand Down Expand Up @@ -301,14 +301,23 @@ class LibraryViewController: UIViewController, Themeable {
navigationItem.rightBarButtonItem = nil
case .bookmarks(state: .itemEditMode):
topRightButton.title = .SettingsAddCustomEngineSaveButtonText
if #available(iOS 26.0, *) {
topRightButton.tintColor = currentTheme().colors.textAccent
}
navigationItem.rightBarButtonItem = topRightButton
navigationItem.rightBarButtonItem?.isEnabled = true
case .bookmarks(state: .itemEditModeInvalidField):
topRightButton.title = .SettingsAddCustomEngineSaveButtonText
if #available(iOS 26.0, *) {
topRightButton.tintColor = currentTheme().colors.textAccent
}
navigationItem.rightBarButtonItem = topRightButton
navigationItem.rightBarButtonItem?.isEnabled = false
default:
topRightButton.title = String.AppSettingsDone
if #available(iOS 26.0, *) {
topRightButton.tintColor = currentTheme().colors.textPrimary
}
navigationItem.rightBarButtonItem = topRightButton
navigationItem.rightBarButtonItem?.isEnabled = true
}
Expand Down Expand Up @@ -363,7 +372,7 @@ class LibraryViewController: UIViewController, Themeable {
}

private func setupToolBarAppearance() {
let theme = themeManager.getCurrentTheme(for: windowUUID)
let theme = currentTheme()
let standardAppearance = UIToolbarAppearance()
standardAppearance.configureWithDefaultBackground()
standardAppearance.backgroundColor = theme.colors.layer1
Expand Down Expand Up @@ -392,14 +401,18 @@ class LibraryViewController: UIViewController, Themeable {
}
}

private func currentTheme() -> Theme {
return themeManager.getCurrentTheme(for: windowUUID)
}

func applyTheme() {
// There is an ANNOYING bar in the nav bar above the segment control. These are the
// UIBarBackgroundShadowViews. We must set them to be clear images in order to
// have a seamless nav bar, if embedding the segmented control.
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()

let theme = themeManager.getCurrentTheme(for: windowUUID)
let theme = currentTheme()
view.backgroundColor = theme.colors.layer1
navigationController?.navigationBar.barTintColor = theme.colors.layer1
navigationController?.navigationBar.tintColor = theme.colors.actionPrimary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ extension OnboardingCardDelegate where Self: OnboardingViewControllerProtocol,
windowUUID: windowUUID)
let buttonItem = UIBarButtonItem(
title: .SettingsSearchDoneButton,
style: .done,
style: .plain,
target: self,
action: selector)
if #available(iOS 26.0, *) {
buttonItem.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.textPrimary
}
singInSyncVC.navigationItem.rightBarButtonItem = buttonItem
(singInSyncVC as? FirefoxAccountSignInViewController)?.qrCodeNavigationHandler = qrCodeNavigationHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ final class OnboardingService: FeatureFlaggable {
style: .plain,
target: self,
action: #selector(dismissSelector))
buttonItem.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.actionPrimary
if #available(iOS 26.0, *) {
buttonItem.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.textPrimary
} else {
buttonItem.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.actionPrimary
}
singInSyncVC.navigationItem.rightBarButtonItem = buttonItem
(singInSyncVC as? FirefoxAccountSignInViewController)?.qrCodeNavigationHandler = qrCodeNavigationHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class PrivacyPolicyViewController: UIViewController, Themeable {
// MARK: - Theming
func applyTheme() {
let theme = themeManager.getCurrentTheme(for: windowUUID)
navigationItem.rightBarButtonItem?.tintColor = theme.colors.actionPrimary
if #available(iOS 26.0, *) {
navigationItem.rightBarButtonItem?.tintColor = theme.colors.textPrimary
} else {
navigationItem.rightBarButtonItem?.tintColor = theme.colors.actionPrimary
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ final class PrivacyPreferencesViewController: UIViewController,
}

titleLabel.textColor = theme.colors.textPrimary
doneButton.setTitleColor(theme.colors.textAccent, for: .normal)
if #available(iOS 26.0, *) {
doneButton.setTitleColor(theme.colors.textPrimary, for: .normal)
} else {
doneButton.setTitleColor(theme.colors.textAccent, for: .normal)
}
crashReportsSwitch.applyTheme(theme: theme)
technicalDataSwitch.applyTheme(theme: theme)
setupContentViews()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ class AddCredentialViewController: UIViewController, Themeable {
fileprivate lazy var saveButton: UIBarButtonItem = {
let button = UIBarButtonItem(
title: .SettingsAddCustomEngineSaveButtonText,
style: .done,
style: .plain,
target: self,
action: #selector(addCredential)
)
button.isEnabled = false
button.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.actionPrimary
if #available(iOS 26.0, *) {
button.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.textAccent
} else {
button.tintColor = themeManager.getCurrentTheme(for: windowUUID).colors.actionPrimary
}
return button
}()

Expand Down
Loading