-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Notifications Refresh] Replace tabs with dropdown in notifications s…
…creen (#23054)
- Loading branch information
Showing
4 changed files
with
83 additions
and
84 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import UIKit | ||
|
||
extension UIButton { | ||
|
||
/// Creates a bar button item that looks like the native title menu | ||
/// (see `navigationItem.titleMenuProvider`, iOS 16+). | ||
static func makeMenu(title: String, menu: UIMenu) -> UIButton { | ||
let button = UIButton(configuration: { | ||
var configuration = UIButton.Configuration.plain() | ||
configuration.title = title | ||
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { | ||
var attributes = $0 | ||
attributes.font = WPStyleGuide.fontForTextStyle(.headline) | ||
return attributes | ||
} | ||
configuration.image = UIImage(systemName: "chevron.down.circle.fill")?.withBaselineOffset(fromBottom: 4) | ||
configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(paletteColors: [.secondaryLabel, .secondarySystemFill]) | ||
.applying(UIImage.SymbolConfiguration(font: WPStyleGuide.fontForTextStyle(.subheadline, fontWeight: .semibold))) | ||
configuration.imagePlacement = .trailing | ||
configuration.imagePadding = 4 | ||
configuration.baseForegroundColor = .label | ||
return configuration | ||
}()) | ||
let button = UIButton(configuration: menuButtonConfiguration(title: title)) | ||
button.menu = menu | ||
button.showsMenuAsPrimaryAction = true | ||
return button | ||
} | ||
|
||
/// The configuration of a bar button item that looks like the native title menu | ||
static func menuButtonConfiguration(title: String) -> UIButton.Configuration { | ||
var configuration = UIButton.Configuration.plain() | ||
configuration.title = title | ||
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { | ||
var attributes = $0 | ||
attributes.font = WPStyleGuide.fontForTextStyle(.headline) | ||
return attributes | ||
} | ||
configuration.image = UIImage(systemName: "chevron.down.circle.fill")?.withBaselineOffset(fromBottom: 4) | ||
configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(paletteColors: [.secondaryLabel, .secondarySystemFill]) | ||
.applying(UIImage.SymbolConfiguration(font: WPStyleGuide.fontForTextStyle(.subheadline, fontWeight: .semibold))) | ||
configuration.imagePlacement = .trailing | ||
configuration.imagePadding = 4 | ||
configuration.baseForegroundColor = .label | ||
return configuration | ||
} | ||
} |
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