Skip to content

Commit d68b7b3

Browse files
committed
⚗️ Update photo_manager and some flag getters for MacOS support.
1 parent efeda8d commit d68b7b3

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

lib/src/widget/asset_picker.dart

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ class AssetPicker extends StatelessWidget {
125125
}
126126
}
127127

128-
/// Whether the current platform is iOS.
129-
/// 当前平台是否iOS
130-
bool get isIOS => Platform.isIOS;
128+
/// Whether the current platform is Apple OS.
129+
/// 当前平台是否苹果系列系统 (iOS & MacOS)
130+
bool get isAppleOS => Platform.isIOS || Platform.isMacOS;
131131

132132
/// Space between asset item widget [_succeedItem].
133133
/// 资源部件之间的间隔
@@ -141,9 +141,9 @@ class AssetPicker extends StatelessWidget {
141141
/// 底部操作栏的高度
142142
double get bottomActionBarHeight => kToolbarHeight / 1.1;
143143

144-
/// Blur radius in iOS layout mode.
145-
/// iOS布局方式下的模糊度
146-
double get iOSBlurRadius => 15.0;
144+
/// Blur radius in Apple OS layout mode.
145+
/// 苹果系列系统布局方式下的模糊度
146+
double get appleOSBlurRadius => 15.0;
147147

148148
/// [Curve] when triggering path switching.
149149
/// 切换路径时的动画曲线
@@ -249,7 +249,7 @@ class AssetPicker extends StatelessWidget {
249249
splashFactory: InkSplash.splashFactory,
250250
onTap: () => provider.switchPath(pathEntity),
251251
child: SizedBox(
252-
height: isIOS ? 64.0 : 52.0,
252+
height: isAppleOS ? 64.0 : 52.0,
253253
child: Row(
254254
children: <Widget>[
255255
RepaintBoundary(
@@ -339,21 +339,21 @@ class AssetPicker extends StatelessWidget {
339339
Widget get pathEntityListWidget {
340340
final double appBarHeight = kToolbarHeight + Screens.topSafeHeight;
341341
final double maxHeight =
342-
isIOS ? Screens.height - appBarHeight : Screens.height * 0.75;
342+
isAppleOS ? Screens.height - appBarHeight : Screens.height * 0.75;
343343
return Selector<AssetPickerProvider, bool>(
344344
selector: (BuildContext _, AssetPickerProvider provider) =>
345345
provider.isSwitchingPath,
346346
builder: (BuildContext _, bool isSwitchingPath, Widget __) {
347347
return AnimatedPositioned(
348348
duration: switchingPathDuration,
349349
curve: switchingPathCurve,
350-
top: isIOS
350+
top: isAppleOS
351351
? !isSwitchingPath ? -maxHeight : appBarHeight
352352
: -(!isSwitchingPath ? maxHeight : 1.0),
353353
child: AnimatedOpacity(
354354
duration: switchingPathDuration,
355355
curve: switchingPathCurve,
356-
opacity: !isIOS || isSwitchingPath ? 1.0 : 0.0,
356+
opacity: !isAppleOS || isSwitchingPath ? 1.0 : 0.0,
357357
child: Container(
358358
width: Screens.width,
359359
height: maxHeight,
@@ -493,7 +493,7 @@ class AssetPicker extends StatelessWidget {
493493
horizontal: 2.0,
494494
vertical: 2.0,
495495
),
496-
decoration: !isIOS
496+
decoration: !isAppleOS
497497
? BoxDecoration(
498498
borderRadius: BorderRadius.circular(2.0),
499499
color: theme.iconTheme.color.withOpacity(0.75),
@@ -502,11 +502,11 @@ class AssetPicker extends StatelessWidget {
502502
child: Text(
503503
Constants.textDelegate.gifIndicator,
504504
style: TextStyle(
505-
color: isIOS
505+
color: isAppleOS
506506
? theme.textTheme.bodyText2.color
507507
: theme.primaryColor,
508-
fontSize: isIOS ? 14.0 : 12.0,
509-
fontWeight: isIOS ? FontWeight.w500 : FontWeight.normal,
508+
fontSize: isAppleOS ? 14.0 : 12.0,
509+
fontWeight: isAppleOS ? FontWeight.w500 : FontWeight.normal,
510510
),
511511
),
512512
),
@@ -599,9 +599,9 @@ class AssetPicker extends StatelessWidget {
599599
},
600600
child: AnimatedContainer(
601601
duration: switchingPathDuration,
602-
margin: EdgeInsets.all(isIOS ? 10.0 : 6.0),
603-
width: isIOS ? 28.0 : 20.0,
604-
height: isIOS ? 28.0 : 20.0,
602+
margin: EdgeInsets.all(isAppleOS ? 10.0 : 6.0),
603+
width: isAppleOS ? 28.0 : 20.0,
604+
height: isAppleOS ? 28.0 : 20.0,
605605
decoration: BoxDecoration(
606606
border: !selected
607607
? Border.all(color: Colors.white, width: 2.0)
@@ -617,9 +617,9 @@ class AssetPicker extends StatelessWidget {
617617
'${selectedAssets.toList().indexOf(asset) + 1}',
618618
style: TextStyle(
619619
color: Colors.white,
620-
fontSize: isIOS ? 16.0 : 14.0,
620+
fontSize: isAppleOS ? 16.0 : 14.0,
621621
fontWeight:
622-
isIOS ? FontWeight.w600 : FontWeight.normal,
622+
isAppleOS ? FontWeight.w600 : FontWeight.normal,
623623
),
624624
)
625625
: const SizedBox.shrink(),
@@ -656,7 +656,7 @@ class AssetPicker extends StatelessWidget {
656656
Widget __,
657657
) {
658658
return GridView.builder(
659-
padding: isIOS
659+
padding: isAppleOS
660660
? EdgeInsets.only(
661661
top: Screens.topSafeHeight + kToolbarHeight,
662662
bottom: bottomActionBarHeight,
@@ -782,18 +782,18 @@ class AssetPicker extends StatelessWidget {
782782
right: 20.0,
783783
bottom: Screens.bottomSafeHeight,
784784
),
785-
color: theme.primaryColor.withOpacity(isIOS ? 0.90 : 1.0),
785+
color: theme.primaryColor.withOpacity(isAppleOS ? 0.90 : 1.0),
786786
child: Row(children: <Widget>[
787787
previewButton(context),
788-
if (isIOS) const Spacer(),
789-
if (isIOS) confirmButton(context),
788+
if (isAppleOS) const Spacer(),
789+
if (isAppleOS) confirmButton(context),
790790
]),
791791
);
792-
if (isIOS) {
792+
if (isAppleOS) {
793793
child = ClipRect(
794794
child: BackdropFilter(
795795
filter:
796-
ui.ImageFilter.blur(sigmaX: iOSBlurRadius, sigmaY: iOSBlurRadius),
796+
ui.ImageFilter.blur(sigmaX: appleOSBlurRadius, sigmaY: appleOSBlurRadius),
797797
child: child,
798798
),
799799
);
@@ -805,11 +805,11 @@ class AssetPicker extends StatelessWidget {
805805
/// 返回按钮
806806
Widget backButton(BuildContext context) => Padding(
807807
padding: const EdgeInsets.symmetric(vertical: 4.0),
808-
child: isIOS
808+
child: isAppleOS
809809
? GestureDetector(
810810
onTap: Navigator.of(context).maybePop,
811811
child: Container(
812-
margin: isIOS
812+
margin: isAppleOS
813813
? const EdgeInsets.symmetric(horizontal: 20.0)
814814
: null,
815815
child: IntrinsicWidth(
@@ -828,9 +828,9 @@ class AssetPicker extends StatelessWidget {
828828
),
829829
);
830830

831-
/// Layout for iOS devices.
832-
/// iOS设备的选择器布局
833-
Widget iOSLayout(BuildContext context) {
831+
/// Layout for Apple OS devices.
832+
/// 苹果系列设备的选择器布局
833+
Widget appleOSLayout(BuildContext context) {
834834
return Stack(
835835
children: <Widget>[
836836
Positioned.fill(
@@ -868,7 +868,7 @@ class AssetPicker extends StatelessWidget {
868868
title: pathEntitySelector,
869869
leading: backButton(context),
870870
actionsPadding: const EdgeInsets.only(right: 14.0),
871-
blurRadius: iOSBlurRadius,
871+
blurRadius: appleOSBlurRadius,
872872
),
873873
],
874874
);
@@ -923,7 +923,7 @@ class AssetPicker extends StatelessWidget {
923923
value: provider,
924924
child: Material(
925925
color: theme.canvasColor,
926-
child: isIOS ? iOSLayout(context) : androidLayout(context),
926+
child: isAppleOS ? appleOSLayout(context) : androidLayout(context),
927927
),
928928
),
929929
),

lib/src/widget/asset_picker_viewer.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
141141
/// 底部详情部件的高度
142142
double get bottomDetailHeight => 140.0;
143143

144-
/// Whether the current platform is iOS.
145-
/// 当前平台是否iOS
146-
bool get isIOS => Platform.isIOS;
144+
/// Whether the current platform is Apple OS.
145+
/// 当前平台是否为苹果系列系统
146+
bool get isAppleOS => Platform.isIOS || Platform.isMacOS;
147147

148148
@override
149149
void initState() {
@@ -339,7 +339,7 @@ class AssetPickerViewerState extends State<AssetPickerViewer>
339339
Widget __,
340340
) {
341341
return Container(
342-
margin: isIOS ? const EdgeInsets.only(right: 10.0) : null,
342+
margin: isAppleOS ? const EdgeInsets.only(right: 10.0) : null,
343343
child: MaterialButton(
344344
minWidth: provider.isSelectedNotEmpty ? 48.0 : 20.0,
345345
height: 32.0,

lib/src/widget/platform_progress_indicator.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ class PlatformProgressIndicator extends StatelessWidget {
2727
final double value;
2828
final Brightness brightness;
2929

30+
bool get isAppleOS => Platform.isIOS || Platform.isMacOS;
31+
3032
@override
3133
Widget build(BuildContext context) {
3234
return SizedBox.fromSize(
3335
size: Size.square(size),
34-
child: Platform.isIOS
36+
child: isAppleOS
3537
? CupertinoTheme(
3638
data: const CupertinoThemeData(brightness: Brightness.dark),
3739
child: CupertinoActivityIndicator(radius: radius),

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ dependencies:
1212
sdk: flutter
1313

1414
extended_image: ">=0.7.3+1 <2.0.0"
15-
photo_manager: ">=0.5.1 <2.0.0"
15+
photo_manager: ">=0.5.2 <2.0.0"
1616
provider: ">=4.1.0 <5.0.0"
17-
video_player: ">=0.10.10 <2.0.0"
17+
video_player: ">=0.10.11 <2.0.0"
1818

1919
dev_dependencies:
2020
flutter_test:

0 commit comments

Comments
 (0)