yubioath-flutter/lib/app/views/device_images.dart

47 lines
1.2 KiB
Dart
Raw Normal View History

2021-11-24 15:28:38 +03:00
import 'package:flutter/material.dart';
2022-03-16 14:43:56 +03:00
import '../../core/models.dart';
2021-11-24 15:28:38 +03:00
import '../../management/models.dart';
const _imagesForName = {
'YubiKey 4': 'yk4series',
'YubiKey Edge': 'ykedge',
'YubiKey Plus': 'ykplus',
'YubiKey 5A': 'yk4',
'FIDO U2F Security Key': 'sky1',
'Security Key by Yubico': 'sky2',
'Security Key NFC': 'sky3',
2022-04-05 13:52:39 +03:00
'Security Key C NFC': 'skycnfc',
2021-11-24 15:28:38 +03:00
'YubiKey NEO': 'neo',
'YubiKey Standard': 'standard',
};
const _imagesForFormFactor = {
FormFactor.usbAKeychain: 'yk4',
FormFactor.usbANano: 'yk5nano',
FormFactor.usbCKeychain: 'yk5c',
FormFactor.usbCNano: 'yk5cnano',
FormFactor.usbCLightning: 'yk5ci',
FormFactor.usbABio: 'ykbioa',
FormFactor.usbCBio: 'ykbioc',
};
const _imagesForFormFactorNfc = {
FormFactor.usbAKeychain: 'yk5nfc',
FormFactor.usbCKeychain: 'yk5cnfc',
};
2022-01-12 14:49:04 +03:00
Image getProductImage(DeviceInfo info, String name) {
var image = _imagesForName[name];
image ??= info.supportedCapabilities.containsKey(Transport.nfc)
? _imagesForFormFactorNfc[info.formFactor]
: _imagesForFormFactor[info.formFactor];
2021-11-24 15:28:38 +03:00
image ??= 'yk5series';
return Image.asset(
'assets/product-images/$image.png',
// Medium provides the best results when scaling down
filterQuality: FilterQuality.medium,
);
2021-11-24 15:28:38 +03:00
}