Skip to content

Commit 74bd1f3

Browse files
klopez4212Terp
andcommitted
Refine avatar picker categories and rendering
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent f3b78d5 commit 74bd1f3

28 files changed

Lines changed: 415 additions & 405 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import '../../shared/agents/agent_avatar_catalog.dart';
2+
3+
/// One destination in the avatar category rail.
4+
class AgentAvatarCategory {
5+
const AgentAvatarCategory.pack(AgentAvatarPack value)
6+
: pack = value,
7+
_extra = 0;
8+
const AgentAvatarCategory._(this._extra) : pack = null;
9+
static const emoji = AgentAvatarCategory._(0);
10+
static const image = AgentAvatarCategory._(1);
11+
final AgentAvatarPack? pack;
12+
final int _extra;
13+
int get position => pack?.index ?? AgentAvatarPack.values.length + _extra;
14+
@override
15+
bool operator ==(Object other) =>
16+
other is AgentAvatarCategory &&
17+
pack == other.pack &&
18+
_extra == other._extra;
19+
@override
20+
int get hashCode => Object.hash(pack, _extra);
21+
}

‎mobile/lib/features/agents/agent_avatar_choices.dart‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import 'agent_character_artwork.dart';
21
import 'package:flutter/foundation.dart';
32
import 'package:flutter/material.dart';
43
import 'package:flutter/services.dart';
54
import 'package:flutter_hooks/flutter_hooks.dart';
65

76
import '../../shared/agents/agent_avatar_catalog.dart';
7+
import '../../shared/animated_avatar.dart';
88
import '../../shared/theme/theme.dart';
99
import '../../shared/widgets/ios_glass_navigation_button.dart';
10-
11-
import '../../shared/widgets/preset_agent_avatar.dart';
10+
import 'agent_avatar_category.dart';
11+
import 'agent_character_artwork.dart';
1212

1313
/// Fixed category rail height used to anchor the editor tray.
1414
const agentAvatarChoicesHeight = 92.0;
@@ -17,8 +17,7 @@ const agentAvatarChoicesHeight = 92.0;
1717
class AgentAvatarChoices extends HookWidget {
1818
const AgentAvatarChoices({
1919
super.key,
20-
required this.mode,
21-
required this.pack,
20+
required this.category,
2221
required this.examples,
2322
required this.emoji,
2423
required this.disabled,
@@ -27,8 +26,7 @@ class AgentAvatarChoices extends HookWidget {
2726
required this.onImage,
2827
});
2928

30-
final int mode;
31-
final AgentAvatarPack pack;
29+
final AgentAvatarCategory category;
3230
final Map<AgentAvatarPack, int> examples;
3331
final String emoji;
3432
final bool disabled;
@@ -42,7 +40,7 @@ class AgentAvatarChoices extends HookWidget {
4240
useEffect(() {
4341
WidgetsBinding.instance.addPostFrameCallback((_) {
4442
if (!controller.hasClients) return;
45-
final position = mode == 0 ? pack.index : mode + 3;
43+
final position = category.position;
4644
controller.jumpTo(
4745
(position * 84.0 - 84).clamp(
4846
0.0,
@@ -64,32 +62,30 @@ class AgentAvatarChoices extends HookWidget {
6462
for (final item in AgentAvatarPack.values)
6563
_Choice(
6664
label: item.label,
67-
selected: mode == 0 && pack == item,
65+
selected: category.pack == item,
6866
onTap: disabled ? null : () => onPack(item),
6967
child: AgentCharacterAlignment(
7068
url: agentAvatarCatalog[examples[item]!].url,
7169
scale: 0.85,
72-
child: PresetAgentAvatar(
73-
imageUrl: agentAvatarCatalog[examples[item]!].url,
74-
size: 60,
75-
posterPlaceholder: characterPoster(
70+
child: Transform.scale(
71+
scale: animatedAvatarArtworkScale,
72+
child: characterPoster(
7673
agentAvatarCatalog[examples[item]!].url,
7774
),
78-
fallback: const Icon(Icons.smart_toy_outlined),
7975
),
8076
),
8177
),
8278
_Choice(
8379
label: 'Emoji',
84-
selected: mode == 1,
80+
selected: category == AgentAvatarCategory.emoji,
8581
onTap: disabled ? null : onEmoji,
8682
child: Center(
8783
child: Text(emoji, style: const TextStyle(fontSize: 32)),
8884
),
8985
),
9086
_Choice(
9187
label: 'Image',
92-
selected: mode == 2,
88+
selected: category == AgentAvatarCategory.image,
9389
onTap: disabled ? null : onImage,
9490
child: const Icon(Icons.image_outlined, size: 28),
9591
),

‎mobile/lib/features/agents/agent_avatar_editor_page.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';
44
import '../../shared/theme/theme.dart';
55
import '../../shared/widgets/frosted_app_bar.dart';
66
import '../../shared/widgets/frosted_scaffold.dart';
7-
import 'agent_avatar_picker.dart';
87
import 'agent_avatar_choices.dart';
8+
import 'agent_avatar_geometry.dart';
9+
import 'agent_avatar_picker.dart';
910

1011
/// Edits an avatar locally; Cancel leaves the creation draft unchanged.
1112
class AgentAvatarEditorPage extends HookWidget {
@@ -74,7 +75,7 @@ class AgentAvatarEditorPage extends HookWidget {
7475
(constraints.maxHeight -
7576
agentAvatarChoicesHeight -
7677
Grid.sm -
77-
228)
78+
agentAvatarPreviewSpace)
7879
.clamp(180, double.infinity),
7980
selection: selection.value,
8081
heroTag: heroTag,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'dart:math' as math;
2+
3+
import 'package:flutter/material.dart';
4+
5+
import '../../shared/theme/theme.dart';
6+
7+
/// Space reserved below previews for the filmstrip.
8+
const agentAvatarTraySpace = 115.0;
9+
10+
/// Preview space added above the editor controls.
11+
const agentAvatarPreviewSpace = 228.0;
12+
13+
/// Maximum character preview size.
14+
const agentAvatarMaxPreviewSize = 440.0;
15+
16+
/// Asset padding compensation shared by previews and Hero flights.
17+
double agentCharacterOffset(String? url, {double scale = 1}) =>
18+
url?.contains('/buzzies/') == true ? -0.084 * scale : 0;
19+
20+
/// Shrinks only items near clipped filmstrip edges.
21+
double agentFilmstripScale({
22+
required int index,
23+
required int count,
24+
required double extent,
25+
required double width,
26+
required double offset,
27+
required bool reduceMotion,
28+
}) {
29+
if (reduceMotion) return 1;
30+
final center = Grid.xxs + index * extent + extent / 2 - offset;
31+
final maxScroll = math.max(0.0, count * extent + Grid.xxs * 2 - width);
32+
final distance = math.min(
33+
center + math.max(0.0, 72 - offset),
34+
width - center + math.max(0.0, 72 - (maxScroll - offset)),
35+
);
36+
return 0.65 +
37+
0.35 * Curves.easeInOut.transform((distance / 72).clamp(0.0, 1.0));
38+
}

0 commit comments

Comments
 (0)