Files
buzz/mobile/ios/Runner/NativePresenceMenu.swift
klopez4212 c8ea4fb4eb feat(mobile): polish Home navigation and Solo workspace (#8393)
## Summary
Polish mobile Home and Solo: group Search/Inbox beside a separate
profile avatar, move Inbox and Settings to bottom-up pages with Close
controls, and place tabs opposite the plus/compose action. Morph plus to
compose clockwise when entering Solo and reverse counterclockwise when
returning Home, with a directional quarter-turn of the icon inside a
level button and a subtle scale pulse, respecting reduced motion. Align
Search’s Close control with Inbox, simplify its placeholder, and
initialize selected filter contrast correctly. Collapse the plus menu
when leaving Home. Center Solo’s native-glass New chat empty state and
keep it stationary behind the keyboard.

Standardize Tabler icons and neutral backgrounds, retain SF Back/Close
on iOS, use native Liquid Glass headers, tab container, and actions
(solid grey selected tab, slightly darker on iOS) on iOS and black
actions on Android, and smooth the expanded menu corners. Repair native
header safe-area/return layout and compose movement after cancellation.

### Related issue
None found for this UI refinement; follows #8337.

### Testing
- Formatting, analysis, full mobile suite: 3,487 passed, 4 skipped; 3
push-configuration tests passed. File-size checks passed.
- Base UI built and installed on Pixel and iPhone in place. Pixel
navigation/New chat cancellation checked. Subsequent glass and rotation
refinements are previewed on iPhone; motion feel awaits human
confirmation.
- Draft pending human confirmation of the final Settings entrance/return
behavior on iPhone.

### Pixel snapshots
| Solo | Expanded actions |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/block/buzz/16dc0f8af971e63d788fee20974997fab925dec9/docs/screenshots/mobile-home-solo/pixel-solo.png"
width="280" alt="Solo empty state with New chat" /> | <img
src="https://raw.githubusercontent.com/block/buzz/16dc0f8af971e63d788fee20974997fab925dec9/docs/screenshots/mobile-home-solo/pixel-actions.png"
width="280" alt="Expanded channel actions with smooth corners" /> |

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-10-16 12:28:02 -04:00

80 lines
3.8 KiB
Swift

import Flutter
import UIKit
final class NativePresenceMenuFactory: 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 {
NativePresenceMenu(frame: frame, id: viewId, args: args, messenger: messenger)
}
}
private final class NativePresenceMenu: NSObject, FlutterPlatformView {
private let container: UIView
private let button = UIButton(type: .system)
private let channel: FlutterMethodChannel
init(frame: CGRect, id: Int64, args: Any?, messenger: FlutterBinaryMessenger) {
container = UIView(frame: frame)
channel = FlutterMethodChannel(name: "buzz/presence_menu/\(id)", binaryMessenger: messenger)
super.init()
container.backgroundColor = .clear
container.isOpaque = false
button.translatesAutoresizingMaskIntoConstraints = false
button.showsMenuAsPrimaryAction = true
container.addSubview(button)
NSLayoutConstraint.activate([
button.leadingAnchor.constraint(equalTo: container.leadingAnchor),
button.trailingAnchor.constraint(equalTo: container.trailingAnchor),
button.topAnchor.constraint(equalTo: container.topAnchor),
button.bottomAnchor.constraint(equalTo: container.bottomAnchor),
])
update(args as? [String: Any] ?? [:])
channel.setMethodCallHandler { [weak self] call, result in
guard call.method == "update", let data = call.arguments as? [String: Any] else {
result(FlutterMethodNotImplemented); return
}
self?.update(data)
result(nil)
}
}
func view() -> UIView { container }
private func update(_ data: [String: Any]) {
let presence = data["presence"] as? String ?? "offline"
let label = data["label"] as? String ?? "Offline"
container.overrideUserInterfaceStyle = data["dark"] as? Bool == true ? .dark : .light
var configuration = UIButton.Configuration.plain()
configuration.title = label
configuration.baseForegroundColor = Self.color(data["foreground"])
configuration.background.backgroundColor = Self.color(data["background"])
configuration.background.cornerRadius = 100
configuration.background.backgroundInsets = NSDirectionalEdgeInsets(top: 7, leading: 0, bottom: 7, trailing: 0)
configuration.contentInsets = NSDirectionalEdgeInsets(top: 7, leading: 12, bottom: 7, trailing: 12)
let fontSize = (data["fontSize"] as? NSNumber)?.doubleValue ?? 15
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
var attributes = incoming
attributes.font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
return attributes
}
button.configuration = configuration
button.accessibilityLabel = "Availability"
button.accessibilityValue = label
let options: [(String, String, UIColor)] = [("online", "Online", .systemGreen), ("away", "Away", .systemOrange), ("offline", "Offline", .systemGray)]
button.menu = UIMenu(children: options.map { value, title, color in
UIAction(title: title,
image: NativeTabler.image("circle.fill")?.withTintColor(color, renderingMode: .alwaysOriginal),
state: presence == value ? .on : .off
) { [weak self] _ in self?.channel.invokeMethod("selected", arguments: value) }
})
}
private static func color(_ value: Any?) -> UIColor {
let argb = (value as? NSNumber)?.uint32Value ?? 0
return UIColor(red: CGFloat((argb >> 16) & 255) / 255, green: CGFloat((argb >> 8) & 255) / 255,
blue: CGFloat(argb & 255) / 255, alpha: CGFloat((argb >> 24) & 255) / 255)
}
}