43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
import 'artifact_file.dart';
|
|
import 'artifact_transfer.dart';
|
|
|
|
/// The host file capabilities one action row uses.
|
|
///
|
|
/// The defaults are the real conditional-import bridge: a web Blob/anchor
|
|
/// download plus `navigator.share`, and honest `unsupported` results on native
|
|
/// hosts until a platform launcher exists. Tests inject both functions and the
|
|
/// capability flags without touching a browser.
|
|
class ArtifactFileBridge {
|
|
const ArtifactFileBridge({
|
|
this.download,
|
|
this.share,
|
|
this.downloadSupported,
|
|
this.shareSupported,
|
|
this.downloadUnsupportedMessage,
|
|
this.shareUnsupportedMessage,
|
|
});
|
|
|
|
final ArtifactSaveFile? download;
|
|
final ArtifactShareFile? share;
|
|
final bool? downloadSupported;
|
|
final bool? shareSupported;
|
|
final String? downloadUnsupportedMessage;
|
|
final String? shareUnsupportedMessage;
|
|
|
|
bool get canDownload => downloadSupported ?? artifactDownloadSupported;
|
|
|
|
bool get canShare => shareSupported ?? artifactShareSupported;
|
|
|
|
String get downloadUnavailableMessage =>
|
|
downloadUnsupportedMessage ?? artifactDownloadUnsupportedMessage;
|
|
|
|
String get shareUnavailableMessage =>
|
|
shareUnsupportedMessage ?? artifactShareUnsupportedMessage;
|
|
|
|
Future<ArtifactTransferResult> saveFile(ArtifactFile file) =>
|
|
(download ?? saveArtifactFile)(file);
|
|
|
|
Future<ArtifactTransferResult> shareFile(ArtifactFile file) =>
|
|
(share ?? shareArtifactFile)(file);
|
|
}
|