Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/ui/settings/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
suffix: const Icon(FIcons.externalLink),
onPress: _openAccountConsole,
),
FTile(
prefix: const Icon(FIcons.image),
title: const Text('Profile picture'),
subtitle: const Text('Upload or change your picture'),
suffix: const Icon(FIcons.externalLink),
onPress: _openProfilePicture,
),
],
),
const SizedBox(height: 20),
Expand Down Expand Up @@ -123,6 +130,25 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
}

/// Opens the Keycloak-served profile-picture upload page (`${authority}/avatar/ui`)
/// in the external browser. The page authenticates the user and uploads the image
/// to the avatar SPI, which the OIDC `picture` claim then carries into the app.
Future<void> _openProfilePicture() async {
Uri? url;
try {
final cfg = await OidcConfig.settings();
url = Uri.parse('${cfg.authority}/avatar/ui');
} catch (_) {
url = null;
}
if (!mounted) return;
if (url == null || !await launchUrl(url, mode: LaunchMode.externalApplication)) {
if (mounted) {
showFToast(context: context, title: const Text("Couldn't open the picture page"));
}
}
}

Future<void> _openServerDialog() async {
final changed = await showFDialog<bool>(
context: context,
Expand Down
Loading