From a8193d37a564e073f0db9d2a3ca2e47ab602b228 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 18:46:05 +0500 Subject: [PATCH 01/10] update docs and package src --- README.md | 115 ++++++++++++-------------------- lib/src/acter_avatar.dart | 6 +- lib/src/models/avatar_info.dart | 16 ++--- 3 files changed, 54 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 161c027..063ab6a 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,69 @@ # Acter Avatar -Acter Avatar is a package to generate avatar for the acter platform. +Acter Avatar is a package to generate avatars for the acter platform. This package allows to generate different types of avatar(s), internally using combination of [Multiavatar](https://pub.dev/packages/multiavatar) and Textual Avatar mechanism to generate different shapes and stack like +avatars. # CI Test Status Build Status -## Progress +## Parameters of ActerAvatar: -- [x] `TextAvatars` based on text with custom color generator -- [-] Generic `ActerAvatar` with: - - [ ] automatic selection of shape & mode - - [ ] image loader - - [ ] optional border-support (with optional coloring support) - - [x] [multiavatar](https://pub.dev/packages/multiavatar) fallback support -- [ ] Generic `ActerAvatarPill` for inline displaying with: - - [ ] internal `ActerAvatar`, click-action +| Parameter | Description | Type | Default | +| :----------------- | :------------------------------------------------- | :------------------ | :------ | --------------------- | +| `mode` | enum for rendering avatar shape (required). | _enum_ | | | +| `size` | Size of Avatar (optional). | _double_ | | | +| `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | | | +| `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | | TooltipStyle.Combined | +| `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | | TooltipStyle.Combined | +| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | | | +| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | | | +| `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | | [] | +| `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | | | ---- +## AvatarInfo -## Components: +`AvatarInfo` class allows you to store avatar related data. See API documentation for reference. -TextAvatar can generate avatars based on any string. It generates the background and foreground color based on your input string and shows the avatar via the text initials. Enjoy it! +### Usage of ActerAvatar 😎 -![Acter Text Avatar](https://github.com/acterglobal/acter-avatar/raw/master/example/screenshots/img_4.png) - -## Getting Started 🔥 - -It is an easy and powerful package to generate text avatars for your users! - -Let's see how to generate an avatar easily! - -### Usage of Acter's Text Avatar 😎 - -Here is the only mandatory parameter is text. +`ActerAvatar` takes both `mode` and `avatarInfo` param to render avatar. The param `uniqueId` in `AvatarInfo` is required. ```dart -TextAvatar( - text: "Deniz Çolak", -) + ActerAvatar( + mode: DisplayMode.DM, + avatarInfo: AvatarInfo( + uniqueId: '@aliKah:lorem.org', + displayName: 'Ali Akalın', + avatar: NetworkImage(*someImageLink*)), // can be any image provider .i.e. AssetImage, MemoryImage and NetworkImage etc. + ), ``` -![Acter Text Avatar](https://github.com/acterglobal/acter-avatar/raw/master/example/screenshots/img_1.png) - -### Parameters of Text Avatar 😎 - -Here is the predefined shapes: Rectangle, Circular or None, if shape is null or not defined the default value similar with Rectangle but not same. - -> Shape.Rectangle, Shape.Circular, Shape.None can be use. +Alternatively you can also provide future avatar in `AvatarInfo` which will show fallback until loaded if data isn't readily available. ```dart -TextAvatar( - shape: Shape.Circular, - text: "Deniz Çolak" -) + ActerAvatar( + mode: DisplayMode.DM, + avatarInfo: AvatarInfo( + uniqueId: '@aliKah:lorem.org', + displayName: 'Ali Akalın', + avatarFuture: someFuture), // can be any image provider .i.e. AssetImage, MemoryImage and NetworkImage etc. + ), ``` -![Acter Text Avatar](https://github.com/acterglobal/acter-avatar/raw/master/example/screenshots/img_2.png) - -numberLetters parameter allows user to generate Avatar more specific number of character. - -> Developer can predefine `size` and `numberLetters`, if `numberLetters` is null or not defined the default value is `1`. - -```dart -TextAvatar( - shape: Shape.Rectangle, - size: 35, - numberLetters: 2, - -) -``` - -![Acter Text Avatar](https://github.com/acterglobal/acter-avatar/raw/master/example/screenshots/img_3.png) - -Other parameters can be change according to your specification. - -> Developers can extend the `TextAvatar` model according to their specification, currently below parameters are supported. +You can also provide list of `AvatarInfo` with `avatarsInfo` param for displaying parent badges and circular stacked avatars. ```dart -TextAvatar( - shape: Shape.Circular, - size: 35 - fontSize: 14, - fontWeight: FontWeight.w600, - upperCase: true, - colorMaker: ColorMaker.bold(), - colorGenerator: // custom ColorGenerator-function. colorMaker takes precedence - numberLetters: 1, - - text: this.widget.userdata.displayname, - sourceText: this.widget.userdata.username, -) + ActerAvatar( + mode: DisplayMode.Space, + avatarInfo: AvatarInfo( + uniqueId: '@aliKah:lorem.org', + displayName: 'Ali Akalın', + avatar: NetworkImage(*someImageLink*), + avatarInfo: [ + // more `AvatarInfo` here. + ]), + ), ``` ## Credits & License diff --git a/lib/src/acter_avatar.dart b/lib/src/acter_avatar.dart index 0cd391b..8f79943 100644 --- a/lib/src/acter_avatar.dart +++ b/lib/src/acter_avatar.dart @@ -84,7 +84,7 @@ class _ActerAvatar extends State { .addListener(secondaryListener); } } - } else if (widget.avatarInfo.imageProviderFuture != null) { + } else if (widget.avatarInfo.avatarFuture != null) { fetchImageProvider(listener); if (widget.avatarsInfo != null && widget.avatarsInfo!.isNotEmpty) { fetchSecondaryImageProvider(secondaryListener); @@ -93,13 +93,13 @@ class _ActerAvatar extends State { } void fetchImageProvider(ImageStreamListener listener) async { - var res = await widget.avatarInfo.imageProviderFuture!; + var res = await widget.avatarInfo.avatarFuture!; res!.resolve(ImageConfiguration()).addListener(listener); avatar = res; } void fetchSecondaryImageProvider(ImageStreamListener listener) async { - var res = await widget.avatarsInfo![0].imageProviderFuture!; + var res = await widget.avatarsInfo![0].avatarFuture!; res!.resolve(ImageConfiguration()).addListener(listener); secondaryAvatar = res; } diff --git a/lib/src/models/avatar_info.dart b/lib/src/models/avatar_info.dart index a255026..40a73d5 100644 --- a/lib/src/models/avatar_info.dart +++ b/lib/src/models/avatar_info.dart @@ -1,28 +1,26 @@ import 'package:flutter/material.dart'; class AvatarInfo { - /// the uniqueId of this object (e.g. full username or roomId) - /// used to calculate the Multiavatar in `DisplayMode.User`. + /// the uniqueId of avatar final String uniqueId; - /// the display name they've chosen + /// the display name they've chosen (optional) final String? displayName; - /// a canonical uniqueName to use instead of the uniqueId in the tooltip, if given. - /// most commonly this is the canonical alias for a space/room rather than the roomID + /// if given, acts as alias for avatar in tooltip rather than `uniqueId` final String? uniqueName; - /// The actual avatar (takes precedence) + /// The actual avatar image renderer (takes precedence over `imageProviderFuture`) final ImageProvider? avatar; - /// Or alternatively a future that loads the avatar (show fallback until loaded) - final Future?>? imageProviderFuture; + /// a future that loads the avatar (show fallback until loaded) + final Future?>? avatarFuture; const AvatarInfo({ required this.uniqueId, this.displayName, this.uniqueName, this.avatar, - this.imageProviderFuture, + this.avatarFuture, }); } From 2878cb01982ab455f46f928b80d4583860b29b1a Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:04:02 +0500 Subject: [PATCH 02/10] update readme.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 063ab6a..4fdfcd5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Acter Avatar -Acter Avatar is a package to generate avatars for the acter platform. This package allows to generate different types of avatar(s), internally using combination of [Multiavatar](https://pub.dev/packages/multiavatar) and Textual Avatar mechanism to generate different shapes and stack like -avatars. +Acter Avatar is a package to generate avatars for the acter platform. This package allows to generate different types and shapes of avatar(s), internally using combination of [Multiavatar](https://pub.dev/packages/multiavatar) and Textual Avatar mechanism. # CI Test Status From 3da0789664ef049b8056ad804bf412fdaa6ec7d8 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:19:40 +0500 Subject: [PATCH 03/10] update readme.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4fdfcd5..8207251 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Acter Avatar -Acter Avatar is a package to generate avatars for the acter platform. This package allows to generate different types and shapes of avatar(s), internally using combination of [Multiavatar](https://pub.dev/packages/multiavatar) and Textual Avatar mechanism. +Acter Avatar is a package to generate different shapes of avatars by leveraging the combination of [Multiavatar](https://pub.dev/packages/multiavatar) library and Textual Avatar mechanism. The package is a derivative work from [Acter a3](https://github.com/acterglobal/a3) ongoing development. # CI Test Status @@ -8,17 +8,17 @@ Acter Avatar is a package to generate avatars for the acter platform. This packa ## Parameters of ActerAvatar: -| Parameter | Description | Type | Default | -| :----------------- | :------------------------------------------------- | :------------------ | :------ | --------------------- | -| `mode` | enum for rendering avatar shape (required). | _enum_ | | | -| `size` | Size of Avatar (optional). | _double_ | | | -| `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | | | -| `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | | TooltipStyle.Combined | -| `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | | TooltipStyle.Combined | -| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | | | -| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | | | -| `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | | [] | -| `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | | | +| Parameter | Description | Type | +| :----------------- | :------------------------------------------------: | :------------------ | +| `mode` | enum for rendering avatar shape (required). | _enum_ | +| `size` | Size of Avatar (optional). | _double_ | +| `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | +| `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | +| `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | +| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | +| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | +| `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | +| `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | ## AvatarInfo From b44a13b8d91b17c424cbc61f4ff48e36805fec99 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:24:59 +0500 Subject: [PATCH 04/10] update readme.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8207251..a05a708 100644 --- a/README.md +++ b/README.md @@ -26,19 +26,19 @@ Acter Avatar is a package to generate different shapes of avatars by leveraging ### Usage of ActerAvatar 😎 -`ActerAvatar` takes both `mode` and `avatarInfo` param to render avatar. The param `uniqueId` in `AvatarInfo` is required. +`ActerAvatar` takes both `mode` and `avatarInfo` param to render avatar. ```dart ActerAvatar( mode: DisplayMode.DM, avatarInfo: AvatarInfo( - uniqueId: '@aliKah:lorem.org', + uniqueId: '@aliKah:lorem.org', // required displayName: 'Ali Akalın', avatar: NetworkImage(*someImageLink*)), // can be any image provider .i.e. AssetImage, MemoryImage and NetworkImage etc. ), ``` -Alternatively you can also provide future avatar in `AvatarInfo` which will show fallback until loaded if data isn't readily available. +Alternatively you can also provide future avatar in `AvatarInfo` which will show fallback if data isn't readily available. ```dart ActerAvatar( From f8ab0b7daf4016d6f878c91a5eb703d147684e63 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:28:31 +0500 Subject: [PATCH 05/10] update changelog.md --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ebf48..3ac1058 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ -## Unreleased - ### [1.0.0] +- release first stable version. - [Breaking Changes]: - ActerAvatar now supports `AvatarInfo` for specifying avatar data instead of singleton parameters. - Acter Avatar now supports `onAvatarTap()` and `onParentBadgeTap` for avatar gesture. @@ -11,6 +10,8 @@ - optimisation for avatar and fallback sizes - added ci unit tests for avatar size, render and tap behavior +## Unreleased + ### [0.0.7] - add logging support From da9bbf4b84bb0b7314405f5fb0640830e5e06808 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:32:18 +0500 Subject: [PATCH 06/10] update readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a05a708..20bd913 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Acter Avatar -Acter Avatar is a package to generate different shapes of avatars by leveraging the combination of [Multiavatar](https://pub.dev/packages/multiavatar) library and Textual Avatar mechanism. The package is a derivative work from [Acter a3](https://github.com/acterglobal/a3) ongoing development. +Acter Avatar is a package to generate different shapes of avatars by leveraging the combination of [Multiavatar](https://pub.dev/packages/multiavatar) library and [Colorize Text Avatar](https://pub.dev/packages/colorize_text_avatar) . The package is a derivative work from [Acter a3](https://github.com/acterglobal/a3) ongoing development. # CI Test Status From 179b431fe82e20b587dc34ce8477ac6533ad57e6 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:43:32 +0500 Subject: [PATCH 07/10] update readme.md --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 20bd913..388f179 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,17 @@ Acter Avatar is a package to generate different shapes of avatars by leveraging ## Parameters of ActerAvatar: -| Parameter | Description | Type | -| :----------------- | :------------------------------------------------: | :------------------ | -| `mode` | enum for rendering avatar shape (required). | _enum_ | -| `size` | Size of Avatar (optional). | _double_ | -| `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | -| `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | -| `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | -| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | -| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | -| `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | -| `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | +| Parameter | Description | Type | +| :----------------- | :-----------------------------------------------------------------------------------------: | :------------------ | +| `mode` | [DisplayMode](lib/src/constants/constants.dart) enum for rendering avatar shape (required). | _enum_ | +| `size` | Size of Avatar (optional). | _double_ | +| `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | +| `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | +| `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | +| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | +| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | +| `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | +| `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | ## AvatarInfo From aca8b291ec34e58abe57fea553edf49872883187 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:46:00 +0500 Subject: [PATCH 08/10] update readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 388f179..13436d4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Acter Avatar is a package to generate different shapes of avatars by leveraging | `badgeSize` | Size of Space Avatar parent badge (optional). | _double_ | | `tooltip` | `ActerAvatar` tooltip. | _TooltipStyle_ | | `secondaryToolTip` | Space Avatar OR Stack secondary avatar tooltip. | _TooltipStyle_ | -| `avatarInfo` | Holds avatar data. See [AvatarInfo] below section. | _AvatarInfo_ | +| `avatarInfo` | Holds avatar data. See [AvatarInfo](#avatarinfo) below section. | _AvatarInfo_ | | `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ | | `avatarsInfo` | for space and circular stack avatars.(optional) | _List?_ | | `onParentBadgeTap` | Secondary avatar interaction function (optional). | _Function()?_ | From 3a1401bb469af2b20364c564b5714d5b8cc18d99 Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:56:11 +0500 Subject: [PATCH 09/10] update pubspec.yaml --- pubspec.lock | 46 +++++++++++----------------------------------- pubspec.yaml | 2 +- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e8b2d68..3a6cd80 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,14 +1,6 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - args: - dependency: transitive - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" async: dependency: transitive description: @@ -74,10 +66,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter @@ -131,6 +123,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + path_drawing: + dependency: transitive + description: + name: path_drawing + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 + url: "https://pub.dev" + source: hosted + version: "1.0.1" path_parsing: dependency: transitive description: @@ -208,30 +208,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" vector_math: dependency: transitive description: @@ -258,4 +234,4 @@ packages: version: "6.4.2" sdks: dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.7.0-0" + flutter: ">=2.11.0-0.1.pre" diff --git a/pubspec.yaml b/pubspec.yaml index 801cb93..1b0b46b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_svg: ">=1.0.5" + flutter_svg: ^1.0.5 multiavatar: ^0.1.5 logging: ^1.2.0 From 445b12c6076eadb56eb20808c93eaf5dc887345d Mon Sep 17 00:00:00 2001 From: Talha Date: Sat, 2 Dec 2023 19:58:53 +0500 Subject: [PATCH 10/10] fix package dry run errors --- CHANGELOG.md | 2 +- pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ac1058..dce1b1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### [1.0.0] +### [1.0.0+3] - release first stable version. - [Breaking Changes]: diff --git a/pubspec.yaml b/pubspec.yaml index 1b0b46b..7ffc38a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0+3 homepage: https://github.com/acterglobal/acter-avatar environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.12.0 <4.0.0' flutter: ">=1.17.0" dependencies: @@ -18,4 +18,3 @@ dev_dependencies: flutter_test: sdk: flutter -flutter: