Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preparation of first version release #9

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Unreleased

### [1.0.0]
### [1.0.0+3]

- 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.
Expand All @@ -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
Expand Down
114 changes: 43 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,68 @@
# Acter Avatar

Acter Avatar is a package to generate avatar for the acter platform.
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

<a href="https://github.com/acterglobal/acter-avatar/actions"><img src="https://github.com/acterglobal/acter-avatar/workflows/acter-avatar-tests/badge.svg" alt="Build Status"></a>

## 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 |
| :----------------- | :-----------------------------------------------------------------------------------------: | :------------------ |
| `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](#avatarinfo) below section. | _AvatarInfo_ |
| `onAvatarTap` | Primary avatar interacton function (optional). | _Function()?_ |
| `avatarsInfo` | for space and circular stack avatars.(optional) | _List<AvatarInfo>?_ |
| `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.

```dart
TextAvatar(
text: "Deniz Çolak",
)
ActerAvatar(
mode: DisplayMode.DM,
avatarInfo: AvatarInfo(
uniqueId: '@aliKah:lorem.org', // required
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 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
Expand Down
6 changes: 3 additions & 3 deletions lib/src/acter_avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class _ActerAvatar extends State<ActerAvatar> {
.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);
Expand All @@ -93,13 +93,13 @@ class _ActerAvatar extends State<ActerAvatar> {
}

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;
}
Expand Down
16 changes: 7 additions & 9 deletions lib/src/models/avatar_info.dart
Original file line number Diff line number Diff line change
@@ -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<Object>? avatar;

/// Or alternatively a future that loads the avatar (show fallback until loaded)
final Future<ImageProvider<Object>?>? imageProviderFuture;
/// a future that loads the avatar (show fallback until loaded)
final Future<ImageProvider<Object>?>? avatarFuture;

const AvatarInfo({
required this.uniqueId,
this.displayName,
this.uniqueName,
this.avatar,
this.imageProviderFuture,
this.avatarFuture,
});
}
46 changes: 11 additions & 35 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ 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:
flutter:
sdk: flutter
flutter_svg: ">=1.0.5"
flutter_svg: ^1.0.5
multiavatar: ^0.1.5
logging: ^1.2.0

dev_dependencies:
flutter_test:
sdk: flutter

flutter:
Loading