Skip to content

German translation for Text Delegate #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
615a757
⚡️ Use precise option for thumbnail
AlexV525 Jun 26, 2021
749ffc8
✨ `AssetPicker.pickAssetsWithDelegate`
AlexV525 Jun 26, 2021
37e3139
✨ `AssetPickerViewer.pushToViewerWithDelegate`
AlexV525 Jun 26, 2021
50b033c
⚡️ Enhance path entities list widget
AlexV525 Jun 26, 2021
519ca1c
💄 Unify appbar
AlexV525 Jun 26, 2021
f20c8c5
🐛 Fix preview widget jump issue
AlexV525 Jun 26, 2021
3910c9c
💄 Sync preview color schemes
AlexV525 Jun 26, 2021
40dcf9e
💄 Use ClipRect to clip the overflowed part
AlexV525 Jun 26, 2021
d80d800
🚸 Reduce duration for the fade image builder
AlexV525 Jun 26, 2021
73c8755
🔥 Remove the usage of fade image builder in grid item
AlexV525 Jun 26, 2021
7f28979
🚀 Sync video preview layouts for WeChat Moment
AlexV525 Jun 26, 2021
fb97b37
♻️ Refactored text delegate with more fields
AlexV525 Jun 26, 2021
50af404
💬 Fix mistaken spelling
AlexV525 Jun 26, 2021
31543e6
💬 Improve words for Chinese text delegate
AlexV525 Jun 26, 2021
addb69e
💬 Add more fields to text delegates
AlexV525 Jun 26, 2021
6f20c77
♻️ Refactored picker delegate to support limited access on iOS
AlexV525 Jun 26, 2021
3a33184
[Text Delegate] Hebrew support for new fields (#163)
yanivshaked Jun 27, 2021
63d3fa2
[Text Delegate] Arabic Support
yanivshaked Jun 27, 2021
336709a
[Text Delegate] Improve English translation
yanivshaked Jun 27, 2021
2db50b4
[Text Delegate] Headline comments fixed
yanivshaked Jun 27, 2021
df15167
[Text Delegate] Russian support for new fields
yanivshaked Jun 27, 2021
0cbd815
🚀 Integrate open settings method
AlexV525 Jun 28, 2021
66eea36
[Text Delegate] Small Russian translation fixes.
greymag Jun 28, 2021
20d8050
🚧 Refactoring grid layout for iOS reverted grid
AlexV525 Jun 29, 2021
7522bb2
Merge pull request #166 from greymag/6.0
yanivshaked Jun 29, 2021
45afcb5
✨ Introduce `Gap` and `SliverGap`
AlexV525 Jun 29, 2021
b2a3669
✨ Refactored grid layout for iOS reverted grid
AlexV525 Jun 29, 2021
1b7d39a
🎨 Make `_gridRevertKey` public
AlexV525 Jun 29, 2021
0611955
🎨 Improve `assetsGridBuilder` in custom delegate
AlexV525 Jun 29, 2021
e871ec4
✨ Add padding extensions
AlexV525 Jun 29, 2021
97a953a
♻️ Refactored bottom height getter
AlexV525 Jun 29, 2021
40cb7cf
🔥 Remove `Screens`
AlexV525 Jun 29, 2021
f870524
✨ Add `changeAccessibleLimitedAssets` for text delegate
AlexV525 Jun 29, 2021
f9702b6
✨ `AssetPickerProvider.selectedMaximumAssets`
AlexV525 Jun 29, 2021
debd10f
✨ `itemBannedIndicator`
AlexV525 Jun 29, 2021
724fa95
💄 Sync UI details for the viewer
AlexV525 Jun 29, 2021
9cc7971
Merge branch 'master' into 6.0
AlexV525 Jun 29, 2021
44bcda3
🔖 ## 6.0.0-dev.1
AlexV525 Jun 29, 2021
1798faa
[Text Delegate] Hebrew, Arabic and Russian translation for changeAcce…
yanivshaked Jun 29, 2021
6d3bf4e
[Text Delegate] Update English phase for changeAccessibleLimitedAssets
yanivshaked Jun 29, 2021
b974b8d
📝 More contents to the README
AlexV525 Jun 29, 2021
2d257ac
⚡️ Add `dispose` method the `AssetPicker`
AlexV525 Jun 29, 2021
095916f
📝 Update migration guide
AlexV525 Jun 29, 2021
f418545
♻️ Turn `switchPath` to `Future<void>`
AlexV525 Jun 30, 2021
663dfe4
🔥 Remove extra dispose
AlexV525 Jun 30, 2021
8ffbcd5
🚸 Make grid anchor more precise
AlexV525 Jun 30, 2021
1a00006
🚀 Update entities when limited assets updated
AlexV525 Jun 30, 2021
b10c11d
📝 Update `AssetPickerProvider` refactoring
AlexV525 Jun 30, 2021
ad063fb
♻️ Refactored `switchPath`'s signature
AlexV525 Jun 30, 2021
6bd14c9
german translation for asset_picker_text_delegate
CEichmueller Jun 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 6.0.0-dev.1

Sync everything with WeChat 8.x .

### New features

- Change the permission from the app settings when it's limited.
- Request more assets on iOS when the permission is limited.
- Fit the assets' grid's layout as the iOS `Photos` app (reverted and start from the bottom).
- Add Arabic language text delegate.
- Allow using `AssetPicker` and `AssetPickerViewer` directly with delegates.

### Improvements

- Items that being banned from select (reached max assets or type conflict)
will have a stronger color cover to indicate.
- Video preview in the [SpecialPickerType.wechatMoment] is completely different from other previews.
- Grid items has removed fade builder for more straight feedback after it gets loaded.
- Better interaction when jumping between previewing assets.
- Path entities list layout structure performance & structure improved.
- More precise thumbnail's option for iOS.

### Breaking changes

Multiple refactoring happened with delegates,
see [Migration Guide](guides/migration_guide.md) for more details.

## 5.5.7

- Make `switchPath` method in `AssetPickerProvider` async.
Expand Down
149 changes: 136 additions & 13 deletions example/lib/customs/pickers/directory_file_asset_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,23 +369,25 @@ class FileAssetPickerProvider extends AssetPickerProvider<File, Directory> {
}

@override
void switchPath(Directory pathEntity) {
Future<void> switchPath([Directory? pathEntity]) async {
if (pathEntity == null) {
return;
}
isSwitchingPath = false;
currentPathEntity = pathEntity;
totalAssetsCount = 0;
notifyListeners();
getAssetsFromEntity(0, currentPathEntity!);
await getAssetsFromEntity(0, currentPathEntity!);
}
}

class FileAssetPickerBuilder
extends AssetPickerBuilderDelegate<File, Directory> {
FileAssetPickerBuilder({
required FileAssetPickerProvider provider,
}) : super(provider: provider);
}) : super(provider: provider, initialPermission: PermissionState.authorized);

