mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
refined screenshots naming
This commit is contained in:
parent
ea023f49e1
commit
6aeb83d96b
5 changed files with 60 additions and 64 deletions
|
@ -1,27 +1,27 @@
|
||||||
{
|
{
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
{
|
{
|
||||||
"screenshotName": "light-metering_reflected",
|
"screenshotName": "light_metering-reflected",
|
||||||
"title": "Quick & easy to use",
|
"title": "Quick & easy to use",
|
||||||
"subtitle": "with all the necessary controls\nunder your thumb"
|
"subtitle": "with all the necessary controls\nunder your thumb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"screenshotName": "light-metering_iso_picker",
|
"screenshotName": "light_metering-iso-picker",
|
||||||
"title": "Lots of ISO values",
|
"title": "Lots of ISO values",
|
||||||
"subtitle": "From 3 and up to 6400"
|
"subtitle": "From 3 and up to 6400"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"screenshotName": "light-settings",
|
"screenshotName": "light_settings",
|
||||||
"title": "Useful settings",
|
"title": "Useful settings",
|
||||||
"subtitle": "to get the most accurate\nmetering results"
|
"subtitle": "to get the most accurate\nmetering results"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"screenshotName": "light-equipment_profiles",
|
"screenshotName": "light_equipment-profiles",
|
||||||
"title": "Create multiple profiles",
|
"title": "Create multiple profiles",
|
||||||
"subtitle": "to match your\ncamera & lens setups"
|
"subtitle": "to match your\ncamera & lens setups"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"screenshotName": "dark-metering_reflected",
|
"screenshotName": "dark_metering-reflected",
|
||||||
"title": "Matches your style",
|
"title": "Matches your style",
|
||||||
"subtitle": "with various theme types and colors"
|
"subtitle": "with various theme types and colors"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ extension ScreenshotImage on Image {
|
||||||
required ScreenshotArgs args,
|
required ScreenshotArgs args,
|
||||||
required ScreenshotLayout layout,
|
required ScreenshotLayout layout,
|
||||||
}) {
|
}) {
|
||||||
if (_configs[args.name] == null) {
|
if (_configs[args.nameWithTheme] == null) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return _addSystemOverlay(
|
return _addSystemOverlay(
|
||||||
|
@ -23,17 +23,12 @@ extension ScreenshotImage on Image {
|
||||||
)
|
)
|
||||||
._addDeviceFrame(
|
._addDeviceFrame(
|
||||||
screenshotDevices[args.deviceName]!,
|
screenshotDevices[args.deviceName]!,
|
||||||
ColorRgba8(
|
args.backgroundColor,
|
||||||
args.backgroundColor.r,
|
|
||||||
args.backgroundColor.g,
|
|
||||||
args.backgroundColor.b,
|
|
||||||
args.backgroundColor.a,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
._applyLayout(
|
._applyLayout(
|
||||||
layout,
|
layout,
|
||||||
_configs[args.name]!.title,
|
_configs[args.nameWithTheme]!.title,
|
||||||
_configs[args.name]!.subtitle,
|
_configs[args.nameWithTheme]!.subtitle,
|
||||||
isDark: args.isDark,
|
isDark: args.isDark,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +42,13 @@ extension ScreenshotImage on Image {
|
||||||
return compositeImage(this, statusBar);
|
return compositeImage(this, statusBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image _addDeviceFrame(ScreenshotDevice device, Color backgroundColor) {
|
Image _addDeviceFrame(ScreenshotDevice device, String color) {
|
||||||
|
final backgroundColor = ColorRgba8(
|
||||||
|
int.parse(color.substring(2, 4), radix: 16),
|
||||||
|
int.parse(color.substring(4, 6), radix: 16),
|
||||||
|
int.parse(color.substring(6, 8), radix: 16),
|
||||||
|
int.parse(color.substring(0, 2), radix: 16),
|
||||||
|
);
|
||||||
final screenshotRounded = copyCrop(
|
final screenshotRounded = copyCrop(
|
||||||
this,
|
this,
|
||||||
x: 0,
|
x: 0,
|
||||||
|
|
|
@ -81,36 +81,36 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.takePhoto();
|
await tester.takePhoto();
|
||||||
await tester.takeScreenshot(binding, 'light-metering_reflected');
|
await tester.takeScreenshotLight(binding, 'metering-reflected');
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.toggleIncidentMetering(7.3);
|
await tester.toggleIncidentMetering(7.3);
|
||||||
await tester.takeScreenshot(binding, 'light-metering_incident');
|
await tester.takeScreenshotLight(binding, 'metering-incident');
|
||||||
}
|
}
|
||||||
|
|
||||||
await tester.openAnimatedPicker<IsoValuePicker>();
|
await tester.openAnimatedPicker<IsoValuePicker>();
|
||||||
await tester.takeScreenshot(binding, 'light-metering_iso_picker');
|
await tester.takeScreenshotLight(binding, 'metering-iso-picker');
|
||||||
|
|
||||||
await tester.tapCancelButton();
|
await tester.tapCancelButton();
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
|
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, 'light-settings');
|
await tester.takeScreenshotLight(binding, 'settings');
|
||||||
|
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.meteringScreenLayout);
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.meteringScreenLayout);
|
||||||
await tester.takeScreenshot(binding, 'light-settings_metering_screen_layout');
|
await tester.takeScreenshotLight(binding, 'settings-metering-screen-layout');
|
||||||
|
|
||||||
await tester.tapCancelButton();
|
await tester.tapCancelButton();
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tapDescendantTextOf<EquipmentProfilesScreen>(mockEquipmentProfiles.first.name);
|
await tester.tapDescendantTextOf<EquipmentProfilesScreen>(mockEquipmentProfiles.first.name);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, 'light-equipment_profiles');
|
await tester.takeScreenshotLight(binding, 'equipment-profiles');
|
||||||
|
|
||||||
await tester.tap(find.byIcon(Icons.iso).first);
|
await tester.tap(find.byIcon(Icons.iso).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, 'light-equipment_profiles_iso_picker');
|
await tester.takeScreenshotLight(binding, 'equipment-profiles-iso-picker');
|
||||||
});
|
});
|
||||||
|
|
||||||
/// and the additionally the first one with the dark theme
|
/// and the additionally the first one with the dark theme
|
||||||
|
@ -125,13 +125,13 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.takePhoto();
|
await tester.takePhoto();
|
||||||
await tester.takeScreenshot(binding, 'dark-metering_reflected');
|
await tester.takeScreenshotDark(binding, 'metering-reflected');
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.toggleIncidentMetering(7.3);
|
await tester.toggleIncidentMetering(7.3);
|
||||||
await tester.takeScreenshot(binding, 'dark-metering_incident');
|
await tester.takeScreenshotDark(binding, 'metering-incident');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -140,21 +140,20 @@ void main() {
|
||||||
final String _platformFolder = Platform.isAndroid ? 'android' : 'ios';
|
final String _platformFolder = Platform.isAndroid ? 'android' : 'ios';
|
||||||
|
|
||||||
extension on WidgetTester {
|
extension on WidgetTester {
|
||||||
Future<void> takeScreenshot(IntegrationTestWidgetsFlutterBinding binding, String name) async {
|
Future<void> takeScreenshotLight(IntegrationTestWidgetsFlutterBinding binding, String name) =>
|
||||||
final bool isDark = name.contains('dark-');
|
_takeScreenshot(binding, name, _themeLight);
|
||||||
final Color backgroundColor = (isDark ? _themeDark : _themeLight).colorScheme.surface;
|
Future<void> takeScreenshotDark(IntegrationTestWidgetsFlutterBinding binding, String name) =>
|
||||||
|
_takeScreenshot(binding, name, _themeDark);
|
||||||
|
|
||||||
|
Future<void> _takeScreenshot(IntegrationTestWidgetsFlutterBinding binding, String name, ThemeData theme) async {
|
||||||
|
final Color backgroundColor = theme.colorScheme.surface;
|
||||||
await binding.takeScreenshot(
|
await binding.takeScreenshot(
|
||||||
ScreenshotArgs(
|
ScreenshotArgs(
|
||||||
name: name,
|
name: name,
|
||||||
deviceName: const String.fromEnvironment('deviceName').replaceAll(' ', '_').toLowerCase(),
|
deviceName: const String.fromEnvironment('deviceName'),
|
||||||
platformFolder: _platformFolder,
|
platformFolder: _platformFolder,
|
||||||
backgroundColor: (
|
backgroundColor: backgroundColor.value.toRadixString(16),
|
||||||
r: backgroundColor.red,
|
isDark: theme.brightness == Brightness.dark,
|
||||||
g: backgroundColor.green,
|
|
||||||
b: backgroundColor.blue,
|
|
||||||
a: backgroundColor.alpha,
|
|
||||||
),
|
|
||||||
isDark: isDark,
|
|
||||||
).toString(),
|
).toString(),
|
||||||
);
|
);
|
||||||
await pumpAndSettle();
|
await pumpAndSettle();
|
||||||
|
|
|
@ -31,23 +31,15 @@ Future<int> main(List<String> args) async {
|
||||||
final screenshotName = filePath.path.split('/').last.replaceAll('.png', '');
|
final screenshotName = filePath.path.split('/').last.replaceAll('.png', '');
|
||||||
final screenshotBytes = File(filePath.path).readAsBytesSync();
|
final screenshotBytes = File(filePath.path).readAsBytesSync();
|
||||||
final screenshot = decodePng(Uint8List.fromList(screenshotBytes))!;
|
final screenshot = decodePng(Uint8List.fromList(screenshotBytes))!;
|
||||||
final topLeftPixel = screenshot.getPixel(0, 0);
|
|
||||||
|
|
||||||
final screenshotArgs = ScreenshotArgs(
|
final screenshotArgs = ScreenshotArgs.fromRawName(
|
||||||
name: screenshotName,
|
name: screenshotName,
|
||||||
deviceName: device,
|
deviceName: device,
|
||||||
platformFolder: platform,
|
platformFolder: platform,
|
||||||
backgroundColor: (
|
|
||||||
r: topLeftPixel.r.toInt(),
|
|
||||||
g: topLeftPixel.g.toInt(),
|
|
||||||
b: topLeftPixel.b.toInt(),
|
|
||||||
a: topLeftPixel.a.toInt(),
|
|
||||||
),
|
|
||||||
isDark: filePath.path.contains('dark-'),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final file =
|
final file =
|
||||||
await File('screenshots/generated/$platform/${layout.name}/$screenshotName.png').create(recursive: true);
|
await File('screenshots/generated/$platform/${layout.name}/${screenshotArgs.name}.png').create(recursive: true);
|
||||||
file.writeAsBytesSync(
|
file.writeAsBytesSync(
|
||||||
encodePng(
|
encodePng(
|
||||||
screenshot.convertToStoreScreenshot(
|
screenshot.convertToStoreScreenshot(
|
||||||
|
|
|
@ -4,19 +4,34 @@ class ScreenshotArgs {
|
||||||
final String name;
|
final String name;
|
||||||
final String deviceName;
|
final String deviceName;
|
||||||
final String platformFolder;
|
final String platformFolder;
|
||||||
final ({int r, int g, int b, int a}) backgroundColor;
|
final String backgroundColor;
|
||||||
final bool isDark;
|
final bool isDark;
|
||||||
|
|
||||||
const ScreenshotArgs({
|
static const _pathArgsDelimited = '_';
|
||||||
|
|
||||||
|
ScreenshotArgs({
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.deviceName,
|
required String deviceName,
|
||||||
required this.platformFolder,
|
required this.platformFolder,
|
||||||
required this.backgroundColor,
|
required this.backgroundColor,
|
||||||
required this.isDark,
|
required this.isDark,
|
||||||
});
|
}) : deviceName = deviceName.replaceAll(' ', _pathArgsDelimited).toLowerCase();
|
||||||
|
|
||||||
String toPathRaw() => 'screenshots/generated/raw/$platformFolder/$deviceName/$name.png';
|
ScreenshotArgs.fromRawName({
|
||||||
String toPath() => 'screenshots/generated/$platformFolder/$deviceName/$name.png';
|
required String name,
|
||||||
|
required String deviceName,
|
||||||
|
required this.platformFolder,
|
||||||
|
}) : name = name.split(_pathArgsDelimited)[1],
|
||||||
|
deviceName = deviceName.replaceAll(' ', _pathArgsDelimited).toLowerCase(),
|
||||||
|
backgroundColor = name.split(_pathArgsDelimited)[2],
|
||||||
|
isDark = name.contains('dark');
|
||||||
|
|
||||||
|
static const _folderPrefix = 'screenshots/generated';
|
||||||
|
String get nameWithTheme => '${isDark ? 'dark' : 'light'}$_pathArgsDelimited$name';
|
||||||
|
|
||||||
|
String toPathRaw() =>
|
||||||
|
'$_folderPrefix/raw/$platformFolder/$deviceName/$nameWithTheme$_pathArgsDelimited$backgroundColor.png';
|
||||||
|
String toPath() => '$_folderPrefix/$platformFolder/$deviceName/$name.png';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => jsonEncode(_toJson());
|
String toString() => jsonEncode(_toJson());
|
||||||
|
@ -24,17 +39,11 @@ class ScreenshotArgs {
|
||||||
factory ScreenshotArgs.fromString(String data) => ScreenshotArgs._fromJson(jsonDecode(data) as Map<String, dynamic>);
|
factory ScreenshotArgs.fromString(String data) => ScreenshotArgs._fromJson(jsonDecode(data) as Map<String, dynamic>);
|
||||||
|
|
||||||
factory ScreenshotArgs._fromJson(Map<String, dynamic> data) {
|
factory ScreenshotArgs._fromJson(Map<String, dynamic> data) {
|
||||||
final colorChannels = data['backgroundColor'] as List;
|
|
||||||
return ScreenshotArgs(
|
return ScreenshotArgs(
|
||||||
name: data['name'] as String,
|
name: data['name'] as String,
|
||||||
deviceName: data['deviceName'] as String,
|
deviceName: data['deviceName'] as String,
|
||||||
platformFolder: data['platformFolder'] as String,
|
platformFolder: data['platformFolder'] as String,
|
||||||
backgroundColor: (
|
backgroundColor: data['backgroundColor'] as String,
|
||||||
r: colorChannels[0] as int,
|
|
||||||
g: colorChannels[1] as int,
|
|
||||||
b: colorChannels[2] as int,
|
|
||||||
a: colorChannels[3] as int,
|
|
||||||
),
|
|
||||||
isDark: data['isDark'] as bool,
|
isDark: data['isDark'] as bool,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,12 +53,7 @@ class ScreenshotArgs {
|
||||||
"name": name,
|
"name": name,
|
||||||
"deviceName": deviceName,
|
"deviceName": deviceName,
|
||||||
"platformFolder": platformFolder,
|
"platformFolder": platformFolder,
|
||||||
"backgroundColor": [
|
"backgroundColor": backgroundColor,
|
||||||
backgroundColor.r,
|
|
||||||
backgroundColor.g,
|
|
||||||
backgroundColor.b,
|
|
||||||
backgroundColor.a,
|
|
||||||
],
|
|
||||||
"isDark": isDark,
|
"isDark": isDark,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue