Browse Source

specs,nextcloud,neon: Implement dark avatars

pull/98/head
jld3103 2 years ago
parent
commit
bb57e82358
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 16
      packages/neon/lib/src/widgets/account_avatar.dart
  2. 22
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  3. 39
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 39
      specs/core.json

16
packages/neon/lib/src/widgets/account_avatar.dart

@ -12,6 +12,7 @@ class AccountAvatar extends StatelessWidget {
@override
Widget build(final BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final size = (kAvatarSize * MediaQuery.of(context).devicePixelRatio).toInt();
return Stack(
alignment: Alignment.center,
@ -21,11 +22,20 @@ class AccountAvatar extends StatelessWidget {
child: ClipOval(
child: CachedAPIImage(
account: account,
cacheKey: 'avatar-${account.id}-$size',
download: () async => account.client.core.getAvatar(
cacheKey: 'avatar-${account.id}-${isDark ? 'dark' : 'light'}$size',
download: () async {
if (isDark) {
return account.client.core.getDarkAvatar(
userId: account.username,
size: size,
),
);
} else {
return account.client.core.getAvatar(
userId: account.username,
size: size,
);
}
},
),
),
),

22
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -1606,6 +1606,28 @@ class CoreClient {
throw ApiException.fromResponse(response); // coverage:ignore-line
}
Future<Uint8List> getDarkAvatar({
required String userId,
required int size,
}) async {
var path = '/avatar/{userId}/{size}/dark';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
Uint8List? body;
path = path.replaceAll('{userId}', Uri.encodeQueryComponent(userId.toString()));
path = path.replaceAll('{size}', Uri.encodeQueryComponent(size.toString()));
final response = await rootClient.doRequest(
'get',
Uri(path: path, queryParameters: queryParameters).toString(),
headers,
body,
);
if (response.statusCode == 200) {
return response.body;
}
throw ApiException.fromResponse(response); // coverage:ignore-line
}
Future<Uint8List> getAvatar({
required String userId,
required int size,

39
packages/nextcloud/lib/src/nextcloud.openapi.json

@ -2310,6 +2310,45 @@
}
}
},
"/avatar/{userId}/{size}/dark": {
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "size",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
}
],
"get": {
"operationId": "get-dark-avatar",
"tags": [
"core"
],
"responses": {
"200": {
"description": "",
"content": {
"image/png": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/avatar/{userId}/{size}": {
"parameters": [
{

39
specs/core.json

@ -1260,6 +1260,45 @@
}
}
},
"/avatar/{userId}/{size}/dark": {
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "size",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
}
],
"get": {
"operationId": "get-dark-avatar",
"tags": [
"core"
],
"responses": {
"200": {
"description": "",
"content": {
"image/png": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/avatar/{userId}/{size}": {
"parameters": [
{

Loading…
Cancel
Save