AssetsPickerTextDelegate get textDelegate =>
DefaultAssetsPickerTextDelegate();
AssetsPickerTextDelegate get textDelegate => AssetsPickerTextDelegate();

Duration get switchingPathDuration => kThemeAnimationDuration * 1.5;

Expand Down Expand Up @@ -533,6 +535,120 @@ class FileAssetPickerBuilder
);
}

@override
Widget assetsGridBuilder(BuildContext context) {
int totalCount = provider.currentAssets.length;
if (specialItemPosition != SpecialItemPosition.none) {
totalCount += 1;
}
final int placeholderCount;
if (isAppleOS && totalCount % gridCount != 0) {
placeholderCount = gridCount - totalCount % gridCount;
} else {
placeholderCount = 0;
}
final int row = (totalCount + placeholderCount) ~/ gridCount;
final double dividedSpacing = itemSpacing / gridCount;
final double topPadding =
MediaQuery.of(context).padding.top + kToolbarHeight;

Widget _sliverGrid(BuildContext ctx, List<File> assets) {
return SliverGrid(
delegate: SliverChildBuilderDelegate(
(_, int index) => Builder(
builder: (BuildContext c) {
if (isAppleOS) {
if (index < placeholderCount) {
return const SizedBox.shrink();
}
index -= placeholderCount;
}
return Directionality(
textDirection: Directionality.of(context),
child: assetGridItemBuilder(c, index, assets),
);
},
),
childCount: assetsGridItemCount(
context: ctx,
assets: assets,
placeholderCount: placeholderCount,
),
findChildIndexCallback: (Key? key) {
if (key is ValueKey<String>) {
return findChildIndexBuilder(
id: key.value,
assets: assets,
placeholderCount: placeholderCount,
);
}
return null;
},
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: gridCount,
mainAxisSpacing: itemSpacing,
crossAxisSpacing: itemSpacing,
),
);
}

return LayoutBuilder(
builder: (BuildContext c, BoxConstraints constraints) {
final double _itemSize = constraints.maxWidth / gridCount;
// Use [ScrollView.anchor] to determine where is the first place of
// the [SliverGrid]. Each row needs [dividedSpacing] to calculate,
// then minus one times of [itemSpacing] because spacing's count in the
// cross axis is always less than the rows.
final double anchor = math.min(
(row * (_itemSize + dividedSpacing) + topPadding - itemSpacing) /
constraints.maxHeight,
1,
);

return Directionality(
textDirection: effectiveGridDirection(context),
child: ColoredBox(
color: theme.canvasColor,
child: Selector<FileAssetPickerProvider, List<File>>(
selector: (_, FileAssetPickerProvider provider) =>
provider.currentAssets,
builder: (_, List<File> assets, __) => CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: gridScrollController,
anchor: isAppleOS ? anchor : 0,
center: isAppleOS ? gridRevertKey : null,
slivers: <Widget>[
if (isAppleOS)
SliverToBoxAdapter(
child: SizedBox(
height:
MediaQuery.of(context).padding.top + kToolbarHeight,
),
),
_sliverGrid(_, assets),
// Ignore the gap when the [anchor] is not equal to 1.
if (isAppleOS && anchor == 1)
SliverToBoxAdapter(
child: SizedBox(
height: MediaQuery.of(context).padding.bottom +
bottomSectionHeight,
),
),
if (isAppleOS)
SliverToBoxAdapter(
key: gridRevertKey,
child: const SizedBox.shrink(),
),
],
),
),
),
);
},
);
}

