Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added assets/images/avatar_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/image_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/core/constants/app_assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ abstract final class AppAssets {
static const imageFigure = 'figure';
static const imageLine = 'line';
static const imageLineVariant = 'line_variant';
static const imagePlaceholder = 'assets/images/image_placeholder.png';
static const avatarPlaceholder = 'assets/images/avatar_placeholder.png';

// Legal documents.
static const legalPrivacyPolicy = 'assets/legal/privacy_policy.txt';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import '../../../../../uikit/buttons/button_state.dart';
import '../../../../../uikit/buttons/main_button.dart';
import '../../../../../uikit/buttons/secondary_button.dart';
import '../../../../../uikit/dialogs/app_feedback_dialog.dart';
import '../../../../../uikit/images/network_image_widget.dart';
import '../../../../../uikit/themes/colors/app_color_theme.dart';
import '../../../../../uikit/themes/text/app_text_theme.dart';
import '../../../auth/domain/entities/user.dart';
import '../../../auth/presentation/validators/auth_validators.dart';
import '../../../auth/presentation/widgets/auth_text_field.dart';
import '../../domain/repositories/profile_repository.dart';
import '../cubits/update_profile_cubit.dart';
import 'profile_avatar_image.dart';
import 'profile_dialog_shell.dart';

/// Opens the edit-profile dialog and returns the refreshed user on success.
Expand Down Expand Up @@ -251,7 +251,7 @@ final class _AvatarPreview extends StatelessWidget {
fit: BoxFit.cover,
);
}
return NetworkImageWidget(
return ProfileAvatarImage(
imageUrl: imageUrl ?? '',
height: 296,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

import '../../../../../core/constants/app_assets.dart';

/// Profile-local network image widget with avatar-specific fallback artwork.
class ProfileAvatarImage extends StatelessWidget {
/// Remote image URL.
final String imageUrl;

/// Height.
final double height;

/// Optional width.
final double? width;

/// Fit.
final BoxFit fit;

/// Creates an instance of [ProfileAvatarImage].
const ProfileAvatarImage({
required this.imageUrl,
required this.height,
this.width,
this.fit = BoxFit.cover,
super.key,
});

@override
Widget build(BuildContext context) {
return CachedNetworkImage(
imageUrl: imageUrl,
height: height,
width: width,
fit: fit,
placeholder: (_, _) => _ProfileAvatarPlaceholder(
height: height,
width: width,
fit: fit,
),
errorWidget: (_, _, _) => _ProfileAvatarPlaceholder(
height: height,
width: width,
fit: fit,
),
);
}
}

final class _ProfileAvatarPlaceholder extends StatelessWidget {
final double height;
final double? width;
final BoxFit fit;

const _ProfileAvatarPlaceholder({
required this.height,
required this.width,
required this.fit,
});

@override
Widget build(BuildContext context) {
return Image.asset(
AppAssets.avatarPlaceholder,
height: height,
width: width,
fit: fit,
errorBuilder: (_, _, _) => const Center(
child: Icon(
Icons.image_not_supported_outlined,
size: 32,
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import '../../../../../core/constants/app_strings.dart';
import '../../../../../uikit/buttons/main_button.dart';
import '../../../../../uikit/buttons/secondary_button.dart';
import '../../../../../uikit/cards/app_card.dart';
import '../../../../../uikit/images/network_image_widget.dart';
import '../../../../../uikit/themes/colors/app_color_theme.dart';
import '../../../../../uikit/themes/text/app_text_theme.dart';
import '../../../auth/domain/entities/user.dart';
import 'profile_avatar_image.dart';

/// The first profile section with the basic authenticated user data.
class UserSectionWidget extends StatelessWidget {
Expand Down Expand Up @@ -42,7 +42,7 @@ class UserSectionWidget extends StatelessWidget {
child: ClipOval(
child: SizedBox.square(
dimension: 140,
child: NetworkImageWidget(
child: ProfileAvatarImage(
imageUrl: user.avatar ?? '',
height: 140,
),
Expand Down
18 changes: 8 additions & 10 deletions lib/uikit/images/network_image_widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

import '../themes/colors/app_color_theme.dart';
import '../../core/constants/app_assets.dart';

/// Widget for displaying cached network images.
class NetworkImageWidget extends StatelessWidget {
Expand All @@ -26,26 +26,24 @@ class NetworkImageWidget extends StatelessWidget {
imageUrl: imageUrl,
fit: BoxFit.cover,
placeholder: (_, _) => const _ImagePlaceholder(),
errorWidget: (_, _, _) => const _ImagePlaceholder(
icon: Icons.image_not_supported_outlined,
),
errorWidget: (_, _, _) => const _ImagePlaceholder(),
),
);
}
}

class _ImagePlaceholder extends StatelessWidget {
final IconData icon;
const _ImagePlaceholder({this.icon = Icons.image_outlined});
const _ImagePlaceholder();

@override
Widget build(BuildContext context) {
return SizedBox(
child: Center(
return Image.asset(
AppAssets.imagePlaceholder,
fit: BoxFit.cover,
errorBuilder: (_, _, _) => const Center(
child: Icon(
icon,
Icons.image_not_supported_outlined,
size: 64,
color: AppColorTheme.of(context).disabled,
),
),
);
Expand Down
Loading