diff --git a/CHANGELOG.md b/CHANGELOG.md index 64362b9..75e520b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* **BREAKING**: feat: Add keyboardName to WindowConfigData + - fix: It's now possible to use custom devices as WindowConfigData variant * feat: awaitImages now support FadeInImage. * improvement: use pump instead of pumpAndSettle in awaitImages. * feat: add path and version argument to expectGolden method. diff --git a/lib/src/adaptive/devices_data.dart b/lib/src/adaptive/devices_data.dart index bdd57ad..bb01c5e 100644 --- a/lib/src/adaptive/devices_data.dart +++ b/lib/src/adaptive/devices_data.dart @@ -7,7 +7,9 @@ enum _Device { iPhone_13, iPadPro, desktop, - pixel_5, + pixel_5; + + String get keyboardName => 'assets/keyboards/${this.name}.png'; } /// [WindowConfigData] for an iPhone 8. @@ -19,6 +21,7 @@ final WindowConfigData iPhone8 = WindowConfigData( keyboardSize: const Size(375, 218), borderRadius: BorderRadius.zero, targetPlatform: TargetPlatform.iOS, + keyboardName: _Device.iPhone_8.keyboardName, ); /// [WindowConfigData] for an iPhone 13. @@ -34,6 +37,7 @@ final WindowConfigData iPhone13 = WindowConfigData( homeIndicator: const HomeIndicatorData(8, Size(135, 5)), notchSize: const Size(154, 32), targetPlatform: TargetPlatform.iOS, + keyboardName: _Device.iPhone_13.keyboardName, ); /// [WindowConfigData] for a Google Pixel 5. @@ -49,6 +53,7 @@ final WindowConfigData pixel5 = WindowConfigData( homeIndicator: const HomeIndicatorData(8, Size(72, 2)), targetPlatform: TargetPlatform.android, punchHole: const PunchHoleData(Offset(12, 12), 25), + keyboardName: _Device.pixel_5.keyboardName, ); /// [WindowConfigData] for a 12.9" iPad Pro. @@ -63,6 +68,7 @@ final WindowConfigData iPadPro = WindowConfigData( ), homeIndicator: const HomeIndicatorData(8, Size(315, 5)), targetPlatform: TargetPlatform.iOS, + keyboardName: _Device.iPadPro.keyboardName, ); /// [WindowConfigData] for a basic 1080p web or desktop window. @@ -73,4 +79,5 @@ final WindowConfigData desktop = WindowConfigData( safeAreaPadding: EdgeInsets.zero, borderRadius: BorderRadius.zero, targetPlatform: TargetPlatform.linux, + keyboardName: _Device.desktop.keyboardName, ); diff --git a/lib/src/adaptive/widgets/layers/keyboard_layer.dart b/lib/src/adaptive/widgets/layers/keyboard_layer.dart index 6615a09..2ed1613 100644 --- a/lib/src/adaptive/widgets/layers/keyboard_layer.dart +++ b/lib/src/adaptive/widgets/layers/keyboard_layer.dart @@ -101,7 +101,7 @@ class _KeyboardDisplayerState extends State { return Positioned( bottom: 0, child: Image.asset( - 'assets/keyboards/${windowConfig.name}.png', + windowConfig.keyboardName, height: windowConfig.keyboardSize?.height, width: windowConfig.keyboardSize?.width, package: 'adaptive_test', diff --git a/lib/src/adaptive/window_size.dart b/lib/src/adaptive/window_size.dart index 2ba230e..b07b553 100644 --- a/lib/src/adaptive/window_size.dart +++ b/lib/src/adaptive/window_size.dart @@ -74,6 +74,7 @@ class WindowConfigData extends Equatable { required this.targetPlatform, required this.borderRadius, required EdgeInsets safeAreaPadding, + required this.keyboardName, this.keyboardSize, this.notchSize, this.punchHole, @@ -142,6 +143,9 @@ class WindowConfigData extends Equatable { /// This represent the size of the device, expressed in `px`. final Size physicalSize; + /// Name of the image asset that represent the keyboard. + final String keyboardName; + @override List get props => [ name, @@ -156,6 +160,7 @@ class WindowConfigData extends Equatable { viewInsets, padding, physicalSize, + keyboardName, ]; }