Skip to content

Commit

Permalink
Merge pull request #36 from bamlab/Feat/add-devices-pixel9-and-iphone16
Browse files Browse the repository at this point in the history
Feat/update devices pixel9 iphone16
  • Loading branch information
T-moz authored Oct 14, 2024
2 parents e070fe2 + 96ed692 commit 5eefd27
Show file tree
Hide file tree
Showing 37 changed files with 105 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) async {

```dart
final defaultDeviceConfigs = {
iPhone13,
pixel5,
iPhone16,
pixel9,
};
```

Expand Down
Binary file modified assets/keyboards/iPhone_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keyboards/iPhone_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/keyboards/pixel_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keyboards/pixel_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions example/multi_packages_app/app/test/flutter_test_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:flutter_test/flutter_test.dart';

final defaultDeviceConfigs = {
iPhone8,
iPhone13,
iPhone16,
iPadPro,
desktop,
pixel5,
pixel9,
};

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:flutter_test/flutter_test.dart';

final defaultDeviceConfigs = {
iPhone8,
iPhone13,
iPhone16,
iPadPro,
desktop,
pixel5,
pixel9,
};

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
Expand Down
2 changes: 1 addition & 1 deletion example/simple_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: "../.."
relative: true
source: path
version: "0.6.0"
version: "0.7.2"
async:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions example/simple_app/test/flutter_test_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:flutter_test/flutter_test.dart';

final defaultDeviceConfigs = {
iPhone8,
iPhone13,
iPhone16,
iPadPro,
desktop,
pixel5,
pixel9,
};

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
Expand Down
Binary file modified example/simple_app/test/src/preview/custom_path_iPhone_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/simple_app/test/src/preview/custom_path_pixel_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/simple_app/test/src/preview/iPhone_13-app_fade_in_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/simple_app/test/src/preview/iPhone_13-app_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/simple_app/test/src/preview/pixel_5-app_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 44 additions & 8 deletions lib/src/adaptive/devices_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import 'package:flutter/painting.dart';
enum _Device {
iPhone_8,
iPhone_13,
iPhone_16,
iPadPro,
desktop,
pixel_5;
pixel_5,
pixel_9;

String get keyboardName => 'assets/keyboards/${this.name}.png';
}
Expand All @@ -33,24 +35,41 @@ final WindowConfigData iPhone13 = WindowConfigData(
size: const Size(390, 844),
pixelDensity: 3,
safeAreaPadding: const EdgeInsets.only(top: 47, bottom: 34),
keyboardSize: const Size(390, 302),
keyboardSize: const Size(390, 336),
borderRadius: const BorderRadius.all(
Radius.circular(48),
Radius.circular(47),
),
homeIndicator: const HomeIndicatorData(8, Size(135, 5)),
homeIndicator: const HomeIndicatorData(8, Size(139, 5)),
notchSize: const Size(154, 32),
targetPlatform: TargetPlatform.iOS,
keyboardName: _Device.iPhone_13.keyboardName,
keyboardPackage: _keyboardPackage,
);

/// [WindowConfigData] for an iPhone 16.
final WindowConfigData iPhone16 = WindowConfigData(
_Device.iPhone_16.name,
size: const Size(393, 852),
pixelDensity: 3,
safeAreaPadding: const EdgeInsets.only(top: 59, bottom: 34),
keyboardSize: const Size(393, 336),
borderRadius: const BorderRadius.all(
Radius.circular(55),
),
homeIndicator: const HomeIndicatorData(8, Size(140, 5)),
dynamicIsland: DynamicIslandData(11, Size(125, 37)),
targetPlatform: TargetPlatform.iOS,
keyboardName: _Device.iPhone_16.keyboardName,
keyboardPackage: _keyboardPackage,
);

/// [WindowConfigData] for a Google Pixel 5.
final WindowConfigData pixel5 = WindowConfigData(
_Device.pixel_5.name,
size: const Size(360, 764),
pixelDensity: 3,
safeAreaPadding: const EdgeInsets.only(top: 24),
keyboardSize: const Size(360, 297),
size: const Size(392, 850),
pixelDensity: 2.75,
safeAreaPadding: const EdgeInsets.only(top: 49, bottom: 24),
keyboardSize: const Size(392, 302),
borderRadius: const BorderRadius.all(
Radius.circular(32),
),
Expand All @@ -61,6 +80,23 @@ final WindowConfigData pixel5 = WindowConfigData(
keyboardPackage: _keyboardPackage,
);

/// [WindowConfigData] for a Google Pixel 9.
final WindowConfigData pixel9 = WindowConfigData(
_Device.pixel_9.name,
size: const Size(412, 923),
pixelDensity: 2.625,
safeAreaPadding: const EdgeInsets.only(top: 51, bottom: 24),
keyboardSize: const Size(412, 360),
borderRadius: const BorderRadius.all(
Radius.circular(55),
),
homeIndicator: const HomeIndicatorData(10, Size(108, 4)),
targetPlatform: TargetPlatform.android,
punchHole: const PunchHoleData(Offset(190, 17), 31),
keyboardName: _Device.pixel_9.keyboardName,
keyboardPackage: _keyboardPackage,
);

/// [WindowConfigData] for a 12.9" iPad Pro.
final WindowConfigData iPadPro = WindowConfigData(
_Device.iPadPro.name,
Expand Down
29 changes: 29 additions & 0 deletions lib/src/adaptive/widgets/layers/hardware_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class HardwareLayer extends StatelessWidget {
children: [
child,
const _Notch(),
const _DynamicIsland(),
const _PunchHole(),
],
),
Expand Down Expand Up @@ -72,6 +73,34 @@ class _Notch extends StatelessWidget {
}
}

class _DynamicIsland extends StatelessWidget {
const _DynamicIsland();

@override
Widget build(BuildContext context) {
final windowConfig = WindowConfig.of(context);

final dynamicIslandData = windowConfig.dynamicIsland;

if (dynamicIslandData == null) return const SizedBox();

return Positioned(
top: dynamicIslandData.top,
width: windowConfig.size.width,
child: Center(
child: Container(
height: dynamicIslandData.size.height,
width: dynamicIslandData.size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(dynamicIslandData.size.height),
color: Colors.black,
),
),
),
);
}
}

class _PunchHole extends StatelessWidget {
const _PunchHole();

Expand Down
22 changes: 22 additions & 0 deletions lib/src/adaptive/window_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ class HomeIndicatorData extends Equatable {
List<Object?> get props => [bottom, size];
}

/// Describe the dynamic island on top of apps, expressed in `dp`.
///
/// This is null when the device has no dynamic island.
class DynamicIslandData extends Equatable {
const DynamicIslandData(this.top, this.size);

/// top offset of the indicator, expressed in `dp`.
final double top;

/// Size of the indicator, expressed in `dp`.
final Size size;

@override
List<Object?> get props => [top, size];
}

/// Establish a subtree in which adaptive window resolves to the given data.
/// Use `WindowConfig.of(context)` to retrieve the data in any child widget.
///
Expand Down Expand Up @@ -78,6 +94,7 @@ class WindowConfigData extends Equatable {
this.keyboardPackage,
this.keyboardSize,
this.notchSize,
this.dynamicIsland,
this.punchHole,
this.homeIndicator,
}) : viewInsets = ViewPaddingImpl(
Expand Down Expand Up @@ -111,6 +128,11 @@ class WindowConfigData extends Equatable {
/// This is null when the device has no notch.
final Size? notchSize;

/// Describe the size of the device physical screen top dynamic island in `dp`.
///
/// This is null when the device has no dynamic island.
final DynamicIslandData? dynamicIsland;

/// Describe the size of the device physical screen camera punch hole in `dp`.
///
/// This is null when the device has no punch hole.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ See: https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html

/// Set the devices variant on which you want your test to run.
///
/// Eg [iPhone8], [iPhone13], [iPadPro], [desktop], [pixel5].
/// Eg [iPhone8], [iPhone13], [iPhone16], [iPadPro], [desktop], [pixel5], [pixel9].
void setDeviceVariants(Set<WindowConfigData> deviceConfigs) {
_deviceVariant = WindowVariant(deviceConfigs);
}
Expand Down

0 comments on commit 5eefd27

Please sign in to comment.