Skip to content

Commit fc609ab

Browse files
author
Dario Segura
committed
[IMAGE] Added ability to load JPEG images
1 parent e6ddfb2 commit fc609ab

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

package/pheno_ui/lib/interface/data/provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ abstract class PhenoDataProvider {
6060
Future<PhenoScreenSpec> doLoadScreenLayout(int id);
6161
Future<PhenoComponentSpec> doLoadComponentSpec(String name);
6262

63-
Image loadPng(String path, { required BoxFit fit });
63+
Image loadImage(String path, { required BoxFit fit });
6464
SvgPicture loadSvg(String path, { required BoxFit fit });
6565
}

package/pheno_ui/lib/interface/data/strapi_provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class StrapiDataProvider extends PhenoDataProvider {
4848
}
4949

5050
@override
51-
Image loadPng(String path, { required BoxFit fit }) {
51+
Image loadImage(String path, { required BoxFit fit }) {
5252
return Image.network(path, fit: fit);
5353
}
5454

package/pheno_ui/lib/models/fimga_image_model.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'figma_node_model.dart';
66

77
enum FigmaImageFormat with FigmaEnum {
88
png,
9+
jpeg,
910
svg,
1011
unknown,
1112
;

package/pheno_ui/lib/parsers/figma_image.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class FigmaImageParser extends MiraiParser<FigmaImageModel> {
1818
@override
1919
String get type => 'figma-image';
2020

21-
_loadPNG(FigmaImageModel model) {
21+
_loadImage(FigmaImageModel model) {
2222
if (model.method == FigmaImageDataMethod.embed) {
2323
return Image.memory(base64Decode(model.data), fit: model.fit);
2424
}
25-
return FigmaScreens().provider!.loadPng(model.data, fit: model.fit);
25+
return FigmaScreens().provider!.loadImage(model.data, fit: model.fit);
2626
}
2727

2828
_loadSVG(FigmaImageModel model) {
@@ -35,7 +35,8 @@ class FigmaImageParser extends MiraiParser<FigmaImageModel> {
3535
@override
3636
Widget parse(BuildContext context, FigmaImageModel model) {
3737
Widget widget = switch (model.format) {
38-
FigmaImageFormat.png =>_loadPNG(model),
38+
FigmaImageFormat.png =>_loadImage(model),
39+
FigmaImageFormat.jpeg =>_loadImage(model),
3940
FigmaImageFormat.svg => _loadSVG(model),
4041
_ => throw 'ERROR: Unknown image format [${model.format.name}]',
4142
};

0 commit comments

Comments
 (0)