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": [
|
||||
{
|
||||
"screenshotName": "light-metering_reflected",
|
||||
"screenshotName": "light_metering-reflected",
|
||||
"title": "Quick & easy to use",
|
||||
"subtitle": "with all the necessary controls\nunder your thumb"
|
||||
},
|
||||
{
|
||||
"screenshotName": "light-metering_iso_picker",
|
||||
"screenshotName": "light_metering-iso-picker",
|
||||
"title": "Lots of ISO values",
|
||||
"subtitle": "From 3 and up to 6400"
|
||||
},
|
||||
{
|
||||
"screenshotName": "light-settings",
|
||||
"screenshotName": "light_settings",
|
||||
"title": "Useful settings",
|
||||
"subtitle": "to get the most accurate\nmetering results"
|
||||
},
|
||||
{
|
||||
"screenshotName": "light-equipment_profiles",
|
||||
"screenshotName": "light_equipment-profiles",
|
||||
"title": "Create multiple profiles",
|
||||
"subtitle": "to match your\ncamera & lens setups"
|
||||
},
|
||||
{
|
||||
"screenshotName": "dark-metering_reflected",
|
||||
"screenshotName": "dark_metering-reflected",
|
||||
"title": "Matches your style",
|
||||
"subtitle": "with various theme types and colors"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ extension ScreenshotImage on Image {
|
|||
required ScreenshotArgs args,
|
||||
required ScreenshotLayout layout,
|
||||
}) {
|
||||
if (_configs[args.name] == null) {
|
||||
if (_configs[args.nameWithTheme] == null) {
|
||||
return this;
|
||||
}
|
||||
return _addSystemOverlay(
|
||||
|
@ -23,17 +23,12 @@ extension ScreenshotImage on Image {
|
|||
)
|
||||
._addDeviceFrame(
|
||||
screenshotDevices[args.deviceName]!,
|
||||
ColorRgba8(
|
||||
args.backgroundColor.r,
|
||||
args.backgroundColor.g,
|
||||
args.backgroundColor.b,
|
||||
args.backgroundColor.a,
|
||||
),
|
||||
args.backgroundColor,
|
||||
)
|
||||
._applyLayout(
|
||||
layout,
|
||||
_configs[args.name]!.title,
|
||||
_configs[args.name]!.subtitle,
|
||||
_configs[args.nameWithTheme]!.title,
|
||||
_configs[args.nameWithTheme]!.subtitle,
|
||||
isDark: args.isDark,
|
||||
);
|
||||
}
|
||||
|
@ -47,7 +42,13 @@ extension ScreenshotImage on Image {
|
|||
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(
|
||||
this,
|
||||
x: 0,
|
||||
|
|
|
@ -81,36 +81,36 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.takePhoto();
|
||||
await tester.takeScreenshot(binding, 'light-metering_reflected');
|
||||
await tester.takeScreenshotLight(binding, 'metering-reflected');
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.toggleIncidentMetering(7.3);
|
||||
await tester.takeScreenshot(binding, 'light-metering_incident');
|
||||
await tester.takeScreenshotLight(binding, 'metering-incident');
|
||||
}
|
||||
|
||||
await tester.openAnimatedPicker<IsoValuePicker>();
|
||||
await tester.takeScreenshot(binding, 'light-metering_iso_picker');
|
||||
await tester.takeScreenshotLight(binding, 'metering-iso-picker');
|
||||
|
||||
await tester.tapCancelButton();
|
||||
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.takeScreenshot(binding, 'light-settings');
|
||||
await tester.takeScreenshotLight(binding, 'settings');
|
||||
|
||||
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.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tapDescendantTextOf<EquipmentProfilesScreen>(mockEquipmentProfiles.first.name);
|
||||
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.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
|
||||
|
@ -125,13 +125,13 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.takePhoto();
|
||||
await tester.takeScreenshot(binding, 'dark-metering_reflected');
|
||||
await tester.takeScreenshotDark(binding, 'metering-reflected');
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||
await tester.pumpAndSettle();
|
||||
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';
|
||||
|
||||
extension on WidgetTester {
|
||||
Future<void> takeScreenshot(IntegrationTestWidgetsFlutterBinding binding, String name) async {
|
||||
final bool isDark = name.contains('dark-');
|
||||
final Color backgroundColor = (isDark ? _themeDark : _themeLight).colorScheme.surface;
|
||||
Future<void> takeScreenshotLight(IntegrationTestWidgetsFlutterBinding binding, String name) =>
|
||||
_takeScreenshot(binding, name, _themeLight);
|
||||
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(
|
||||
ScreenshotArgs(
|
||||
name: name,
|
||||
deviceName: const String.fromEnvironment('deviceName').replaceAll(' ', '_').toLowerCase(),
|
||||
deviceName: const String.fromEnvironment('deviceName'),
|
||||
platformFolder: _platformFolder,
|
||||
backgroundColor: (
|
||||
r: backgroundColor.red,
|
||||
g: backgroundColor.green,
|
||||
b: backgroundColor.blue,
|
||||
a: backgroundColor.alpha,
|
||||
),
|
||||
isDark: isDark,
|
||||
backgroundColor: backgroundColor.value.toRadixString(16),
|
||||
isDark: theme.brightness == Brightness.dark,
|
||||
).toString(),
|
||||
);
|
||||
await pumpAndSettle();
|
||||
|
|
|
@ -31,23 +31,15 @@ Future<int> main(List<String> args) async {
|
|||
final screenshotName = filePath.path.split('/').last.replaceAll('.png', '');
|
||||
final screenshotBytes = File(filePath.path).readAsBytesSync();
|
||||
final screenshot = decodePng(Uint8List.fromList(screenshotBytes))!;
|
||||
final topLeftPixel = screenshot.getPixel(0, 0);
|
||||
|
||||
final screenshotArgs = ScreenshotArgs(
|
||||
final screenshotArgs = ScreenshotArgs.fromRawName(
|
||||
name: screenshotName,
|
||||
deviceName: device,
|
||||
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 =
|
||||
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(
|
||||
encodePng(
|
||||
screenshot.convertToStoreScreenshot(
|
||||
|
|
|
@ -4,19 +4,34 @@ class ScreenshotArgs {
|
|||
final String name;
|
||||
final String deviceName;
|
||||
final String platformFolder;
|
||||
final ({int r, int g, int b, int a}) backgroundColor;
|
||||
final String backgroundColor;
|
||||
final bool isDark;
|
||||
|
||||
const ScreenshotArgs({
|
||||
static const _pathArgsDelimited = '_';
|
||||
|
||||
ScreenshotArgs({
|
||||
required this.name,
|
||||
required this.deviceName,
|
||||
required String deviceName,
|
||||
required this.platformFolder,
|
||||
required this.backgroundColor,
|
||||
required this.isDark,
|
||||
});
|
||||
}) : deviceName = deviceName.replaceAll(' ', _pathArgsDelimited).toLowerCase();
|
||||
|
||||
String toPathRaw() => 'screenshots/generated/raw/$platformFolder/$deviceName/$name.png';
|
||||
String toPath() => 'screenshots/generated/$platformFolder/$deviceName/$name.png';
|
||||
ScreenshotArgs.fromRawName({
|
||||
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
|
||||
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._fromJson(Map<String, dynamic> data) {
|
||||
final colorChannels = data['backgroundColor'] as List;
|
||||
return ScreenshotArgs(
|
||||
name: data['name'] as String,
|
||||
deviceName: data['deviceName'] as String,
|
||||
platformFolder: data['platformFolder'] as String,
|
||||
backgroundColor: (
|
||||
r: colorChannels[0] as int,
|
||||
g: colorChannels[1] as int,
|
||||
b: colorChannels[2] as int,
|
||||
a: colorChannels[3] as int,
|
||||
),
|
||||
backgroundColor: data['backgroundColor'] as String,
|
||||
isDark: data['isDark'] as bool,
|
||||
);
|
||||
}
|
||||
|
@ -44,12 +53,7 @@ class ScreenshotArgs {
|
|||
"name": name,
|
||||
"deviceName": deviceName,
|
||||
"platformFolder": platformFolder,
|
||||
"backgroundColor": [
|
||||
backgroundColor.r,
|
||||
backgroundColor.g,
|
||||
backgroundColor.b,
|
||||
backgroundColor.a,
|
||||
],
|
||||
"backgroundColor": backgroundColor,
|
||||
"isDark": isDark,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue