@@ -21,6 +21,12 @@ abstract class SBUStatelessComponent extends StatelessWidget
2121 const SBUStatelessComponent ({super .key});
2222}
2323
24+ enum SBUFileType {
25+ image,
26+ video,
27+ other,
28+ }
29+
2430mixin SBUBaseComponent {
2531 // Name
2632 String getGroupChannelName (GroupChannel channel, SBUStrings strings) {
@@ -60,6 +66,21 @@ mixin SBUBaseComponent {
6066 return nickname;
6167 }
6268
69+ String getNicknameOrYou (User ? user, SBUStrings strings) {
70+ String result = '' ;
71+ if (user != null ) {
72+ if (user.userId.isNotEmpty &&
73+ user.userId == SendbirdChat .currentUser? .userId) {
74+ return strings.you;
75+ }
76+
77+ if (user.nickname.isNotEmpty) {
78+ result = user.nickname;
79+ }
80+ }
81+ return result;
82+ }
83+
6384 List <User > sortUsersByNickname (List <User > users) {
6485 final sortedMembers = List .of (users);
6586 sortedMembers.sort ((a, b) {
@@ -223,23 +244,28 @@ mixin SBUBaseComponent {
223244 return null ;
224245 }
225246
226- bool isImage (String ? fileName) {
227- // Check
228- if (fileName != null && fileName.isNotEmpty) {
229- final splitFileName = fileName.split ('.' );
230- if (splitFileName.length >= 2 ) {
231- final ext = splitFileName.last.toLowerCase ();
232- if (ext == 'png' || ext == 'jpg' || ext == 'jpeg' || ext == 'gif' ) {
233- return true ;
234- }
247+ SBUFileType getFileType (FileMessage message) {
248+ String ? mimeType = message.type;
249+ if (mimeType != null ) {
250+ if (mimeType.startsWith ('image' )) {
251+ return SBUFileType .image;
252+ } else if (mimeType.startsWith ('video' )) {
253+ return SBUFileType .video;
235254 }
236255 }
237- return false ;
256+ return SBUFileType .other;
257+ }
258+
259+ String ? getChannelCacheKey (BaseChannel ? channel) {
260+ if (channel != null ) {
261+ return channel.channelUrl; // Check
262+ }
263+ return null ;
238264 }
239265
240- String ? getImageCacheKey (BaseMessage ? message) {
266+ String ? getMessageCacheKey (BaseMessage ? message) {
241267 if (message != null ) {
242- return '${message .requestId }_${message .messageId }' ;
268+ return '${message .requestId }_${message .messageId }' ; // Check
243269 }
244270 return null ;
245271 }
@@ -372,6 +398,18 @@ mixin SBUBaseComponent {
372398 } catch (_) {}
373399 }
374400
401+ Size getThumbnailSize () {
402+ return const Size (600 , 600 ); // Check
403+ }
404+
405+ bool isReplyMessageToChannel (BaseMessage message) {
406+ return (message.isReplyToChannel && message.parentMessage != null );
407+ }
408+
409+ bool isReplyMessage (BaseMessage message) {
410+ return (! message.isReplyToChannel && message.parentMessage != null );
411+ }
412+
375413 // Test
376414 bool isThemeTestOn () {
377415 return false ;
0 commit comments