-
Notifications
You must be signed in to change notification settings - Fork 12
/
avatar_widget.dart
73 lines (71 loc) · 3.05 KB
/
avatar_widget.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import 'package:flutter/material.dart';
import 'package:notredame/features/ets/events/author/author_info_skeleton.dart';
import 'package:notredame/features/ets/events/author/author_viewmodel.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:stacked/stacked.dart';
class AvatarWidget extends ViewModelWidget<AuthorViewModel> {
const AvatarWidget({super.key});
@override
Widget build(BuildContext context, AuthorViewModel model) {
return model.isBusy
? AvatarSkeleton()
: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 16),
child: SizedBox(
width: 120,
height: 120,
child: Hero(
tag: 'news_author_avatar',
child: CircleAvatar(
backgroundColor: Utils.getColorByBrightness(context,
AppTheme.lightThemeAccent, AppTheme.darkThemeAccent),
child: Stack(
fit: StackFit.expand,
children: [
if (model.author?.avatarUrl != null &&
model.author!.avatarUrl != "")
ClipRRect(
borderRadius: BorderRadius.circular(120),
child: Image.network(
model.author!.avatarUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Center(
child: Text(
model.author?.organization
?.substring(0, 1) ??
'',
style: TextStyle(
fontSize: 56,
color: Utils.getColorByBrightness(
context,
Colors.black,
Colors.white)),
),
);
},
),
),
if (model.author?.avatarUrl == null ||
model.author!.avatarUrl == "")
Center(
child: Text(
model.author?.organization?.substring(0, 1) ?? '',
style: TextStyle(
fontSize: 56,
color: Utils.getColorByBrightness(
context, Colors.black, Colors.white)),
),
),
],
),
),
),
),
),
);
}
}