-
Notifications
You must be signed in to change notification settings - Fork 116
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
[Horizon] Add navigation bar #3034
[Horizon] Add navigation bar #3034
Conversation
[ignore-commit-lint]
❌ XCTest failed: CoreTests/AssignmentCellViewModelTests/testSubmissionStatusAndIconAndColor
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testAutomaticRead
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testLayout
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testShowEntry
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testShowReplies
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testStudentGroupTopic
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testStudentGroupTopicWhenUserNotInAGroup
❌ XCTest failed: CoreTests/DiscussionDetailsViewControllerTests/testTeacherGroupTopic
|
.scrollIndicators(.hidden, axes: .vertical) | ||
.background(Color.backgroundLight) | ||
.onFirstAppear { viewModel.viewController = viewController} |
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 don't love the pattern of requiring the view to set a property on the view model. I think it's better just to pass the viewController as an argument to the notebookDidTap method. That way it's always clear what is required. Otherwise it can be unclear to someone using the view model that they need to set that property before it'll work.
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.
Ok but i need to pass the closure direct to view model, because the navigation logic must be set in viewModel.
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.
It would just be one of the parameters passed in the onEvent handler:
func onEvent(event: HorizonUI.NavigationBar.Trailing.Event, viewController: WeakViewController)
You might also consider creating a separate ViewModel to pair with the HorizonUI.NavigationBar.Trailing and putting the onEvent handler in there. Otherwise we must handle the navigation logic in the ViewModel for every View that uses the HorizonUI.NavigationBar.Trailing view.
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.
If I'm being honest though, the amount of logic that would go into the Trailing view controller is so small and unlikely to be broken, I'd probably just put it into the view. So it's up to you what you want to do there.
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.
No, HorizonUI is just for creating UI only and shouldn't have any logic in it.
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.
Since this component will be used only on the dashboard, I'd simply pass 3 named () -> Void
closure to the HorizonUI.NavigationBar.Trailing
initializer then we can have:
viewModel.notebookDidTap(viewController)
viewModel.notificationDidTap(viewController)
...the rest
that is readable easily.
Horizon/Horizon/Sources/Features/Dashboard/View/DashboardViewModel.swift
Outdated
Show resolved
Hide resolved
...ges/HorizonUI/Sources/HorizonUI/Sources/Components/NavigationBar/TrailingNavigationBar.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.
Please see my comments below.
...ages/HorizonUI/Sources/HorizonUI/Sources/Components/NavigationBar/LeadingNavigationBar.swift
Outdated
Show resolved
Hide resolved
.scrollIndicators(.hidden, axes: .vertical) | ||
.background(Color.backgroundLight) | ||
.onFirstAppear { viewModel.viewController = viewController} |
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.
Since this component will be used only on the dashboard, I'd simply pass 3 named () -> Void
closure to the HorizonUI.NavigationBar.Trailing
initializer then we can have:
viewModel.notebookDidTap(viewController)
viewModel.notificationDidTap(viewController)
...the rest
that is readable easily.
Navigation bar
https://instructure.atlassian.net/browse/CLX-282