Skip to content

Commit 6f52377

Browse files
klopez4212Terp
andcommitted
feat(mobile): add Buzzies and refresh agent avatar picker
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent d342cf1 commit 6f52377

34 files changed

Lines changed: 2416 additions & 522 deletions

‎mobile/android/app/src/main/kotlin/xyz/block/buzz/mobile/TransparentAvatarView.kt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ private class TransparentAvatarView(
6868
channel.setMethodCallHandler { call, result ->
6969
if (!valid) {
7070
result.error("unsupported_avatar", "The avatar is not a bundled HTTPS WebM.", null)
71+
} else if (call.method == "isReady") {
72+
webView.evaluateJavascript(
73+
"(function(){var v=document.getElementById('avatar');return !!v && v.dataset.ready==='true';})()",
74+
) { value -> result.success(value == "true") }
7175
} else if (call.method == "setPlaying") {
7276
playing = call.arguments == true
7377
updatePlayback()
@@ -84,7 +88,7 @@ private class TransparentAvatarView(
8488
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
8589
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https://dwwgwmfqqjotj.cloudfront.net; media-src https://dwwgwmfqqjotj.cloudfront.net; style-src 'unsafe-inline'; script-src 'unsafe-inline'">
8690
<style>html,body{margin:0;width:100%;height:100%;overflow:hidden;background:transparent}video{width:100%;height:100%;object-fit:contain;pointer-events:none}</style>
87-
</head><body><video id="avatar" muted loop playsinline preload="auto" poster="$poster" src="$url"></video></body></html>""",
91+
</head><body><video id="avatar" muted loop playsinline preload="auto" poster="$poster" src="$url"></video><script>document.getElementById('avatar').requestVideoFrameCallback(function(){document.getElementById('avatar').dataset.ready='true';});</script></body></html>""",
8892
"text/html", "UTF-8", null,
8993
)
9094
}

‎mobile/ios/Runner/ConcentricSheetSurface.swift‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ final class ConcentricSheetSurfacePlatformView: NSObject, FlutterPlatformView {
8282
glassTintColorValue: (arguments?["glassTintColor"] as? NSNumber)?.uint32Value
8383
)
8484
applyInterfaceStyle(from: arguments?["brightness"])
85-
applyCornerConfiguration(minimumRadius: minimumRadius)
85+
applyCornerConfiguration(minimumRadius: minimumRadius, capsule: arguments?["capsule"] as? Bool == true)
8686

8787
channel.setMethodCallHandler { [weak self] call, result in
8888
guard let self else {
@@ -127,7 +127,8 @@ final class ConcentricSheetSurfacePlatformView: NSObject, FlutterPlatformView {
127127
}
128128
self.applyInterfaceStyle(from: arguments["brightness"])
129129
self.applyCornerConfiguration(
130-
minimumRadius: minimumRadius.doubleValue
130+
minimumRadius: minimumRadius.doubleValue,
131+
capsule: arguments["capsule"] as? Bool == true
131132
)
132133
result(nil)
133134
default:
@@ -164,8 +165,12 @@ final class ConcentricSheetSurfacePlatformView: NSObject, FlutterPlatformView {
164165
rootView.backgroundColor = backdropColorValue.map { Self.color(from: $0) } ?? .clear
165166
}
166167

167-
private func applyCornerConfiguration(minimumRadius: CGFloat) {
168+
private func applyCornerConfiguration(minimumRadius: CGFloat, capsule: Bool) {
168169
if #available(iOS 26.0, *) {
170+
if capsule {
171+
surfaceView.cornerConfiguration = .capsule()
172+
return
173+
}
169174
let radius = UICornerRadius.containerConcentric(minimum: minimumRadius)
170175
surfaceView.cornerConfiguration =
171176
corners == "bottom"

‎mobile/ios/Runner/JumpToLatestGlassButton.swift‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ final class NavigationGlassButton: UIButton {
4646
var menuVisibilityChanged: ((Bool) -> Void)?
4747
var animateMenu: ((Bool, UIContextMenuInteractionAnimating?) -> Void)?
4848
weak var glassPreview: UIView?
49+
var onHighlightChanged: ((Bool) -> Void)?
50+
51+
override var isHighlighted: Bool {
52+
didSet {
53+
if oldValue != isHighlighted { onHighlightChanged?(isHighlighted) }
54+
}
55+
}
4956

5057
override func contextMenuInteraction(
5158
_ interaction: UIContextMenuInteraction,
@@ -266,6 +273,9 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
266273
if arguments?["plain"] as? Bool == true || arguments?["mergingNavigation"] as? Bool == true { configuration = .plain() }
267274
configuration.cornerStyle = .capsule
268275
button.configuration = configuration
276+
button.onHighlightChanged = { [weak self] highlighted in
277+
self?.channel.invokeMethod("highlighted", arguments: highlighted)
278+
}
269279
applyContent(from: arguments)
270280
button.titleLabel?.numberOfLines = 1
271281
button.titleLabel?.lineBreakMode = .byClipping
@@ -275,6 +285,7 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
275285
bottom: max(0, (hitTargetHeight - controlSize) / 2),
276286
right: max(0, hitTargetWidth - buttonCenterX - controlWidth / 2)
277287
)
288+
containerView.accessibilityElementsHidden = arguments?["accessibilityHidden"] as? Bool ?? false
278289
button.accessibilityLabel = arguments?["accessibilityLabel"] as? String ?? "Back"
279290
button.translatesAutoresizingMaskIntoConstraints = false
280291
button.addAction(
@@ -311,6 +322,11 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
311322

312323
applyAppearance(from: args)
313324
channel.setMethodCallHandler { [weak self] call, result in
325+
if call.method == "setArtworkPressed" {
326+
self?.button.isHighlighted = call.arguments as? Bool ?? false
327+
result(nil)
328+
return
329+
}
314330
if call.method == "setContent" {
315331
self?.setContent(from: call.arguments)
316332
result(nil)
@@ -426,10 +442,10 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
426442
containerView.overrideUserInterfaceStyle = interfaceStyle
427443
button.overrideUserInterfaceStyle = interfaceStyle
428444
button.isEnabled = enabled
429-
button.isSelected = selected
445+
button.isSelected = selected && (arguments?["tintsSelection"] as? Bool ?? true)
430446
// Resolve label contrast explicitly on the first selected frame as well as
431447
// later selections; UIKit may retain the initial glass title foreground.
432-
labelForegroundColor = selected
448+
labelForegroundColor = button.isSelected
433449
? (interfaceStyle == .dark ? .black : .white)
434450
: foregroundColor
435451
isBusy = busy

‎mobile/ios/Runner/NativeEmojiPicker.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ final class NativeEmojiPickerCoordinator: NSObject,
8787
let content = NativeEmojiPickerView(
8888
data: data,
8989
appearance: appearance,
90+
largeEmoji: arguments["largeEmoji"] as? Bool ?? false,
9091
initialSkinTone: (arguments["skinTone"] as? NSNumber)?.intValue ?? 0,
9192
onSelect: { [weak self] emoji in self?.select(emoji) },
9293
onSkinToneChanged: { [weak self] value in

‎mobile/ios/Runner/NativeEmojiPickerView.swift‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import UIKit
55
struct NativeEmojiPickerView: View {
66
let data: NativeEmojiPickerData
77
let appearance: NativeEmojiPickerAppearance
8+
let largeEmoji: Bool
89
let onSelect: (String) -> Void
910
let onSkinToneChanged: (Int) -> Void
1011
let onClose: () -> Void
@@ -13,23 +14,27 @@ struct NativeEmojiPickerView: View {
1314
@State private var categorySelection: NativeEmojiCategorySelection
1415
@State private var selectedSkinTone: Int
1516

16-
private let columns = Array(
17-
repeating: GridItem(.flexible(minimum: 36), spacing: 0),
18-
count: 8
19-
)
17+
private var columns: [GridItem] {
18+
Array(
19+
repeating: GridItem(.flexible(minimum: 36), spacing: 0),
20+
count: largeEmoji ? 5 : 8
21+
)
22+
}
2023

2124
private let sectionListSpace = "buzz.emoji.sectionList"
2225

2326
init(
2427
data: NativeEmojiPickerData,
2528
appearance: NativeEmojiPickerAppearance,
29+
largeEmoji: Bool = false,
2630
initialSkinTone: Int,
2731
onSelect: @escaping (String) -> Void,
2832
onSkinToneChanged: @escaping (Int) -> Void,
2933
onClose: @escaping () -> Void
3034
) {
3135
self.data = data
3236
self.appearance = appearance
37+
self.largeEmoji = largeEmoji
3338
self.onSelect = onSelect
3439
self.onSkinToneChanged = onSkinToneChanged
3540
self.onClose = onClose
@@ -347,13 +352,13 @@ struct NativeEmojiPickerView: View {
347352
url: url,
348353
fallbackColor: appearance.secondaryText
349354
)
350-
.frame(width: 28, height: 28)
355+
.frame(width: largeEmoji ? 48 : 28, height: largeEmoji ? 48 : 28)
351356
} else {
352-
Text(value).font(.system(size: 28))
357+
Text(value).font(.system(size: largeEmoji ? 48 : 28))
353358
}
354359
}
355360
.frame(maxWidth: .infinity)
356-
.frame(height: 44)
361+
.frame(height: largeEmoji ? 60 : 44)
357362
.contentShape(Rectangle())
358363
}
359364
.buttonStyle(.plain)

‎mobile/ios/Runner/NativeTabler.swift‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum NativeTabler {
1616
}()
1717

1818
static func image(_ symbol: String, size: CGFloat = 20) -> UIImage? {
19+
if symbol == "agent" { return agentImage(size: size) }
1920
guard let code = glyphs[symbol], let scalar = UnicodeScalar(code),
2021
let name = fontName, let font = UIFont(name: name, size: size) else {
2122
assertionFailure("Missing Tabler icon: \(symbol)")
@@ -29,6 +30,33 @@ enum NativeTabler {
2930
}.withRenderingMode(.alwaysTemplate)
3031
}
3132

33+
/// Matches Flutter's AgentNavigationIcon and the desktop agent mark.
34+
private static func agentImage(size: CGFloat) -> UIImage {
35+
UIGraphicsImageRenderer(size: CGSize(width: size, height: size)).image { renderer in
36+
renderer.cgContext.scaleBy(x: size / 24, y: size / 24)
37+
UIColor.black.setStroke()
38+
UIColor.black.setFill()
39+
let head = UIBezierPath(roundedRect: CGRect(x: 4.75, y: 7, width: 14.5, height: 13.25), cornerRadius: 4.5)
40+
head.lineWidth = 2
41+
head.stroke()
42+
let lines = UIBezierPath()
43+
lines.lineWidth = 2
44+
lines.lineCapStyle = .round
45+
for (start, end) in [
46+
(CGPoint(x: 12, y: 7), CGPoint(x: 12, y: 2.5)),
47+
(CGPoint(x: 3.25, y: 11.5), CGPoint(x: 3.25, y: 15.75)),
48+
(CGPoint(x: 20.75, y: 11.5), CGPoint(x: 20.75, y: 15.75))
49+
] {
50+
lines.move(to: start)
51+
lines.addLine(to: end)
52+
}
53+
lines.stroke()
54+
for x in [9.0, 15.0] {
55+
UIBezierPath(ovalIn: CGRect(x: x - 1.4, y: 11.85, width: 2.8, height: 2.8)).fill()
56+
}
57+
}.withRenderingMode(.alwaysTemplate)
58+
}
59+
3260
private static let glyphs: [String: UInt32] = [
3361
"arrow.down": 0xea16, // arrow-down
3462
"xmark": 0xeb55, // x

0 commit comments

Comments
 (0)