Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor buttons to use UIButton.Configuration #6928

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

mojganii
Copy link
Collaborator

@mojganii mojganii commented Oct 4, 2024

This PR refactors the buttons to use UIButton.Configuration for their configuration.


This change is Reviewable

Copy link

linear bot commented Oct 4, 2024

@mojganii mojganii self-assigned this Oct 4, 2024
@mojganii mojganii added the iOS Issues related to iOS label Oct 4, 2024
Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @mojganii)


ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift line 111 at r1 (raw file):

        config.contentInsets = UIMetrics.textFieldMargins.toDirectionalInsets
        config.baseForegroundColor = .AccountTextField.NormalState.textColor
        button.configuration = config

Nit: I think we should either add all available configurations (including eg.title) or just the one that is deprecated. Title color isn't deprecated and can be left out if we want to.


ios/MullvadVPN/Views/CustomButton.swift line 43 at r1 (raw file):

            return UIColor.AppButton.normalTitleColor
        case .disabled:
            return UIColor.AppButton.disabledTitleColor.withAlphaComponent(0.5)

Is this ok to remove? This color has a value of 1.0 alpha and without the 0.5 it is the same color as .highlightedTitleColor.

Copy link
Collaborator Author

@mojganii mojganii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @rablador)


ios/MullvadVPN/View controllers/Login/AccountInputGroupView.swift line 111 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Nit: I think we should either add all available configurations (including eg.title) or just the one that is deprecated. Title color isn't deprecated and can be left out if we want to.

Good catch!
we have to put all together in configuration.


ios/MullvadVPN/Views/CustomButton.swift line 43 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Is this ok to remove? This color has a value of 1.0 alpha and without the 0.5 it is the same color as .highlightedTitleColor.

it's correct both have the same value but we are using them separately in the code. so I suggest to not let them mix up when it's supposed to have different style for different states.

@mojganii mojganii force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 973ed38 to 06d2f5b Compare October 7, 2024 12:08
rablador
rablador previously approved these changes Oct 7, 2024
Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the reconnect button is gone

Reviewed 6 of 8 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mojganii)


ios/MullvadVPN/Views/InAppPurchaseButton.swift line 78 at r2 (raw file):

    }

    private func getActivityIndicatorRect(forContentRect contentRect: CGRect) -> CGRect {

nit
There's no need to add a get prefix here, the name of the function follows convention and Apple's guidelines

@mojganii mojganii force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 06d2f5b to 47c0fcf Compare October 8, 2024 10:58
Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: 5 of 8 files reviewed, 1 unresolved discussion (waiting on @buggmagnet and @mojganii)

@mojganii mojganii force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 47c0fcf to 9fa4ad7 Compare October 10, 2024 11:59
@mojganii mojganii force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 9fa4ad7 to 3674be3 Compare October 10, 2024 12:03
Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 8 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @mojganii)


ios/MullvadVPN/Views/AppButton.swift line 109 at r4 (raw file):

        imageAlignment = .trailing
        titleAlignment = .leading
        isHighlighted = false

This attribute is false by default.

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 8 files at r4.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @mojganii)


ios/MullvadVPN/Extensions/CGSize+Helpers.swift line 13 at r4 (raw file):

extension CGSize {
    // Function to deduct insets from CGSize
    func deducting(insets: NSDirectionalEdgeInsets) -> CGSize {

nit
It's deducting offsets from a NSDirectionalEdgeInsets


ios/MullvadVPN/Extensions/CGSize+Helpers.swift line 14 at r4 (raw file):

    // Function to deduct insets from CGSize
    func deducting(insets: NSDirectionalEdgeInsets) -> CGSize {
        let newWidth = self.width - (insets.leading + insets.trailing)

not need for self here and below


ios/MullvadVPN/Extensions/UIImage+Helpers.swift line 14 at r4 (raw file):

    // Function to resize image while keeping aspect ratio
    func resizeImage(targetSize: CGSize) -> UIImage {
        let widthRatio = targetSize.width / self.size.width

no need for self here and below

@mojganii mojganii force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 3674be3 to 0fbaa5a Compare October 11, 2024 13:45
Copy link
Collaborator Author

@mojganii mojganii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 of 10 files reviewed, 5 unresolved discussions (waiting on @buggmagnet and @rablador)


ios/MullvadVPN/Extensions/CGSize+Helpers.swift line 14 at r4 (raw file):

Previously, buggmagnet wrote…

not need for self here and below

Done.


ios/MullvadVPN/Extensions/UIImage+Helpers.swift line 14 at r4 (raw file):

Previously, buggmagnet wrote…

no need for self here and below

Done.


ios/MullvadVPN/Views/AppButton.swift line 109 at r4 (raw file):

Previously, rablador (Jon Petersson) wrote…

This attribute is false by default.

true. I've forgotten to remove that.


ios/MullvadVPN/Views/InAppPurchaseButton.swift line 78 at r2 (raw file):

Previously, buggmagnet wrote…

nit
There's no need to add a get prefix here, the name of the function follows convention and Apple's guidelines

Fair enough!

Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5 of 5 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @buggmagnet and @mojganii)

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 8 files at r4, 5 of 5 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mojganii)

Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mojganii)

@pinkisemils pinkisemils force-pushed the fix-deprecation-warning-for-button-ios-856 branch from 0fbaa5a to 0339b0b Compare October 17, 2024 06:58
Copy link
Contributor

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mojganii)

@pinkisemils pinkisemils merged commit 59e445c into main Oct 17, 2024
10 of 11 checks passed
@pinkisemils pinkisemils deleted the fix-deprecation-warning-for-button-ios-856 branch October 17, 2024 07:18
Copy link

🚨 End to end tests failed. Please check the failed workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants