Files
noo/lib/widgets/profile_avatar_button.dart
ayushyaandClaude Opus 5.5 56784ef212 Rebuild UI on the Noo design system
Replaces the Material 3 screens with the Noo design system: warm
neutrals, one violet accent, pill controls, Schibsted Grotesk/
Instrument Sans, Lucide icons, no gradients/shadows.

- New lib/widgets/noo/ component kit (core, lists, files, media, nav,
  overlays) plus lib/theme/design_tokens.dart for the color/type/space/
  radius/motion tokens.
- Rebuilt the app shell (top/bottom bars, drawer, desktop sidebar and
  toolbar), every tab (Files/Offline, Photos, Favorites, Recent,
  Activity, Trash, Shares), Settings, the lock and login screens, the
  media viewer, search, the details/share sheets, and the share-upload
  and move/copy destination pickers.
- Added a design canvas (linked from DESIGN_SYSTEM.md) covering the
  screens the spec didn't already describe, with matching Android and
  iOS chrome; wrote up the approved recipes into DESIGN_SYSTEM.md §4.
- Removed now-dead legacy widgets (media_grid_tile, swipeable_item,
  sync_status_badge, selectable_thumbnail) and updated
  architecture.md/styling.md/standards.md to describe the new
  structure and component/testing conventions.
- Added widget tests for the noo/ component kit.

This is a UI-only rework: no provider/model/service behavior changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 01:51:58 -04:00

64 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import '../providers/session_controller.dart';
import '../views/account_view.dart';
import 'noo/core/noo_avatar.dart';
/// Top-bar avatar button that opens the account screen. Replaces the old
/// "Account" bottom-nav destination, matching how Google Drive surfaces
/// account access from a profile picture in the app bar. Also doubles as a
/// quick account switcher: swiping up/down on it cycles to the next/
/// previous saved account immediately, with no confirmation - a shortcut
/// alongside the full switcher list in Settings.
class ProfileAvatarButton extends StatelessWidget {
const ProfileAvatarButton({super.key});
Future<void> _handleVerticalSwipe(
BuildContext context,
DragEndDetails details,
) async {
final velocity = details.primaryVelocity ?? 0;
if (velocity.abs() < 250) return;
final provider = context.read<SessionController>();
final target = velocity < 0
? await provider.cycleToNextAccount()
: await provider.cycleToPreviousAccount();
if (target == null || !context.mounted) return;
HapticFeedback.selectionClick();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Switched to ${target.username}'),
behavior: SnackBarBehavior.floating,
),
);
}
@override
Widget build(BuildContext context) {
final provider = context.watch<SessionController>();
final initial = provider.username.isNotEmpty
? provider.username[0].toUpperCase()
: '?';
return Padding(
padding: const EdgeInsets.only(right: 8),
child: GestureDetector(
onVerticalDragEnd: (details) => _handleVerticalSwipe(context, details),
child: IconButton(
tooltip: 'Settings',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const AccountView()),
);
},
icon: NooAvatar(initials: initial, current: true, size: 32),
),
),
);
}
}