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. 20
      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

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

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

Loading…
Cancel
Save