Initial commit
This commit is contained in:
commit
b5f2ecd56f
96 changed files with 4522 additions and 0 deletions
39
lib/components/avatar.dart
Normal file
39
lib/components/avatar.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'matrix.dart';
|
||||
|
||||
class Avatar extends StatelessWidget {
|
||||
final MxContent mxContent;
|
||||
final double size;
|
||||
|
||||
const Avatar(this.mxContent, {this.size = 40, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String src = mxContent.getThumbnail(
|
||||
Matrix.of(context).client,
|
||||
width: size * MediaQuery.of(context).devicePixelRatio,
|
||||
height: size * MediaQuery.of(context).devicePixelRatio,
|
||||
method: ThumbnailMethod.scale,
|
||||
);
|
||||
return CircleAvatar(
|
||||
radius: size / 2,
|
||||
backgroundImage: mxContent.mxc?.isNotEmpty ?? false
|
||||
? kIsWeb
|
||||
? NetworkImage(
|
||||
src,
|
||||
)
|
||||
: CachedNetworkImageProvider(
|
||||
src,
|
||||
)
|
||||
: null,
|
||||
backgroundColor: Color(0xFFF8F8F8),
|
||||
child: mxContent.mxc.isEmpty
|
||||
? Text("@", style: TextStyle(color: Colors.blueGrey))
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue