Skip to content

Commit 862ac04

Browse files
authored
🐛 Fix UI layouts (#634)
1 parent 2d2a786 commit 862ac04

15 files changed

+99
-39
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ that can be found in the LICENSE file. -->
99
1010
## Unreleased
1111

12-
*None.*
12+
### Improvements
13+
14+
- Do not mute the Live Photo during the preview.
15+
16+
### Fixes
17+
18+
- Fix the GIF indicator's layout.
19+
- Fix the directionality with the reverted grid item.
1320

1421
## 9.3.0
1522

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
FF5A0AA64F3B1C88D3552E39 /* Pods-Runner.release.xcconfig */,
7777
6B0C8420452B45A5D1F1C0C7 /* Pods-Runner.profile.xcconfig */,
7878
);
79-
name = Pods;
8079
path = Pods;
8180
sourceTree = "<group>";
8281
};

example/ios/Runner/Info.plist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>CADisableMinimumFrameDurationOnPhone</key>
6+
<true/>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>$(DEVELOPMENT_LANGUAGE)</string>
79
<key>CFBundleDisplayName</key>
@@ -30,6 +32,8 @@
3032
<string>Take a video for display</string>
3133
<key>NSPhotoLibraryUsageDescription</key>
3234
<string>Read your photos for display</string>
35+
<key>UIApplicationSupportsIndirectInputEvents</key>
36+
<true/>
3337
<key>UILaunchStoryboardName</key>
3438
<string>LaunchScreen</string>
3539
<key>UIMainStoryboardFile</key>
@@ -47,9 +51,5 @@
4751
<string>UIInterfaceOrientationLandscapeLeft</string>
4852
<string>UIInterfaceOrientationLandscapeRight</string>
4953
</array>
50-
<key>CADisableMinimumFrameDurationOnPhone</key>
51-
<true/>
52-
<key>UIApplicationSupportsIndirectInputEvents</key>
53-
<true/>
5454
</dict>
5555
</plist>

example/lib/constants/picker_method.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,29 @@ class PickMethod {
9696
);
9797
}
9898

99+
factory PickMethod.livePhoto(BuildContext context, int maxAssetsCount) {
100+
return PickMethod(
101+
icon: '🎬',
102+
name: context.l10n.pickMethodLivePhotoName,
103+
description: context.l10n.pickMethodLivePhotoDescription,
104+
method: (BuildContext context, List<AssetEntity> assets) {
105+
return AssetPicker.pickAssets(
106+
context,
107+
pickerConfig: AssetPickerConfig(
108+
maxAssets: maxAssetsCount,
109+
selectedAssets: assets,
110+
requestType: RequestType.image,
111+
filterOptions: CustomFilter.sql(
112+
where: '${CustomColumns.base.mediaType} = 1'
113+
' AND '
114+
'${CustomColumns.darwin.mediaSubtypes} & (1 << 3) = (1 << 3)',
115+
),
116+
),
117+
);
118+
},
119+
);
120+
}
121+
99122
factory PickMethod.camera({
100123
required BuildContext context,
101124
required int maxAssetsCount,

example/lib/l10n/app_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"pickMethodVideoDescription": "Only pick video from device. (Includes Live Photos on iOS and macOS.)",
1515
"pickMethodAudioName": "Audio picker",
1616
"pickMethodAudioDescription": "Only pick audio from device.",
17+
"pickMethodLivePhotoName": "Live Photo picker",
18+
"pickMethodLivePhotoDescription": "Only pick Live Photos from device.",
1719
"pickMethodCameraName": "Pick from camera",
1820
"pickMethodCameraDescription": "Allow to pick an asset through camera.",
1921
"pickMethodCameraAndStayName": "Pick from camera and stay",

example/lib/l10n/app_zh.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
"pickMethodImageName": "图片选择",
1414
"pickMethodImageDescription": "仅选择图片。",
1515
"pickMethodVideoName": "视频选择",
16-
"pickMethodVideoDescription": "仅选择视频。(在 iOS 和 macOS 上将包括实况图片。)",
16+
"pickMethodVideoDescription": "仅选择视频。",
1717
"pickMethodAudioName": "音频选择",
1818
"pickMethodAudioDescription": "仅选择音频。",
19+
"pickMethodLivePhotoName": "实况图片选择",
20+
"pickMethodLivePhotoDescription": "仅选择实况图片。",
1921
"pickMethodCameraName": "从相机生成选择",
2022
"pickMethodCameraDescription": "通过相机拍照生成并选择资源",
2123
"pickMethodCameraAndStayName": "从相机生成选择并停留",

example/lib/l10n/gen/app_localizations.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ abstract class AppLocalizations {
180180
/// **'Only pick audio from device.'**
181181
String get pickMethodAudioDescription;
182182

183+
/// No description provided for @pickMethodLivePhotoName.
184+
///
185+
/// In en, this message translates to:
186+
/// **'Live Photo picker'**
187+
String get pickMethodLivePhotoName;
188+
189+
/// No description provided for @pickMethodLivePhotoDescription.
190+
///
191+
/// In en, this message translates to:
192+
/// **'Only pick Live Photos from device.'**
193+
String get pickMethodLivePhotoDescription;
194+
183195
/// No description provided for @pickMethodCameraName.
184196
///
185197
/// In en, this message translates to:

example/lib/l10n/gen/app_localizations_en.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ class AppLocalizationsEn extends AppLocalizations {
5151
@override
5252
String get pickMethodAudioDescription => 'Only pick audio from device.';
5353

54+
@override
55+
String get pickMethodLivePhotoName => 'Live Photo picker';
56+
57+
@override
58+
String get pickMethodLivePhotoDescription =>
59+
'Only pick Live Photos from device.';
60+
5461
@override
5562
String get pickMethodCameraName => 'Pick from camera';
5663

example/lib/l10n/gen/app_localizations_zh.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,20 @@ class AppLocalizationsZh extends AppLocalizations {
4242
String get pickMethodVideoName => '视频选择';
4343

4444
@override
45-
String get pickMethodVideoDescription => '仅选择视频。(在 iOS 和 macOS 上将包括实况图片。)';
45+
String get pickMethodVideoDescription => '仅选择视频。';
4646

4747
@override
4848
String get pickMethodAudioName => '音频选择';
4949

5050
@override
5151
String get pickMethodAudioDescription => '仅选择音频。';
5252

53+
@override
54+
String get pickMethodLivePhotoName => '实况图片选择';
55+
56+
@override
57+
String get pickMethodLivePhotoDescription => '仅选择实况图片。';
58+
5359
@override
5460
String get pickMethodCameraName => '从相机生成选择';
5561

example/lib/pages/multi_assets_page.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by an Apache license that can be found
33
// in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:flutter/material.dart';
68
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
79

@@ -32,6 +34,8 @@ class _MultiAssetsPageState extends State<MultiAssetsPage>
3234
PickMethod.image(context, maxAssetsCount),
3335
PickMethod.video(context, maxAssetsCount),
3436
PickMethod.audio(context, maxAssetsCount),
37+
if (Platform.isIOS || Platform.isMacOS)
38+
PickMethod.livePhoto(context, maxAssetsCount),
3539
PickMethod.camera(
3640
context: context,
3741
maxAssetsCount: maxAssetsCount,

example/lib/pages/single_assets_page.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by an Apache license that can be found
33
// in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:flutter/material.dart';
68
import 'package:wechat_assets_picker/wechat_assets_picker.dart'
79
show AssetEntity;
@@ -32,6 +34,8 @@ class _SingleAssetPageState extends State<SingleAssetPage>
3234
PickMethod.image(context, maxAssetsCount),
3335
PickMethod.video(context, maxAssetsCount),
3436
PickMethod.audio(context, maxAssetsCount),
37+
if (Platform.isIOS || Platform.isMacOS)
38+
PickMethod.livePhoto(context, maxAssetsCount),
3539
PickMethod.camera(
3640
context: context,
3741
maxAssetsCount: maxAssetsCount,

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_assets_picker_demo
22
description: The demo project for the wechat_assets_picker package.
3-
version: 9.2.1+57
3+
version: 9.3.0+58
44
publish_to: none
55

66
environment:

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
408408
return Align(
409409
alignment: Alignment.bottomCenter,
410410
child: Container(
411-
alignment: AlignmentDirectional.centerEnd,
411+
width: double.infinity,
412412
padding: const EdgeInsets.all(6),
413413
decoration: BoxDecoration(
414414
gradient: LinearGradient(
@@ -1227,11 +1227,7 @@ class DefaultAssetPickerBuilderDelegate
12271227
final bool gridRevert = effectiveShouldRevertGrid(context);
12281228
return Selector<DefaultAssetPickerProvider, PathWrapper<AssetPathEntity>?>(
12291229
selector: (_, DefaultAssetPickerProvider p) => p.currentPath,
1230-
builder: (
1231-
BuildContext context,
1232-
PathWrapper<AssetPathEntity>? wrapper,
1233-
_,
1234-
) {
1230+
builder: (context, wrapper, _) {
12351231
// First, we need the count of the assets.
12361232
int totalCount = wrapper?.assetCount ?? 0;
12371233
final Widget? specialItem;
@@ -1270,30 +1266,29 @@ class DefaultAssetPickerBuilderDelegate
12701266
final double topPadding =
12711267
context.topPadding + appBarPreferredSize!.height;
12721268

1269+
final textDirection = Directionality.of(context);
12731270
Widget sliverGrid(BuildContext context, List<AssetEntity> assets) {
12741271
return SliverGrid(
12751272
delegate: SliverChildBuilderDelegate(
1276-
(_, int index) => Builder(
1277-
builder: (BuildContext context) {
1278-
if (gridRevert) {
1279-
if (index < placeholderCount) {
1280-
return const SizedBox.shrink();
1281-
}
1282-
index -= placeholderCount;
1273+
(context, int index) {
1274+
if (gridRevert) {
1275+
if (index < placeholderCount) {
1276+
return const SizedBox.shrink();
12831277
}
1284-
return MergeSemantics(
1285-
child: Directionality(
1286-
textDirection: Directionality.of(context),
1287-
child: assetGridItemBuilder(
1288-
context,
1289-
index,
1290-
assets,
1291-
specialItem: specialItem,
1292-
),
1278+
index -= placeholderCount;
1279+
}
1280+
return MergeSemantics(
1281+
child: Directionality(
1282+
textDirection: textDirection,
1283+
child: assetGridItemBuilder(
1284+
context,
1285+
index,
1286+
assets,
1287+
specialItem: specialItem,
12931288
),
1294-
);
1295-
},
1296-
),
1289+
),
1290+
);
1291+
},
12971292
childCount: assetsGridItemCount(
12981293
context: context,
12991294
assets: assets,

lib/src/widget/builder/image_page_builder.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ class _ImagePageBuilderState extends State<ImagePageBuilder> {
8787
safeSetState(() {
8888
_livePhotoVideoController = c;
8989
});
90-
c
91-
..setVolume(0)
92-
..addListener(() {
93-
safeSetState(() {});
94-
});
90+
c.addListener(() {
91+
safeSetState(() {});
92+
});
9593
}
9694

9795
Widget _imageBuilder(BuildContext context, AssetEntity asset) {

lib/wechat_assets_picker.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by an Apache license that can be found
33
// in the LICENSE file.
44

5+
// ignore: unnecessary_library_name
56
library wechat_assets_picker;
67

78
export 'package:photo_manager/photo_manager.dart';

0 commit comments

Comments
 (0)