-
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
Navigation bar titles #3129
Open
rh12
wants to merge
13
commits into
master
Choose a base branch
from
bugfix/MBL-18460-NavigationBar-titles
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Navigation bar titles #3129
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8fc462c
Remove UINavigationBar.Style.modalLight
rh12 87697b6
Unify navigation bar fonts
rh12 2ef1551
Add InstUI.NavigationBarTitleView
rh12 c810e0f
Remove unused Inbox AttachmentPicker
rh12 dfb62d1
Remove navigationTitleStyled, replace usages with navigationBarTitleView
rh12 22879c5
Add title only modifier variant
rh12 4db5eab
Replace native navigation title calls
rh12 46f6048
Remove custom navigationTitle(), replace usages with navigationBarTit…
rh12 f5c9d3f
Cleanup
rh12 712efeb
Fix SmartSearch removing titleView in CorseDetails
rh12 7872de4
Move related files together, add tests
rh12 38ea153
Increase subtitle font size to 14
rh12 bc5726c
Fix swiftlint issue
rh12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Core/Core/Common/CommonUI/InstUI/Views/NavigationBarTitleView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// This file is part of Canvas. | ||
// Copyright (C) 2025-present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension InstUI { | ||
|
||
public struct NavigationBarTitleView: View { | ||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize | ||
@Environment(\.navBarColors) private var navBarColors | ||
|
||
private let title: String | ||
private let subtitle: String? | ||
|
||
public init( | ||
title: String, | ||
subtitle: String? = nil | ||
) { | ||
self.title = title | ||
self.subtitle = subtitle | ||
} | ||
|
||
public var body: some View { | ||
VStack(spacing: 1) { | ||
Text(title) | ||
.font(.semibold16) | ||
.foregroundColor(navBarColors.title) | ||
|
||
if let subtitle, subtitle.isNotEmpty { | ||
Text(subtitle) | ||
.font(.regular14) | ||
.foregroundColor(navBarColors.subtitle) | ||
} | ||
} | ||
.accessibilityElement(children: .combine) | ||
.accessibilityAddTraits(.isHeader) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Core/Core/Common/CommonUI/NavigationBar/NavigationBarColorConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// This file is part of Canvas. | ||
// Copyright (C) 2025-present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct NavigationBarColorConfiguration { | ||
var title: Color | ||
var subtitle: Color | ||
var tint: Color | ||
|
||
// private, because currently we don't want to allow custom configurations | ||
private init(title: Color, subtitle: Color, tint: Color) { | ||
self.title = title | ||
self.subtitle = subtitle | ||
self.tint = tint | ||
} | ||
|
||
init(style: NavigationBarStyle, brand: Brand = .shared) { | ||
switch style { | ||
case .modal: | ||
self.init( | ||
title: .textDarkest, | ||
subtitle: .textDark, | ||
tint: brand.linkColor.asColor | ||
) | ||
case .global: | ||
let color = brand.navTextColor.asColor | ||
self.init(title: color, subtitle: color, tint: color) | ||
case .color: | ||
let color = Color.textLightest | ||
self.init(title: color, subtitle: color, tint: color) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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:
or even: