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

Update activity indicators on leaving room #5630

Merged
merged 6 commits into from
Feb 25, 2022
Merged

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Feb 18, 2022

Resolves #5605

Note that this captures 2 most common out of 4 ways a user may leave the room. The other less common 2 ways are captured in #5608

Leaving from detail Leaving from home
details context
Leaving Left
Simulator Screen Shot - iPhone 13 - 2022-02-18 at 13 18 38 Simulator Screen Shot - iPhone 13 - 2022-02-18 at 13 33 40

@github-actions
Copy link

github-actions bot commented Feb 18, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/VaVQcr

func present() {
// Find the current top navigation controller
var vc: UIViewController? = viewController
while vc?.navigationController != nil {
Copy link
Member

Choose a reason for hiding this comment

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

SwiftLint warning here Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'vc' (identifier_name)

Copy link
Member

Choose a reason for hiding this comment

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

You probably need to update .swiftlint with the path to CommonKit. Do me a favor and check the other targets while you're at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is happening outside the CommonKit, so I must have some incomplete setup.

private weak var viewController: UIViewController?
private var activity: Activity?

init(label: String, on viewController: UIViewController) {
Copy link
Member

Choose a reason for hiding this comment

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

This on parameter has the semantics of an action happening. We should keep it simple with init(title: String, viewController: UIViewController). Same applies to the FullscreenLoadingActivityPresenter`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is following the API requirements of ActivityIndicatorPresenterType, which has present(on view: UIView), but I can change at least the init.

Riot/Modules/Application/AppCoordinator.swift Outdated Show resolved Hide resolved
@@ -73,6 +76,10 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
self.activityIndicatorPresenter = ActivityIndicatorPresenter()
}

deinit {
activities.cancelAll()
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between cancel and complete in this context?

Also, I was under the impression this happens automatically on activity deinit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

complete should not be public API, only cancel is. But this manual cancellation isn't necessary, it does indeed automatically deinit, so removing.

Riot/Modules/Application/AppCoordinator.swift Show resolved Hide resolved
switch type {
case let .loading(label):
let presenter = ToastActivityPresenter(
viewState: .init(
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit weird that the presenter is advertising that it's using a RoundedToastView by requiring one of its viewStates. That's an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I extracted the view state out of the context of RoundedToastView so now it can be a shared type between the presenter and the view

@@ -47,7 +48,9 @@ class ActivityIndicatorToastPresenter: ActivityPresentable {
])

view.alpha = 0
CATransaction.flush()
Copy link
Member

Choose a reason for hiding this comment

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

What's this about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was meant to solve the issue described in the previous comment, where calling dismiss right after present did not respect the current alpha, presumably because all the changes happen within one run loop, but testing it now, it does not actually work. Reverting for now and will find another solution in the next PR.

imageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
imageView.widthAnchor.constraint(equalToConstant: Constants.imageViewSize),
imageView.heightAnchor.constraint(equalToConstant: Constants.imageViewSize),
Copy link
Member

Choose a reason for hiding this comment

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

Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have my eyes on automatic swift formatter as next improvement


func present() {
// Find the current top navigation controller
var vc: UIViewController? = viewController
Copy link
Member

Choose a reason for hiding this comment

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

Might as well do it on the app's window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but then I have the problem of needing to inject the window (Or do the ugly UIApplication.shared.windows ... ). As I am going to work with these in the room indicators, I will revisit the approach.

return indicator
}()

private lazy var imagView: UIImageView = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo

Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

Looks great, 🚢 it! 😁

Copy link

@amshakal amshakal left a comment

Choose a reason for hiding this comment

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

TY! 👯

@niquewoodhouse niquewoodhouse removed their request for review February 25, 2022 09:28
@Anderas Anderas merged commit c7985e5 into develop Feb 25, 2022
@Anderas Anderas deleted the andy/5605_leave_room branch February 25, 2022 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leave Room Activity Indicators
3 participants