-
Notifications
You must be signed in to change notification settings - Fork 500
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 Version of Room Notification Settings V2 #4670
SwiftUI Version of Room Notification Settings V2 #4670
Conversation
…eyd/4669_room_notification_settings_swiftui
… swiftui views with VectorHostingViewController, VectorContentModifier. Add VisibilityModifier. Move from List to VStack.
…eyd/4669_room_notification_settings_swiftui
…x padding and make nav buttons private.
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModelType.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettingsView.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionHeaderView.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionHeaderView.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsCoordinator.swift
Outdated
Show resolved
Hide resolved
This looks really great! So good how much the VStack looks and feels like a List 😄. Sorry I added quite so many comments. I think it would be nice to have a few more doc comments (autocompletion hints for the new view types would be super helpful going forward). Two general points I'm wondering about that are worth discussing tomorrow:
|
+1 @pixlwave regarding naming. Also something I'd like to discuss. Also things like DesignKit and what ends up going in there. Main reason I had I think if we start using LocalizedStringKey it will look for strings in resources with that key which wont work with the current SwiftGen approach (Isn't using english as the key). But yea probably a few SwiftUI features like that we can discuss. |
Updates look good to me. Wondering if it should be |
…thub.com:vector-im/element-ios into langleyd/4669_room_notification_settings_swiftui
… injection for MxMediaManager dependency.
…eyd/4669_room_notification_settings_swiftui
…now in AvatarImage.
👀 at build errors |
Ok looks like build is fixed, test and alpha failed due to timeouts. |
📱 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/VeWcc3 |
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 injection module is very nice!
I wonder if we should separate pure SwiftUI code and UIKit code right now. I am afraid that we will mix or miss things if we continue to put everything into Modules
. The RoomNotificationSettings
code is hybrid and can stay there but pure SwiftUI code should not be not mixed with UIKit.
Options:
- keep current
Modules
andSwiftUIModules
folders as the same level - add another layer like
Modules/UIKit
with current code andModules/SwiftUI
- or ...
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSwiftUIViewModel.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift
Outdated
Show resolved
Hide resolved
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSwiftUIViewModel.swift
Show resolved
Hide resolved
Co-authored-by: manuroe <[email protected]>
Co-authored-by: manuroe <[email protected]>
Co-authored-by: manuroe <[email protected]>
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, especially the dependency injection stuff! More thoughts on naming 🙄
Injectable
vsInjectableObject
are very close in meaning. When I seeInjectable
by itself, it's hard to reason about whether it's to be injected or can receive injections. But I'm struggling to think of something better so might simply be something to learn.- I was clearly wrong suggesting never using
View
suffix at all. I think it still makes sense for reusable components, butRoomNotificationSettingsView
was probably clearer for the entire composition? 😕
Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSwiftUIViewModel.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Doug <[email protected]>
…tps://github.com/vector-im/element-ios into langleyd/4669_room_notification_settings_swiftui
@pixlwave and I went over apple usage and seems they use @pixlwave I had the exact same thoughts regarding |
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.
All looks good from my perspective. That switch
on the view model is wayyyy cleaner to read too 😄
This PR introduces a SwiftUI implementation of Room Notification Settings V2
What's in this PR
VectorContentModifier
a SwiftUI modifier that can be used to apply any application level configuration at the top of the SwiftUI hierarchy.VectorHostingViewController
hosts a SwiftUI view and applies theming to any containerNavigationController
and applies theVectorContentModifier
.AvatarSize
an enum to match the sizes in Design System. (Size naming TBD).AvatarService
a simple api that retrieves and caches avatars. Also a mock service.VectorAvatarView
a view for rendering avatars consistently byAvatarSize
.RoomNotificationSettingsViewModel
with the UIKit implementation. This is generally a bit awkward with with the@available
attribute.@available
can't be used with stored properties for example. For the moment we plan on using SwiftUI for new features so won't face this problem in the general case. If we do find more areas we are trying to support both UIKit + SwiftUI and avoid code duplication we may want to look into this further.List
component which is backed byUITableView
.List
does not give you access to style all parts of the tableview like the background, nor does it give you a reference to the underlyingUITableVIew
. To implement the avatar header for example I would have had to put the header inside aSection
with no content in order to get the groupedUITableView
to style correctly. Rather than fighting it I decided to use aVStack
which gives you full control but you have to do a bit more of the styling yourself. You can mitigate this by creating your own styles. I think in future this is probably give us more re-use and better flexibility.ViewModel
(previously done to make view models more testable and decoupled) had the nice side-effect that we can always run our live preview without a network connection/MxSession
.Update 2021-9-17:
AvatarViewModel
owned by theAvatarView
via a@StateObject
so that onlymxContentUri
is needed as input to the view.DependencyContainer
and the EnvironmentKeyDependencyContainerKey
Inject
property wrapper,Injectable
protocol andInjectableObject
were also added to remove some boilerplate.AvatarGenerator
and we just render that part in SwiftUI.Screenshots
Todos
RoomNotificationSettingsView
resolves #4669