-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Polish mobile timeline navigation #5874
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d5d422d
Polish mobile timeline navigation
klopez4212 d7e6578
Ignore nested timeline scroll metrics
klopez4212 091f8e9
Sync iOS glass controls with app theme
klopez4212 5d622c2
Slow latest button exit animation
klopez4212 afb01e4
Refresh latest navigation on composer resize
klopez4212 6fe81cf
Fix detached latest navigation
klopez4212 fbd9f56
Merge main into mobile timeline navigation
e0f5e5d
fix(mobile): address timeline review feedback
klopez4212 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 hidden or 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 hidden or 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 hidden or 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,125 @@ | ||
| import Flutter | ||
| import UIKit | ||
|
|
||
| final class JumpToLatestGlassButtonFactory: NSObject, FlutterPlatformViewFactory { | ||
| private let messenger: FlutterBinaryMessenger | ||
|
|
||
| init(messenger: FlutterBinaryMessenger) { | ||
| self.messenger = messenger | ||
| super.init() | ||
| } | ||
|
|
||
| func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol { | ||
| FlutterStandardMessageCodec.sharedInstance() | ||
| } | ||
|
|
||
| func create( | ||
| withFrame frame: CGRect, | ||
| viewIdentifier viewId: Int64, | ||
| arguments args: Any? | ||
| ) -> FlutterPlatformView { | ||
| JumpToLatestGlassButtonPlatformView( | ||
| frame: frame, | ||
| viewIdentifier: viewId, | ||
| arguments: args, | ||
| messenger: messenger | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private final class JumpToLatestGlassButton: UIButton { | ||
| private static let hitTargetExpansion: CGFloat = 4 | ||
|
|
||
| override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | ||
| bounds | ||
| .insetBy( | ||
| dx: -Self.hitTargetExpansion, | ||
| dy: -Self.hitTargetExpansion | ||
| ) | ||
| .contains(point) | ||
| } | ||
| } | ||
|
|
||
| final class JumpToLatestGlassButtonPlatformView: NSObject, FlutterPlatformView { | ||
| private let containerView: UIView | ||
| private let channel: FlutterMethodChannel | ||
| private let button = JumpToLatestGlassButton(type: .system) | ||
|
|
||
| init( | ||
| frame: CGRect, | ||
| viewIdentifier viewId: Int64, | ||
| arguments args: Any?, | ||
| messenger: FlutterBinaryMessenger | ||
| ) { | ||
| containerView = UIView(frame: frame) | ||
| channel = FlutterMethodChannel( | ||
| name: "buzz/jump_to_latest_glass/\(viewId)", | ||
| binaryMessenger: messenger | ||
| ) | ||
| super.init() | ||
|
|
||
| containerView.backgroundColor = .clear | ||
| containerView.isOpaque = false | ||
| applyBrightness(from: args) | ||
|
|
||
| var configuration: UIButton.Configuration | ||
| if #available(iOS 26.0, *) { | ||
| configuration = .glass() | ||
| } else { | ||
| configuration = .gray() | ||
| configuration.baseBackgroundColor = UIColor.secondarySystemBackground | ||
| } | ||
| configuration.cornerStyle = .capsule | ||
| configuration.baseForegroundColor = .label | ||
| configuration.image = UIImage( | ||
| systemName: "arrow.down", | ||
| withConfiguration: UIImage.SymbolConfiguration( | ||
| pointSize: 16, | ||
| weight: .semibold | ||
| ) | ||
| ) | ||
| button.configuration = configuration | ||
| button.accessibilityLabel = "Jump to latest message" | ||
| button.translatesAutoresizingMaskIntoConstraints = false | ||
| button.addAction( | ||
| UIAction { [weak self] _ in | ||
| self?.channel.invokeMethod("pressed", arguments: nil) | ||
| }, | ||
| for: .touchUpInside | ||
| ) | ||
|
|
||
| channel.setMethodCallHandler { [weak self] call, result in | ||
| guard call.method == "setBrightness" else { | ||
| result(FlutterMethodNotImplemented) | ||
| return | ||
| } | ||
| self?.applyBrightness(from: call.arguments) | ||
| result(nil) | ||
| } | ||
|
|
||
| containerView.addSubview(button) | ||
| NSLayoutConstraint.activate([ | ||
| button.centerXAnchor.constraint(equalTo: containerView.centerXAnchor), | ||
| button.bottomAnchor.constraint(equalTo: containerView.bottomAnchor), | ||
| button.widthAnchor.constraint(equalToConstant: 40), | ||
| button.heightAnchor.constraint(equalToConstant: 40), | ||
| ]) | ||
| } | ||
|
|
||
| func view() -> UIView { | ||
| containerView | ||
| } | ||
|
|
||
| private func applyBrightness(from value: Any?) { | ||
| let brightness = (value as? [String: Any])?["brightness"] as? String | ||
| ?? value as? String | ||
| let interfaceStyle: UIUserInterfaceStyle = brightness == "dark" ? .dark : .light | ||
| containerView.overrideUserInterfaceStyle = interfaceStyle | ||
| button.overrideUserInterfaceStyle = interfaceStyle | ||
| button.setNeedsUpdateConfiguration() | ||
| } | ||
|
|
||
| deinit { | ||
| channel.setMethodCallHandler(nil) | ||
| } | ||
| } | ||
This file contains hidden or 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,131 @@ | ||
| import Flutter | ||
| import UIKit | ||
|
|
||
| private final class StickyDateGlassView: UIVisualEffectView { | ||
| override func layoutSubviews() { | ||
| super.layoutSubviews() | ||
| layer.cornerRadius = bounds.height / 2 | ||
| } | ||
| } | ||
|
|
||
| final class StickyDateGlassHeaderFactory: NSObject, FlutterPlatformViewFactory { | ||
| private let messenger: FlutterBinaryMessenger | ||
|
|
||
| init(messenger: FlutterBinaryMessenger) { | ||
| self.messenger = messenger | ||
| super.init() | ||
| } | ||
|
|
||
| func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol { | ||
| FlutterStandardMessageCodec.sharedInstance() | ||
| } | ||
|
|
||
| func create( | ||
| withFrame frame: CGRect, | ||
| viewIdentifier viewId: Int64, | ||
| arguments args: Any? | ||
| ) -> FlutterPlatformView { | ||
| StickyDateGlassHeaderPlatformView( | ||
| frame: frame, | ||
| viewIdentifier: viewId, | ||
| arguments: args, | ||
| messenger: messenger | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| final class StickyDateGlassHeaderPlatformView: NSObject, FlutterPlatformView { | ||
| private let glassView: StickyDateGlassView | ||
| private let channel: FlutterMethodChannel | ||
| private let dateLabel = UILabel() | ||
|
|
||
| init( | ||
| frame: CGRect, | ||
| viewIdentifier viewId: Int64, | ||
| arguments args: Any?, | ||
| messenger: FlutterBinaryMessenger | ||
| ) { | ||
| let arguments = args as? [String: Any] | ||
| let text = arguments?["label"] as? String ?? "" | ||
| channel = FlutterMethodChannel( | ||
| name: "buzz/sticky_date_glass/\(viewId)", | ||
| binaryMessenger: messenger | ||
| ) | ||
|
|
||
| if #available(iOS 26.0, *) { | ||
| let glassEffect = UIGlassEffect(style: .regular) | ||
| glassEffect.isInteractive = false | ||
| glassView = StickyDateGlassView(effect: glassEffect) | ||
| } else { | ||
| glassView = StickyDateGlassView( | ||
| effect: UIBlurEffect(style: .systemMaterial) | ||
| ) | ||
| } | ||
|
|
||
| super.init() | ||
|
|
||
| glassView.frame = frame | ||
| glassView.isOpaque = false | ||
| glassView.isUserInteractionEnabled = false | ||
| glassView.clipsToBounds = true | ||
| glassView.layer.cornerCurve = .continuous | ||
| applyBrightness(from: arguments?["brightness"]) | ||
|
|
||
| dateLabel.translatesAutoresizingMaskIntoConstraints = false | ||
| dateLabel.text = text | ||
| dateLabel.textAlignment = .center | ||
| dateLabel.textColor = .secondaryLabel | ||
| dateLabel.font = UIFontMetrics(forTextStyle: .caption1).scaledFont( | ||
| for: UIFont.systemFont(ofSize: 14, weight: .medium) | ||
| ) | ||
| dateLabel.adjustsFontForContentSizeCategory = true | ||
| dateLabel.numberOfLines = 1 | ||
| dateLabel.lineBreakMode = .byTruncatingTail | ||
| dateLabel.isAccessibilityElement = false | ||
|
|
||
| glassView.contentView.addSubview(dateLabel) | ||
| NSLayoutConstraint.activate([ | ||
| dateLabel.leadingAnchor.constraint( | ||
| equalTo: glassView.contentView.leadingAnchor, | ||
| constant: 12 | ||
| ), | ||
| dateLabel.trailingAnchor.constraint( | ||
| equalTo: glassView.contentView.trailingAnchor, | ||
| constant: -12 | ||
| ), | ||
| dateLabel.centerYAnchor.constraint( | ||
| equalTo: glassView.contentView.centerYAnchor | ||
| ), | ||
| ]) | ||
|
|
||
| channel.setMethodCallHandler { [weak self] call, result in | ||
| switch call.method { | ||
| case "setLabel": | ||
| guard let text = call.arguments as? String else { | ||
| result(FlutterMethodNotImplemented) | ||
| return | ||
| } | ||
| self?.dateLabel.text = text | ||
| result(nil) | ||
| case "setBrightness": | ||
| self?.applyBrightness(from: call.arguments) | ||
| result(nil) | ||
| default: | ||
| result(FlutterMethodNotImplemented) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func view() -> UIView { | ||
| glassView | ||
| } | ||
|
|
||
| private func applyBrightness(from value: Any?) { | ||
| let interfaceStyle: UIUserInterfaceStyle = value as? String == "dark" ? .dark : .light | ||
| glassView.overrideUserInterfaceStyle = interfaceStyle | ||
| } | ||
|
|
||
| deinit { | ||
| channel.setMethodCallHandler(nil) | ||
| } | ||
| } |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.