-
Notifications
You must be signed in to change notification settings - Fork 117
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
Navigation bar titles #3129
base: master
Are you sure you want to change the base?
Navigation bar titles #3129
Conversation
refs: MBL-18460 affects: Student, Teacher, Parent release note: none
d1268aa
to
bc5726c
Compare
/// - Parameters: | ||
/// - title: The line is always displayed, even if this is empty. (This should not happen normally.) | ||
/// - subtitle: The subtitle line is only displayed if this is not empty. | ||
public func navigationBarTitleView(title: String, subtitle: String?) -> some 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.
This is considered as being an implicit dependency and can be easily missed out.
Rather than dictating that a specific modifier must be called after this one for it work properly.
I would go with passing style
as a required parameter to this modifier.
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 agree that it's not ideal, and I've considered passing style here, but it creates it's own problems.
Style sets the background color as well, and as a next step it's planned to govern the NavigationBarItems' color (via navBarColors.tint
). That would mean we would have to set the style in 3 separate places which is also not ideal, plus it allows for mixed styles which we want to restrict.
I consider this solution as a lesser evil. And since order already matters for SwiftUI modifiers, it's a known concept (although maybe in an unexpected way, yes). Another mitigation of the issue is that this solution (and only this) would be used all over the project, with plenty of examples and documentation.
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.
Just to make sure I conveyed my idea correctly. What I mean with passing style
, as simple as having style modifier inside this one.
public func navigationBarTitleView(title: String, subtitle: String?, style: NavigationBarStyle) -> some View {
toolbar {
ToolbarItem(placement: .principal) {
InstUI.NavigationBarTitleView(title: title, subtitle: subtitle)
}
}
.navigationBarStyle(style)
}
You mean even doing that can create problems ?
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.
Yes, basically I aim to avoid this:
content
.navigationBarTitleView(title: ..., style: .modal)
.navBarItems(trailing: ..., style: .modal)
.navigationBarStyle(.modal)
or even:
content
.navigationBarTitleView(title: ..., style: .modal)
.navBarItems(trailing: ..., style: .modal) // which would call .navigationBarStyle() inside again in your example
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.
Code +1
@@ -30,7 +30,7 @@ public struct CalendarToDoDetailsScreen: View { | |||
InstUI.BaseScreen(state: viewModel.state, config: viewModel.screenConfig) { _ in | |||
eventContent | |||
} | |||
.navigationTitle(viewModel.navigationTitle) | |||
.navigationBarTitleView(viewModel.navigationTitle) |
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 navigationBarStyle()
is called after 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.
QA +1
Tested on iPhone, iOS 18.2.0, Student and Parent apps.
One note though, I noticed that Title View on Assignments Screen takes a split second before appearing. See record below:
refs: MBL-18460
affects: Student, Teacher, Parent
release note: none
What's changed
InstUI.NavigationBarTitleView
, it's used vianavigationBarTitleView()
NavigationView
too, not just inUINavigationController
TitleSubtitleView
, but now it is only used in ViewControllerssemibold16
and subtitle font toregular14
How to set navigation bar title/subtitle
navigationBarTitleView(_:)
ornavigationBarTitleView(title:, subtitle:)
modifiernavigationBarStyle(_:)
modifiernavigationTitle()
methodsChores
.modalLight
navigation bar styleCommonUI/NavigationBar
folderTest Plan
Checklist