File tree Expand file tree Collapse file tree 4 files changed +72
-1
lines changed
widgets/message/item/action_card Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,7 @@ class _ShareMenuItem extends StatelessWidget {
294
294
true ,
295
295
[],
296
296
'' ,
297
+ null ,
297
298
);
298
299
299
300
await context.accountServer.sendAppCardMessage (
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class AppCardData {
17
17
this .shareable,
18
18
this .actions,
19
19
this .coverUrl,
20
+ this .cover,
20
21
);
21
22
22
23
factory AppCardData .fromJson (Map <String , dynamic > json) =>
@@ -28,6 +29,9 @@ class AppCardData {
28
29
final String iconUrl;
29
30
@JsonKey (name: 'cover_url' , defaultValue: '' )
30
31
final String coverUrl;
32
+
33
+ final Cover ? cover;
34
+
31
35
final String title;
32
36
final String description;
33
37
@JsonKey (name: 'action' , defaultValue: '' )
@@ -47,6 +51,28 @@ class AppCardData {
47
51
bool get canShareActions => actions.every ((e) => e.isValidSharedAction);
48
52
}
49
53
54
+ @JsonSerializable ()
55
+ class Cover {
56
+ const Cover ({
57
+ required this .url,
58
+ required this .thumbnail,
59
+ required this .mimeType,
60
+ required this .width,
61
+ required this .height,
62
+ });
63
+
64
+ factory Cover .fromJson (Map <String , dynamic > json) => _$CoverFromJson (json);
65
+
66
+ final String url;
67
+ final String ? thumbnail;
68
+ @JsonKey (name: 'mime_type' )
69
+ final String mimeType;
70
+ final int width;
71
+ final int height;
72
+
73
+ Map <String , dynamic > toJson () => _$CoverToJson (this );
74
+ }
75
+
50
76
extension on ActionData {
51
77
bool get isValidSharedAction {
52
78
try {
Original file line number Diff line number Diff line change
1
+ import 'dart:math' as math;
2
+
1
3
import 'package:flutter/material.dart' ;
2
4
import 'package:flutter_hooks/flutter_hooks.dart' ;
3
5
@@ -105,7 +107,9 @@ class ActionsCardBody extends StatelessWidget {
105
107
AspectRatio (
106
108
aspectRatio: 1 ,
107
109
child: CacheImage (data.coverUrl),
108
- ),
110
+ )
111
+ else if (data.cover != null )
112
+ _CoverWidget (cover: data.cover! ),
109
113
const SizedBox (height: 10 ),
110
114
Padding (
111
115
padding: const EdgeInsets .symmetric (horizontal: 12 ),
@@ -128,6 +132,26 @@ class ActionsCardBody extends StatelessWidget {
128
132
);
129
133
}
130
134
135
+ class _CoverWidget extends StatelessWidget {
136
+ const _CoverWidget ({required this .cover});
137
+
138
+ final Cover cover;
139
+
140
+ @override
141
+ Widget build (BuildContext context) {
142
+ var aspect = 1.0 ;
143
+ try {
144
+ aspect = math.max (cover.width / cover.height, 1.5 );
145
+ } catch (err) {
146
+ aspect = 1 ;
147
+ }
148
+ return AspectRatio (
149
+ aspectRatio: aspect,
150
+ child: CacheImage (cover.url),
151
+ );
152
+ }
153
+ }
154
+
131
155
class _Actions extends StatelessWidget {
132
156
const _Actions ({required this .actions});
133
157
You can’t perform that action at this time.
0 commit comments