forked from deniscolak/colorize-text-avatar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce AvatarOptions for simplifying APIs
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:acter_avatar/acter_avatar.dart'; | ||
|
||
/// Abstract class representing the set of avatars. | ||
abstract class AvatarOptions { | ||
AvatarInfo? get avatar; | ||
List<AvatarInfo>? get parentAvatars; | ||
double? get size; | ||
double? get parentSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:acter_avatar/src/models/avatar_info.dart'; | ||
import 'package:acter_avatar/src/models/avatar_options.dart'; | ||
|
||
/// Class representing avatar for Direct Message/Private Chat (DM). | ||
class DMAvatarOptions extends AvatarOptions { | ||
DMAvatarOptions({required this.dmAvatar, this.avatarSize}); | ||
@override | ||
AvatarInfo get avatar => dmAvatar; | ||
|
||
@override | ||
List<AvatarInfo>? get parentAvatars => null; | ||
|
||
@override | ||
double? get size => avatarSize ?? 24.0; | ||
|
||
@override | ||
double? get parentSize => null; | ||
|
||
final AvatarInfo dmAvatar; | ||
final double? avatarSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:acter_avatar/src/models/avatar_info.dart'; | ||
import 'package:acter_avatar/src/models/avatar_options.dart'; | ||
|
||
/// Class representing set of avatars for group chat/room. | ||
class GroupChatAvatarOptions extends AvatarOptions { | ||
GroupChatAvatarOptions({ | ||
required this.groupAvatar, | ||
required this.parentGroupAvatars, | ||
this.avatarSize, | ||
this.parentAvatarSize, | ||
}); | ||
|
||
@override | ||
AvatarInfo? get avatar => groupAvatar; | ||
|
||
@override | ||
List<AvatarInfo>? get parentAvatars => parentGroupAvatars; | ||
|
||
@override | ||
double? get size => avatarSize ?? 48.0; | ||
|
||
@override | ||
double? get parentSize => parentAvatarSize ?? 24.0; | ||
|
||
final AvatarInfo groupAvatar; | ||
final List<AvatarInfo> parentGroupAvatars; | ||
final double? avatarSize; | ||
final double? parentAvatarSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:acter_avatar/src/models/avatar_info.dart'; | ||
import 'package:acter_avatar/src/models/avatar_options.dart'; | ||
|
||
/// Class representing set of avatars for a group DM. | ||
class GroupDMAvatarOptions extends AvatarOptions { | ||
GroupDMAvatarOptions({ | ||
required this.groupAvatars, | ||
this.avatarSize, | ||
this.parentAvatarSize, | ||
}); | ||
|
||
@override | ||
AvatarInfo? get avatar => null; | ||
|
||
@override | ||
List<AvatarInfo> get parentAvatars => groupAvatars; | ||
|
||
@override | ||
double? get size => avatarSize ?? 48.0; | ||
|
||
@override | ||
double? get parentSize => parentAvatarSize ?? 24.0; | ||
|
||
final List<AvatarInfo> groupAvatars; | ||
final double? avatarSize; | ||
final double? parentAvatarSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:acter_avatar/src/models/avatar_info.dart'; | ||
import 'package:acter_avatar/src/models/avatar_options.dart'; | ||
|
||
/// Class representing set of avatars for a space. | ||
class SpaceAvatarOptions extends AvatarOptions { | ||
SpaceAvatarOptions(this.avatarSize, this.parentAvatarSize, | ||
{required this.spaceAvatar, this.parentSpaceAvatars}); | ||
|
||
@override | ||
AvatarInfo get avatar => spaceAvatar; | ||
|
||
@override | ||
List<AvatarInfo>? get parentAvatars => parentSpaceAvatars; | ||
|
||
@override | ||
double? get size => avatarSize ?? 48.0; | ||
|
||
@override | ||
double? get parentSize => parentAvatarSize ?? 24.0; | ||
|
||
final AvatarInfo spaceAvatar; | ||
final List<AvatarInfo>? parentSpaceAvatars; | ||
final double? avatarSize; | ||
final double? parentAvatarSize; | ||
} |