-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
186 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/widgetbook/lib/src/addons/device_addon/frame_builders/device_frame_builder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/src/addons/device_addon/frame_builders/frame_builder.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
|
||
DeviceInfo mapDeviceToDeviceInfo(Device device) { | ||
final map = { | ||
Apple.iPhone12Mini: Devices.ios.iPhone12Mini, | ||
Apple.iPhone12: Devices.ios.iPhone12, | ||
Apple.iPhone12ProMax: Devices.ios.iPhone12ProMax, | ||
Apple.iPhone13Mini: Devices.ios.iPhone13Mini, | ||
Apple.iPhone13: Devices.ios.iPhone13, | ||
Apple.iPhone13ProMax: Devices.ios.iPhone13ProMax, | ||
Apple.iPhoneSE2020: Devices.ios.iPhoneSE, | ||
// not sure what to map this device to | ||
// Apple.iPadAir9Inch: Devices.ios.iPadAir4, | ||
Apple.iPad10Inch: Devices.ios.iPad, | ||
Apple.iPadPro11Inch: Devices.ios.iPadPro11Inches, | ||
}; | ||
|
||
final mappedDevice = map[device] ?? | ||
DeviceInfo.genericPhone( | ||
platform: TargetPlatform.iOS, | ||
id: 'custom', | ||
name: 'custom', | ||
screenSize: Size( | ||
device.resolution.logicalSize.width, | ||
device.resolution.logicalSize.height, | ||
), | ||
pixelRatio: device.resolution.scaleFactor, | ||
); | ||
|
||
return mappedDevice; | ||
} | ||
|
||
class DeviceFrameBuilder extends FrameBuilder { | ||
DeviceFrameBuilder({ | ||
required super.devices, | ||
}) : super( | ||
name: 'Device Frame', | ||
); | ||
|
||
@override | ||
Widget builder(BuildContext context, Widget child) { | ||
return DeviceFrame( | ||
device: mapDeviceToDeviceInfo(context.device), | ||
screen: child, | ||
); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/widgetbook/lib/src/addons/device_addon/frame_builders/frame_builders.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export './device_frame_builder.dart'; | ||
export './widgetbook_frame_builder.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
packages/widgetbook/lib/src/extensions/list_extension.dart
This file was deleted.
Oops, something went wrong.