@override
Widget assetGridItemBuilder(
BuildContext context,
Expand Down Expand Up @@ -567,18 +683,22 @@ class FileAssetPickerBuilder
}

@override
int assetsGridItemCount(BuildContext context, List<File> currentAssets) {
int assetsGridItemCount({
required BuildContext context,
required List<File> assets,
int placeholderCount = 0,
}) {
int length;
switch (specialItemPosition) {
case SpecialItemPosition.none:
length = currentAssets.length;
length = assets.length;
break;
case SpecialItemPosition.prepend:
case SpecialItemPosition.append:
length = currentAssets.length + 1;
length = assets.length + 1;
break;
}
return length;
return length + placeholderCount;
}

@override
Expand Down Expand Up @@ -1047,8 +1167,12 @@ class FileAssetPickerBuilder
}

@override
int findChildIndexBuilder(String id, List<File> currentAssets) {
return currentAssets.indexWhere((File file) => file.path == id);
int findChildIndexBuilder({
required String id,
required List<File> assets,
int placeholderCount = 0,
}) {
return assets.indexWhere((File file) => file.path == id);
}
}

Expand Down Expand Up @@ -1091,8 +1215,7 @@ class FileAssetPickerViewerBuilderDelegate

late final PageController pageController;

AssetsPickerTextDelegate get textDelegate =>
DefaultAssetsPickerTextDelegate();
AssetsPickerTextDelegate get textDelegate => AssetsPickerTextDelegate();

