App lock (local_auth) gates the app behind the OS's biometric/device credential prompt via a new lock screen, layered on top of the existing Nextcloud session rather than replacing it. Multi-account support lets users save several Nextcloud logins and switch between them (AccountStore, per-account browsing prefs, avatar swipe-to- cycle); logout() now keeps an account's saved credentials/prefs intact so it can be resumed from a "Continue as..." list, while removeAccount() stays the only destructive path. The account settings screen is redesigned around a single profile card (avatar/name/email, server host, storage quota with groups) with Refresh Cache/Logout/Remove actions, replacing the old separate "Server Connection Info" section. Also fixes activity-tab timestamps: the OCS Activity API reports time as an ISO 8601 `datetime` string, not the numeric `timestamp` field the code incorrectly assumed, which made every activity render as Jan 1 1970. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
75 lines
2.4 KiB
Dart
75 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../providers/server_provider.dart';
|
|
import '../views/account_view.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<ServerProvider>();
|
|
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<ServerProvider>();
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
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: CircleAvatar(
|
|
radius: 17,
|
|
backgroundColor: colorScheme.primary,
|
|
child: Text(
|
|
initial,
|
|
style: TextStyle(
|
|
color: colorScheme.onPrimary,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|