mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
## Summary - Polish mobile Home, Activity, Search, and Settings navigation chrome. - Add progressive Buzz gradients/frost, aligned theme colors, dividers, typography, and section spacing. - Refine Search and Settings motion, including automatic keyboard focus on search activation. <img width="630" height="1368" alt="C78FA3CE-F2B3-45F2-B9F5-7EA7500778CC" src="https://github.com/user-attachments/assets/5935514b-d894-4010-80dd-a938363fee93" /> <img width="630" height="1368" alt="5C058A73-1879-476A-881C-531ACC256D84" src="https://github.com/user-attachments/assets/5266c841-17ee-49e8-9841-b06d84f4195f" /> <img width="630" height="1368" alt="3F50ADB7-9BDA-4A8D-A81E-20560C3B9EA6" src="https://github.com/user-attachments/assets/f615f61e-9e96-4bce-b261-ae5ec54db872" /> <img width="630" height="1368" alt="35ECE741-01F3-4B79-80C5-1DDD447121A7" src="https://github.com/user-attachments/assets/b5145186-9884-44eb-8ebc-f3303831c0a4" /> ## Validation - `flutter analyze` - Focused Home, Activity, Channels, Search, theme, and footer widget tests - Full pre-push checks, including mobile tests, desktop checks, and Tauri checks - On-device iPhone review during the visual polish pass --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: npub1glqcqfjxdens59scl477pmejh8lht4hqkhx0y4w38jxr6e6w6y2sm29y4e <47c18026466e670a1618fd7de0ef32b9ff75d6e0b5ccf255d13c8c3d674ed115@buzz.block.builderlab.xyz> Signed-off-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Co-authored-by: npub1glqcqfjxdens59scl477pmejh8lht4hqkhx0y4w38jxr6e6w6y2sm29y4e <47c18026466e670a1618fd7de0ef32b9ff75d6e0b5ccf255d13c8c3d674ed115@buzz.block.builderlab.xyz> Co-authored-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz>
111 lines
3.3 KiB
Dart
111 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import '../../shared/theme/theme.dart';
|
|
import '../../shared/widgets/avatar_image.dart';
|
|
import '../../shared/widgets/masked_avatar_badge.dart';
|
|
import 'profile_provider.dart';
|
|
import 'user_profile.dart';
|
|
|
|
/// Matches desktop's sidebar profile card, whose avatar is 32px.
|
|
const _defaultAvatarSize = 32.0;
|
|
|
|
/// The visible dot is smaller than the notch it sits in, so a ring of
|
|
/// background separates it from the avatar. Desktop's `h-2 w-2` dot inside a
|
|
/// `h-3.5 w-3.5` badge frame.
|
|
const _presenceDotRatio = 8 / 14;
|
|
|
|
/// User avatar with a presence dot indicator, for use in the app bar.
|
|
///
|
|
/// The dot sits in a notch masked out of the avatar rather than overlapping it,
|
|
/// the same treatment desktop's `SidebarProfileCard` uses — so it needs no
|
|
/// background-coloured ring, and reads correctly over the themed top section.
|
|
class ProfileAvatar extends ConsumerWidget {
|
|
final VoidCallback? onTap;
|
|
final bool showPresence;
|
|
|
|
/// The avatar diameter in logical pixels; defaults to the 32px desktop match.
|
|
final double size;
|
|
|
|
const ProfileAvatar({
|
|
super.key,
|
|
this.onTap,
|
|
this.showPresence = true,
|
|
this.size = _defaultAvatarSize,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final profileAsync = ref.watch(profileProvider);
|
|
final presenceAsync = ref.watch(presenceProvider);
|
|
final presence = presenceAsync.when(
|
|
data: (v) => v,
|
|
loading: () => 'online',
|
|
error: (_, _) => 'offline',
|
|
);
|
|
|
|
return profileAsync.when(
|
|
loading: () => _buildPlaceholder(context),
|
|
error: (_, _) => _buildAvatar(context, null, presence),
|
|
data: (profile) => _buildAvatar(context, profile, presence),
|
|
);
|
|
}
|
|
|
|
Widget _buildPlaceholder(BuildContext context) {
|
|
return CircleAvatar(
|
|
radius: size / 2,
|
|
backgroundColor: context.colors.primaryContainer,
|
|
);
|
|
}
|
|
|
|
Widget _buildAvatar(
|
|
BuildContext context,
|
|
UserProfile? profile,
|
|
String presence,
|
|
) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: MaskedAvatarBadge(
|
|
size: size,
|
|
geometry: AvatarBadgeMaskGeometry.presenceDot,
|
|
avatar: ClipOval(
|
|
child: ColoredBox(
|
|
color: context.colors.primaryContainer,
|
|
child: AvatarImageContent(
|
|
imageUrl: profile?.avatarUrl,
|
|
fallback: Text(
|
|
profile?.initial ?? '?',
|
|
style: context.textTheme.labelMedium?.copyWith(
|
|
color: context.colors.onPrimaryContainer,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
badge: showPresence
|
|
? Center(
|
|
child: FractionallySizedBox(
|
|
widthFactor: _presenceDotRatio,
|
|
heightFactor: _presenceDotRatio,
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: _presenceColor(context, presence),
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: null,
|
|
),
|
|
);
|
|
}
|
|
|
|
Color _presenceColor(BuildContext context, String presence) {
|
|
return switch (presence) {
|
|
'online' => context.appColors.success,
|
|
'away' => context.appColors.warning,
|
|
_ => context.colors.outline,
|
|
};
|
|
}
|
|
}
|