void switchDisplayingDetail({bool? value}) {
isDisplayingDetail = value ?? !isDisplayingDetail;
Expand Down
93 changes: 78 additions & 15 deletions guides/migration_guide.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,96 @@
# Migration Guide

## Migrate to 5.0.0
This document gathered all breaking changes and migrations requirement between major versions.

## References

API documentation:
- `AssetPickerBuilderDelegate`:
- https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerBuilderDelegate-class.html
- https://pub.flutter-io.cn/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerBuilderDelegate-class.html
- `AssetPickerViewerBuilderDelegate`:
- https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerBuilderDelegate-class.html
- https://pub.flutter-io.cn/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerBuilderDelegate-class.html
- `AssetPickerProvider`:
- https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerProvider-class.html
- https://pub.flutter-io.cn/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerProvider-class.html
- `AssetPickerViewerProvider`:
- https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerProvider-class.html
- https://pub.flutter-io.cn/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerProvider-class.html
- `AssetsPickerTextDelegate`:
- https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetsPickerTextDelegate-class.html
- https://pub.flutter-io.cn/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetsPickerTextDelegate-class.html

## Major versions

- [6.0.0](#6.0.0)
- [5.0.0](#5.0.0)

## 6.0.0

### Summary

_If you didn't extend `AssetPickerBuilderDelegate` or `AssetTextDelegate` to build delegates on your own,
you can stop reading._

- User who extended `AssetPickerBuilderDelegate` needs to update the subclass with the latest changes.
- `AssetsPickerTextDelegate` is not abstract anymore.

### Details

#### `AssetPickerBuilderDelegate`

- This delegate requires a new argument `initialPermission` with `PermissionState` type when using.
The intention of this change is to be capable with various of `PermissionState`.
If your delegate didn't require a permission check, you can pass `PermissionState.authorized` directly.

- `assetsGridBuilder` is not implemented by default.

- The `findChildIndexBuilder` and `assetsGridItemCount` methods have new signature.
They require calculating placeholders count on iOS/macOS by default.

#### `AssetsPickerTextDelegate`

- This delegate is now a normal class with Chinese language implemented by default,
which makes `DefaultAssetsPickerTextDelegate` removed. So if you used to use `DefaultAssetsPickerTextDelegate()`,
use `AssetsPickerTextDelegate()` instead.

#### `AssetPickerProvider`

- The `switchPath` method has a different signature:

Before:

```dart
void switchPath(P pathEntity);
```

After:

```dart
Future<void> switchPath([P? pathEntity]);
```

## 5.0.0

### Summary

_If you only use the `AssetPicker.pickAssets` and `AssetEntityImageProvider`,
didn't use `AssetPickerViewer`, `AssetPickerProvider`, or other components separately,
you can stop reading._

`AssetPicker` and `AssetPickerViewer` are only a builder since 5.x, all widgets construct were moved
to `AssetPickerBuilderDelegate` and `AssetPickerViewerBuilderDelegate`, and these delegates are both
abstract.
The `AssetPicker` and the `AssetPickerViewer` are only a builder since 5.x,
all widgets construct were moved to `AssetPickerBuilderDelegate` and `AssetPickerViewerBuilderDelegate`,
and these delegates are both abstract.

By splitting delegates, now you can build your own picker with custom types, style, and widgets.

### Migration steps
#### Details

For how to implement a custom picker, see the example's custom page for more implementation details.

* If you have ever use `AssetPickerViewer.pushToViewer`, the properties `assets` has changed to
- If you have ever use `AssetPickerViewer.pushToViewer`, the properties `assets` has changed to
`previewAssets`.

* If you have extends an `AssetPickerProvider` or `AssetPickerViewerProvider`, it now requires you
- If you have extended an `AssetPickerProvider` or `AssetPickerViewerProvider`, it now requires you
to pass generic type `A` and `P`, and handle the entities on your own.

### References

API documentation:
* `AssetPickerBuilderDelegate`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerBuilderDelegate-class.html
* `AssetPickerViewerBuilderDelegate`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerBuilderDelegate-class.html
* `AssetPickerProvider`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerProvider-class.html
* `AssetPickerViewerProvider`: https://pub.dev/documentation/wechat_assets_picker/latest/wechat_assets_picker/AssetPickerViewerProvider-class.html
5 changes: 2 additions & 3 deletions lib/src/constants/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@ export '../widget/builder/fade_image_builder.dart';
export '../widget/builder/image_page_builder.dart';
export '../widget/builder/video_page_builder.dart';
export '../widget/fixed_appbar.dart';
export '../widget/gaps.dart';
export '../widget/platform_progress_indicator.dart';

export 'colors.dart';
export 'custom_scroll_physics.dart';
export 'enums.dart';
export 'extensions.dart';
export 'screens.dart';

class Constants {
const Constants._();

static GlobalKey pickerKey = GlobalKey();

static AssetsPickerTextDelegate textDelegate =
DefaultAssetsPickerTextDelegate();
static AssetsPickerTextDelegate textDelegate = AssetsPickerTextDelegate();
static SortPathDelegate sortPathDelegate = SortPathDelegate.common;

static const int defaultGridThumbSize = 200;
Expand Down
8 changes: 7 additions & 1 deletion lib/src/constants/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ extension BuildContextExtension on BuildContext {
MediaQueryData get mediaQuery => MediaQuery.of(this);

ThemeData get themeData => Theme.of(this);

double get topPadding => mediaQuery.padding.top;

double get bottomPadding => mediaQuery.padding.bottom;

double get bottomInsets => mediaQuery.viewInsets.bottom;
}

extension BrightnessExtension on Brightness {
Expand All @@ -17,7 +23,7 @@ extension BrightnessExtension on Brightness {
}

extension ColorExtension on Color {
bool get isTransparent => this == Colors.transparent;
bool get isTransparent => this == Colors.transparent || alpha == 0x00;
}

extension ThemeDataExtension on ThemeData {
Expand Down
Loading