fix: default icon for user avatar

This commit is contained in:
appflowy 2022-08-12 19:19:19 +08:00
parent 435d1b8354
commit 4488247fb1
2 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
import 'package:app_flowy/workspace/presentation/settings/settings_dialog.dart';
import 'package:app_flowy/workspace/presentation/settings/widgets/settings_user_view.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra/theme.dart';
@ -41,6 +42,9 @@ class MenuUser extends StatelessWidget {
Widget _renderAvatar(BuildContext context) {
String iconUrl = context.read<MenuUserBloc>().state.userProfile.iconUrl;
if (iconUrl.isEmpty) {
iconUrl = defaultUserAvatar;
}
return SizedBox(
width: 25,

View File

@ -8,6 +8,8 @@ import 'package:flowy_infra/image.dart';
import 'dart:convert';
const defaultUserAvatar = '1F600';
class SettingsUserView extends StatelessWidget {
final UserProfilePB user;
SettingsUserView(this.user, {Key? key}) : super(key: ValueKey(user.id));
@ -40,6 +42,9 @@ class SettingsUserView extends StatelessWidget {
Widget _renderCurrentIcon(BuildContext context) {
String iconUrl =
context.read<SettingsUserViewBloc>().state.userProfile.iconUrl;
if (iconUrl.isEmpty) {
iconUrl = defaultUserAvatar;
}
return _CurrentIcon(iconUrl);
}
}