-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[adaptive_style] rework with extension types
- Loading branch information
Francesco Iapicca
committed
Apr 28, 2024
1 parent
59b6b50
commit c05b284
Showing
13 changed files
with
163 additions
and
148 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
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 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,42 @@ | ||
// import 'package:flutter/widgets.dart'; | ||
// import 'package:yak_flutter/yak_flutter.dart'; | ||
// import 'extension.dart'; | ||
// import 'device_size.dart'; | ||
|
||
// typedef AdaptiveSizeNotifier = RestrictedNotifier<AdaptiveSizeData>; | ||
|
||
// final class AdaptiveSizeData { | ||
// const AdaptiveSizeData({ | ||
// required this.screenSize, | ||
// required this.scale, | ||
// required this.availableSizes, | ||
// required this.mostSimilarDeviceSize, | ||
// }); | ||
|
||
// // factory AdaptiveSizeData.fromSize( | ||
// // Size size, { | ||
// // List<DeviceSize> availableSizes = DeviceSize.values, | ||
// // }) { | ||
// // final mostSimilarDeviceSize = availableSizes.mostSimilarTo(size); | ||
// // final scale = mostSimilarDeviceSize.size.closestDimentionScale(size); | ||
|
||
// // return AdaptiveSizeData( | ||
// // availableSizes: availableSizes, | ||
// // realScreenSize: size, | ||
// // mostSimilarDeviceSize: mostSimilarDeviceSize, | ||
// // scale: scale, | ||
// // ); | ||
// // } | ||
|
||
// final Size screenSize; | ||
// final Offset widthScale, ; | ||
// final List<DeviceSize> availableSizes; | ||
// final DeviceSize mostSimilarDeviceSize; | ||
|
||
// @override | ||
// bool operator ==(Object other) => | ||
// other is AdaptiveSizeData && other.hashCode == hashCode; | ||
|
||
// @override | ||
// int get hashCode => Object.hash(screenSize, availableSizes); | ||
// } |
This file was deleted.
Oops, something went wrong.
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 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,27 +1,36 @@ | ||
import 'dart:ui' show Size; | ||
import 'package:flutter/widgets.dart' show Orientation; | ||
|
||
/// a collection of well known screen dimesions | ||
/// as offered by [chrome device toolbar] | ||
enum DeviceSize { | ||
iphoneSE(Size(375, 667)), | ||
iphoneXR(Size(414, 896)), | ||
iphone12PRO(Size(390, 844)), | ||
iphone14PRO(Size(430, 932)), | ||
pixel7(Size(412, 915)), | ||
galaxyS8Plus(Size(360, 740)), | ||
galaxyS20Ultra(Size(412, 915)), | ||
iPadMini(Size(768, 1024)), | ||
iPadAir(Size(820, 1180)), | ||
iPadPro(Size(1024, 1366)), | ||
surfacePro7(Size(912, 1368)), | ||
surfaceDuo(Size(540, 720)), | ||
galaxyFold(Size(280, 653)), | ||
galaxyA51(Size(412, 914)), | ||
galaxyA71(Size(412, 914)), | ||
nestHub(Size(1024, 600)), | ||
nestHubMax(Size(1280, 800)); | ||
const DeviceSize(this.size); | ||
// enum Orientation { | ||
// landscape, | ||
// portrait, | ||
// } | ||
|
||
final Size size; | ||
extension type const DeviceSize._(Size value) implements Size { | ||
const DeviceSize(Size value) : this._(value); | ||
static const iphoneSE = DeviceSize(Size(375, 667)); | ||
static const iphoneXR = DeviceSize(Size(414, 896)); | ||
static const iphone12PRO = DeviceSize(Size(390, 844)); | ||
static const iphone14PRO = DeviceSize(Size(430, 932)); | ||
static const pixel7 = DeviceSize(Size(412, 915)); | ||
static const galaxyS8Plus = DeviceSize(Size(360, 740)); | ||
static const galaxyS20Ultra = DeviceSize(Size(412, 915)); | ||
static const iPadMini = DeviceSize(Size(768, 1024)); | ||
static const iPadAir = DeviceSize(Size(820, 1180)); | ||
static const iPadPro = DeviceSize(Size(1024, 1366)); | ||
static const surfacePro7 = DeviceSize(Size(912, 1368)); | ||
static const surfaceDuo = DeviceSize(Size(540, 720)); | ||
static const galaxyFold = DeviceSize(Size(280, 653)); | ||
static const galaxyA51 = DeviceSize(Size(412, 914)); | ||
static const galaxyA71 = DeviceSize(Size(412, 914)); | ||
static const nestHub = DeviceSize(Size(1024, 600)); | ||
static const nestHubMax = DeviceSize(Size(1280, 800)); | ||
|
||
Orientation get orientation => | ||
aspectRatio <= 1 ? Orientation.portrait : Orientation.landscape; | ||
|
||
DeviceSize flip() => DeviceSize(Size(height, width)); | ||
} |
Oops, something went wrong.