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

Convert ConfirmationView from UIKit to SwiftUI #769

Merged

Conversation

rasmustautsglia
Copy link
Contributor

@rasmustautsglia rasmustautsglia commented Sep 13, 2023

This PR is an experimental, yet important first step towards transitioning to SwiftUI. ConfirmationView has been rewritten entirely in SwiftUI. The primary motivator for this PR was the frustrating nature of UIKit constraints.

Key factors to keep in mind while reviewing:

  1. The checkmark image has been made smaller, which was the request from the design team

  2. UIFont does not translate 1:1 to SwiftUI Font, meaning the same font looks just a little bit different now. But dynamic scaling works and all our default fonts translate to the expected outcome (font size, weight, etc.)

  3. Some approaches used in view layouts are due to the restrictions of SwiftUI 1.0 capabilities. Those can and will be upgraded in the future

  4. The naming of Views, and Objects, as well as file locations in the directory are up for discussion. Everyone's input is much appreciated.

  5. Prefix SwiftUI is used in lots of places due to a conflict with existing custom objects Button and Image

  6. The new HeaderSwiftUI view does not include all the possible configuration possibilities, as the ConfirmationView's needs are not very demanding. So, that view can be upgraded in the future.

This PR also covers the ticket MOB-2488 which focuses on ADA compliance in ConfirmationView

Snapshot image reference PR: https://github.com/salemove/ios-widgets-snapshots/pull/47

#I

@rasmustautsglia rasmustautsglia changed the title Convert ConfirmationView form UIKit to SwiftUI Convert ConfirmationView from UIKit to SwiftUI Sep 13, 2023
@rasmustautsglia rasmustautsglia force-pushed the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch from e3a5fcd to 5e452cc Compare September 14, 2023 06:45
Copy link
Contributor

@igorkravchenko igorkravchenko left a comment

Choose a reason for hiding this comment

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

As we have discussed, lets try view model approach.

@rasmustautsglia rasmustautsglia force-pushed the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch 2 times, most recently from 45a7410 to 5051718 Compare September 14, 2023 15:10
@rasmustautsglia rasmustautsglia force-pushed the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch from 5e700f7 to 3fc3927 Compare September 15, 2023 09:22
Copy link
Contributor

@EgorovEI EgorovEI left a comment

Choose a reason for hiding this comment

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

LGTM 💪

Copy link
Contributor

@igorkravchenko igorkravchenko left a comment

Choose a reason for hiding this comment

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

Left one comment about moving OrientationManager to Model.

renderProps()
struct ConfirmationViewSwiftUI: View {
@ObservedObject var model: Model
@ObservedObject var orientation: OrientationManager
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it will be beneficial in terms of have single source of truth to make orientation a part of Model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it is not possible

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's how it could be achieved f448682.
And I think OrientationManager can be injected as dependency itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed dc39037

@rasmustautsglia
Copy link
Contributor Author

!squash

@sm-deployer sm-deployer force-pushed the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch from added37 to 0946736 Compare September 20, 2023 12:23
Copy link
Contributor

@igorkravchenko igorkravchenko left a comment

Choose a reason for hiding this comment

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

I updated Model to use nested OrientationManager. As we discussed, we can also make OrientationManager as dependency and inject it.

Copy link
Contributor

@igorkravchenko igorkravchenko left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@rasmustautsglia
Copy link
Contributor Author

!squash

This PR is experimental, yet important first step towards transitioning
to SwiftUI. ConfirmationView has been rewritten entirely in SwiftUI. The
primary motivator for this PR was the frustrating nature of UIKit constraints.

Key factors to keep in mind while reviewing:

1. Checkmark image has been made smaller, which was the request from the
design team

2. UIFont does not translate 1:1 to SwiftUI Font, meaning the same font
looks just a little big different now. But dynamic scaling works, and all
our default fonts translate to expected outcome (font size, weight etc.)

3. Some approaches used in view layouts is due to the restrictions of
SwiftUI 1.0 capabilities. Those can and will be upgraded in the future

4. The naming of Views, and Objects, as well as file locations in the
directory are up for discussion. Everyone's input is much appreciated.

5. Prefix SwiftUI is used in lots of places due to a conflict with existing
custom objects Button and Image

6. New HeaderSwiftUI view does not include all the possible configuration
possibilities, as confirmations view's needs are not very demanding. So,
that view can be upgraded in future.

This PR also covers the ticket MOB-2488 which focuses on ADA-compliance
in ConfigurationsView
@sm-deployer sm-deployer force-pushed the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch from 54d5356 to 2f7eb17 Compare September 21, 2023 08:52
@rasmustautsglia rasmustautsglia merged commit 302b0a9 into development Sep 21, 2023
1 check passed
@rasmustautsglia rasmustautsglia deleted the Convert-ConfirmationView-from-UIKit-to-SwiftUI branch September 21, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants