-
Notifications
You must be signed in to change notification settings - Fork 498
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
Add Authentication Service and first 2 screens for new flow. #6048
Conversation
DesignKit/Source/Colors.swift
Outdated
/// Global color: The color white. | ||
var white: ColorType { get } | ||
|
||
/// Global color: The EMS brand's purple colour. | ||
var ems: ColorType { get } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm semi wondering if these should be grouped in a theme.globalColors.ems
property or perhaps theme.colors.global.ems
.
e6d4809
to
4774cf7
Compare
📱 Scan the QR code below to install the build for this PR. If you can't scan the QR code you can install the build via this link: https://i.diawi.com/VwEmm3 |
4774cf7
to
64c4fa9
Compare
64c4fa9
to
ee07144
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is quite a lot of code in this PR, which makes it harder to review and see how all the bits fit together. Additionally some of the classes (e.g. the coordinators) are quite large, which makes them harder to understand and maintain in the long run. I wrote some suggestions below of how some of the code could be extracted out and tested.
RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/RegistrationFlowHandling.swift
Outdated
Show resolved
Hide resolved
RiotSwiftUI/Modules/Authentication/Registration/AuthenticationRegistrationModels.swift
Show resolved
Hide resolved
RiotSwiftUI/Modules/Authentication/Registration/AuthenticationRegistrationModels.swift
Show resolved
Hide resolved
...wiftUI/Modules/Authentication/Registration/AuthenticationRegistrationViewModelProtocol.swift
Show resolved
Hide resolved
RiotSwiftUI/Modules/Authentication/Registration/Test/UI/AuthenticationRegistrationUITests.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just have a few more questions
// MARK: - Public | ||
|
||
override func process(viewAction: AuthenticationRegistrationViewAction) { | ||
Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't Task
and await MainActor.run
right after equal to just not using any concurrency? Or is the process
method simetimes called from non-main thread? I wonder if that should be allowed if it is mean to accept view actions, i.e. actions triggered from the main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a side effect of marking completion
as @MainActor
where you get a compile error unless Swift can see that the call is also coming from the main thread. The right answer here is that process
should also be @MainActor
but that breaks the protocol conformance, and so without updating the protocol and all of the SwiftUI view models this is the best "on-ramp" onto the MainActor
I could come up with.
In reality the View Model (and Coordinator and View) should be annotated @MainActor
and then none of the methods/properties would need annotating individually. Would be nice to get this right early on in EIX to avoid async calls like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of options that I could do to make this cleaner:
- Add a
@MainActor private func processOnMain(viewAction: AuthenticationRegistrationViewAction)
and call it from here. - Add a
MainActorTask
/TaskOnMain
that hides away theawait MainActor.run
the removes one level of closure.
Happy to consider either of these (or other ideas) if you think they make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MainActor private func
seems clean enough, though happy to go along the current code for this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, will do that alongside renaming the completions
.
...wiftUI/Modules/Authentication/Registration/AuthenticationRegistrationViewModelProtocol.swift
Show resolved
Hide resolved
RiotSwiftUI/Modules/Authentication/Registration/Test/UI/AuthenticationRegistrationUITests.swift
Show resolved
Hide resolved
VStack(spacing: 0) { | ||
header | ||
.padding(.top, OnboardingMetrics.topPaddingToNavigationBar) | ||
.padding(.bottom, 36) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional for future PR: might be good to extract these hardcoded padding constants into some internal struct / enum for more control and consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slowing pulling out common constants into OnboardingMetrics
, but I have wondered about local constants too. So far my conclusion was that unless some of these constants are shared, then the benefit is small and is no different to entering constraint values into a xib/storyboard. But definitely something I'd like to talk about more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is true. The main issue with constants is that it is not whether different values are different deliberately or we just have not considered unifiying them (same goes for font sizes etc). But we can improve this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing all the feedback
- Add Registration Screen. - Add Server Selection Screen. - Rename AuthenticationCoordinator to LegacyAuthenticationCoordinator. - Add AuthenticationService and RegistrationWizard. - Async extensions. - Add global white and EMS colors to the themes. - Add tests for server selection and registration screens. - Accessibility and iPad layout tweaks. - Remove MainActor from Auth Coordinators/VMs/Views. (It broke the protocol conformances so now the methods and properties are marked individually.)
Stop using the homeserver from user defaults.
Log errors before throwing. Remove white colour. Remove AuthenticationCoordinatorState added during rebase.
0e86a96
to
d89da7a
Compare
This PR adds an
AuthenticationService
andRegistrationWizard
based on the Android implementations. It additionally adds the Registration screen and Server Selection screen. It alsoAuthenticationCoordinator
toLegacyAuthenticationCoordinator
.MXRestClient
andMXHTTPClient
withasync
variants of the used methods to help the implementation more closely align with Kotlin's suspending functions.ems
andwhite
to the themes.Closes #5161. Closes #5648. Requires matrix-org/matrix-ios-sdk#1443