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

SwiftUI contact list #1205

Merged

Conversation

matthewrfennell
Copy link
Member

@matthewrfennell matthewrfennell commented Aug 12, 2024

Introduction

This PR implements the first part of #1094

To do in (if it's ok) future PRs:

Videos

iPhone

1094-iphone-full.mp4

iPad

At 2:22, the contact gets deleted from another device.

1094-ipad-full.mp4

Animated notification badge

Just before raising this PR, I noticed the contact request notification badge wasn't animated.
I didn't want to re-record everything, so here's a recording of just that animation.

1094-notification-animation.mp4

}
}
.swipeActions(allowsFullSwipe: false) {
// We do not use a Button with destructive role here as we would like to display the confirmation dialog first.
Copy link
Member

Choose a reason for hiding this comment

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

That's very nice! could you add that behaviour to the group members list, too?

Copy link
Member

Choose a reason for hiding this comment

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

Don't forget this one :)

}
}
.sheet(isPresented: $addContactIsPresented) {
NavigationStack {
Copy link
Member

Choose a reason for hiding this comment

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

Would be nicer to not open a new navigation stack here, but use the current one (that would look nice even on ipad/macos, I guess) and let the user return to the contact list by using the back button.

@matthewrfennell
Copy link
Member Author

matthewrfennell commented Aug 18, 2024

Popover

Here's how it looks now:

full-example.mp4.compressed.mp4.rotated.mp4

There is one edge case: if the view size changes from regular to compact (or vice versa) while the view is open, the button doesn't get added or removed:

button.mp4.compressed.mp4.rotated.mp4

I'm looking into this now, but it might take some time to work out. It may be easier to wait until the ActiveChatsViewController is also SwiftUI.

Group list swipe action

Swipe action now doesn't allow full swipe, and users joining and leaving are now animated (presence changes are not animated yet).

group-swipe-action.mp4.compressed.mp4

Here's how the sheet looks on the iPhone:

group-swipe-action

(sheet looks the same as before in both cases, just wanted to show it)

@tmolitor-stud-tu
Copy link
Member

Regarding the back button stuff: have a look at MLSplitViewDelegate.m.

This should allow you to trigger an event if the split view type (compact/expanded) changes and react accordingly in swiftui.

It will allow you to remove the code passing in the state (horizontalSizeClass, shouldDisplayBackButton etc.) all the way from active chats down to the swiftui view, too :)

@matthewrfennell
Copy link
Member Author

GitHub is getting stuck uploading the video. So here's a blurry gif instead :)

https://github.com/user-attachments/assets/9af4f125-b06f-4377-a179-231c8479e18b

@tmolitor-stud-tu
Copy link
Member

I feel like shouldAlwaysDisplayBackButtonisn't needed anymore, right?

Is the SizeClassWrapper needed? Wouldn't it be better to just add that horizontal property to ActiveChats directly (renamed to horizontalSizeClass, of course)

This convenience method is also not available in iOS 16, so we redefine
it making use of our existing shim.

The signature does not exactly match Apple's, but it's sufficiently
similar that we can drop in the real version without changes when
needed, simply by renaming the class being called.
This is a reusable badge designed to be overlaid on top of Buttons when
they have notifications.
Sorting is done via the contact's display name first, and by jid
second.
This view was shown incorrectly in certain situations when inside a
popover. This commit introduces a workaround so that SwiftUI uses
consistent spacing, whether the popover is presented as a popover or a
sheet.
This can be used to tell us whether we should display back buttons in
popovers.
This makes sure the sizeClass in ActiveChatsViewController is always
kept in sync with changes to the size class (e.g. when the size changes
in split view).
Apple guidelines state that we should only display a close button on a
popover for confirmation or guidance. Therefore, there are some
situations where we would like to display a popover without a close
button.

This commit allows us to only display the close button inside
AddTopLevelNavigation when it is needed.

Unfortunately, we have to retrieve the size class from the active chats
view controller. It doesn't work to use
@Environment(\.horizontalSizeClass) within AddTopLevelNavigation, since
this will always display as compact within the popover itself.
We only animate additions and removals from the group here. Animating
presence changes (e.g. fading the opacity in and out) and affiliation
changes is still to do, as it requires a larger refactor.
@matthewrfennell
Copy link
Member Author

Here's how the ContactDetails view dismiss button looks now:

back-button-applied-everywhere-rotated.mp4.compressed.mp4

@tmolitor-stud-tu tmolitor-stud-tu merged commit 46d92e5 into monal-im:develop Aug 29, 2024
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.

2 participants