63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
import 'package:manager_app/Components/audio_player.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:managerapi/api.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
getElementForResource(dynamic resourceDTO, AppContext appContext) {
|
|
switch(resourceDTO.type) {
|
|
case ResourceType.image:
|
|
return Image.network(
|
|
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id,
|
|
fit:BoxFit.fill,
|
|
loadingBuilder: (BuildContext context, Widget child,
|
|
ImageChunkEvent loadingProgress) {
|
|
if (loadingProgress == null) {
|
|
return child;
|
|
}
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
color: kPrimaryColor,
|
|
value: loadingProgress.expectedTotalBytes != null
|
|
? loadingProgress.cumulativeBytesLoaded /
|
|
loadingProgress.expectedTotalBytes
|
|
: null,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
break;
|
|
case ResourceType.imageUrl:
|
|
return Image.network(
|
|
resourceDTO.data,
|
|
fit:BoxFit.fill,
|
|
loadingBuilder: (BuildContext context, Widget child,
|
|
ImageChunkEvent loadingProgress) {
|
|
if (loadingProgress == null) {
|
|
return child;
|
|
}
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
color: kPrimaryColor,
|
|
value: loadingProgress.expectedTotalBytes != null
|
|
? loadingProgress.cumulativeBytesLoaded /
|
|
loadingProgress.expectedTotalBytes
|
|
: null,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
break;
|
|
case ResourceType.audio:
|
|
//return AudioPlayerContainer(resourceDTO: resourceDTO, isAuto: true);
|
|
return Text("Fichier audio - aucune visualisation possible");
|
|
break;
|
|
case ResourceType.video:
|
|
return Text("Vidéo locale - aucune visualisation possible");
|
|
break;
|
|
case ResourceType.videoUrl:
|
|
return Text(resourceDTO.data);
|
|
break;
|
|
}
|
|
}
|