mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-12 10:47:31 +02:00
feat(metadata): edit release tags and render UPC barcodes
This commit is contained in:
1 parent
290923e88f
commit
a7423b7f89
37 files changed
+1162
-32
No files matched your search
@@ -1036,6 +1036,10 @@ void main() {
|
||||
'bitDepth': 24,
|
||||
'sampleRate': 96000,
|
||||
'bitrate': 1840,
|
||||
'albumType': 'album',
|
||||
'explicit': true,
|
||||
'upc': '4006381333931',
|
||||
'comment': 'https://listen.tidal.com/album/1',
|
||||
'format': 'flac',
|
||||
});
|
||||
|
||||
@@ -1051,6 +1055,10 @@ void main() {
|
||||
expect(normalized['bit_depth'], 24);
|
||||
expect(normalized['sample_rate'], 96000);
|
||||
expect(normalized['bitrate'], 1840);
|
||||
expect(normalized['album_type'], 'album');
|
||||
expect(normalized['explicit'], isTrue);
|
||||
expect(normalized['upc'], '4006381333931');
|
||||
expect(normalized['comment'], 'https://listen.tidal.com/album/1');
|
||||
expect(normalized['audio_codec'], 'flac');
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:spotiflac_android/utils/retail_barcode.dart';
|
||||
import 'package:spotiflac_android/widgets/metadata_barcode.dart';
|
||||
|
||||
void main() {
|
||||
test('encodes a valid UPC-A with its native retail symbology', () {
|
||||
final barcode = encodeRetailBarcode('036000291452');
|
||||
|
||||
expect(barcode, isNotNull);
|
||||
expect(barcode!.symbology, 'UPC-A');
|
||||
expect(barcode.value, '036000291452');
|
||||
expect(barcode.modules, hasLength(95));
|
||||
expect(barcode.modules, startsWith('101'));
|
||||
expect(barcode.modules, endsWith('101'));
|
||||
});
|
||||
|
||||
test('encodes a valid EAN-13 with its native retail symbology', () {
|
||||
final barcode = encodeRetailBarcode('4006381333931');
|
||||
|
||||
expect(barcode, isNotNull);
|
||||
expect(barcode!.symbology, 'EAN-13');
|
||||
expect(barcode.modules, hasLength(95));
|
||||
expect(hasValidGtinCheckDigit(barcode.value), isTrue);
|
||||
});
|
||||
|
||||
test('uses an exact scannable fallback for a malformed provider value', () {
|
||||
final barcode = encodeRetailBarcode('0012345678901');
|
||||
|
||||
expect(barcode, isNotNull);
|
||||
expect(barcode!.symbology, 'CODE 128');
|
||||
expect(barcode.value, '0012345678901');
|
||||
expect(barcode.modules, isNotEmpty);
|
||||
});
|
||||
|
||||
test('normalizes separators but rejects non-numeric values', () {
|
||||
expect(encodeRetailBarcode('0 36000-29145 2')?.value, '036000291452');
|
||||
expect(encodeRetailBarcode('not-a-upc'), isNull);
|
||||
});
|
||||
|
||||
testWidgets('metadata barcode stays usable in a narrow metadata card', (
|
||||
tester,
|
||||
) async {
|
||||
var copied = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(colorSchemeSeed: Colors.teal),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 260,
|
||||
child: MetadataBarcode(
|
||||
value: '036000291452',
|
||||
label: 'UPC / Barcode',
|
||||
onCopy: () => copied = true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('UPC-A'), findsOneWidget);
|
||||
expect(find.text('036000291452'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byType(MetadataBarcode));
|
||||
expect(copied, isTrue);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user