feat: Implement linux desktop notifications
This commit is contained in:
parent
dfbb2fb0bf
commit
6f29f1d6fa
9 changed files with 106 additions and 95 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/string_color.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -28,31 +27,49 @@ class Avatar extends StatelessWidget {
|
|||
Matrix.of(context).client,
|
||||
width: size * MediaQuery.of(context).devicePixelRatio,
|
||||
height: size * MediaQuery.of(context).devicePixelRatio,
|
||||
method: ThumbnailMethod.scale,
|
||||
);
|
||||
final src = thumbnail;
|
||||
var fallbackLetters = '@';
|
||||
if ((name?.length ?? 0) >= 2) {
|
||||
fallbackLetters = name.substring(0, 2);
|
||||
fallbackLetters = String.fromCharCodes(name.runes, 0, 2);
|
||||
} else if ((name?.length ?? 0) == 1) {
|
||||
fallbackLetters = name;
|
||||
}
|
||||
final textWidget = Center(
|
||||
child: Text(
|
||||
fallbackLetters,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
final noPic = mxContent == null || mxContent.toString().isEmpty;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: CircleAvatar(
|
||||
radius: size / 2,
|
||||
backgroundImage: !noPic
|
||||
? PlatformInfos.isBetaDesktop
|
||||
? NetworkImage(src)
|
||||
: CachedNetworkImageProvider(src)
|
||||
: null,
|
||||
backgroundColor: noPic
|
||||
? name?.lightColor ?? Theme.of(context).secondaryHeaderColor
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: noPic
|
||||
? Text(fallbackLetters, style: TextStyle(color: Colors.white))
|
||||
: null,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(size / 2),
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
color: noPic
|
||||
? name?.lightColor ?? Theme.of(context).secondaryHeaderColor
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: noPic
|
||||
? textWidget
|
||||
: CachedNetworkImage(
|
||||
imageUrl: src,
|
||||
fit: BoxFit.cover,
|
||||
width: size,
|
||||
height: size,
|
||||
placeholder: (c, s) => Stack(
|
||||
children: [
|
||||
Center(child: CircularProgressIndicator(strokeWidth: 2)),
|
||||
textWidget,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue