Skip to content

Commit 227d8d0

Browse files
authored
📝 Update doc (#913)
1 parent 3a5ba8d commit 227d8d0

18 files changed

+447
-79
lines changed

lib/src/filter/base_filter.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The FlutterCandies author. All rights reserved.
2+
// Use of this source code is governed by an Apache license that can be found
3+
// in the LICENSE file.
4+
15
import 'custom/custom_columns.dart';
26
import 'custom/custom_filter.dart';
37
import 'custom/order_by_item.dart';
@@ -48,7 +52,7 @@ abstract class PMFilter {
4852

4953
/// Whether the [AssetPathEntity]s will return with modified time.
5054
///
51-
/// This option is performance-consuming. Use with cautious.
55+
/// This option is performance-consuming. Use with caution.
5256
///
5357
/// See also:
5458
/// * [AssetPathEntity.lastModified].
@@ -62,7 +66,7 @@ abstract class PMFilter {
6266
/// The subclass should override this method to make params.
6367
Map<String, dynamic> childMap();
6468

65-
/// The method only support for [FilterOptionGroup].
69+
/// The method only supports for [FilterOptionGroup].
6670
PMFilter updateDateToNow();
6771

6872
/// Convert the filter to a map for channel.

lib/src/filter/classical/filter_option_group.dart

+82-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,31 @@ import '../../internal/enums.dart';
88
import '../base_filter.dart';
99
import 'filter_options.dart';
1010

11-
/// The group class to obtain [FilterOption]s.
11+
/// A collection of filtering and sorting options for querying assets.
12+
///
13+
/// Use this class to specify how to filter and sort a set of assets returned by [PhotoManager].
14+
///
15+
/// The [FilterOptionGroup] object contains several [FilterOption] objects, one for each type of asset (image, video, audio).
16+
/// You can set specific filtering and sorting options for each type of asset using the corresponding [FilterOption] object.
17+
///
18+
/// Additionally, you can specify whether to include modified path results, whether to include live photos,
19+
/// or whether to only include live photos, using the appropriate properties of this object.
20+
///
21+
/// Finally, you can use the [orders] property to specify sorting options for the results.
1222
class FilterOptionGroup extends PMFilter {
1323
/// Construct a default options group.
24+
///
25+
/// Parameters:
26+
///
27+
/// * `imageOption`: The option for filtering image assets. Defaults to [FilterOption].
28+
/// * `videoOption`: The option for filtering video assets. Defaults to [FilterOption].
29+
/// * `audioOption`: The option for filtering audio assets. Defaults to [FilterOption].
30+
/// * `containsPathModified`: Whether the result should contain assets whose file path has been modified. Defaults to `false`.
31+
/// * `containsLivePhotos`: Whether the result should contain live photos. This option only takes effects on iOS. Defaults to `true`.
32+
/// * `onlyLivePhotos`: Whether the result should only contain live photos. This option only takes effects on iOS and when the request type is image. Defaults to `false`.
33+
/// * `createTimeCond`: The condition for filtering asset creation time. See [DateTimeCond] for more information. Defaults to `DateTimeCond.def()`.
34+
/// * `updateTimeCond`: The condition for filtering asset update time. See [DateTimeCond] for more information. By default, this option is ignored.
35+
/// * `orders`: A list of options for sorting the results. Defaults to an empty list.
1436
FilterOptionGroup({
1537
FilterOption imageOption = const FilterOption(),
1638
FilterOption videoOption = const FilterOption(),
@@ -32,37 +54,78 @@ class FilterOptionGroup extends PMFilter {
3254
}
3355

3456
/// Construct an empty options group.
57+
///
58+
/// Returns a new [FilterOptionGroup] instance with default options for all asset types and no other filters applied.
3559
FilterOptionGroup.empty();
3660

3761
/// Whether to obtain only live photos.
3862
///
3963
/// This option only takes effects on iOS and when the request type is image.
4064
bool onlyLivePhotos = false;
4165

42-
/// Whether to obtain live photos.
66+
/// Whether the result should contain live photos.
67+
///
68+
/// Defaults to `true`.
4369
///
4470
/// This option only takes effects on iOS.
4571
bool containsLivePhotos = true;
4672

4773
final Map<AssetType, FilterOption> _map = <AssetType, FilterOption>{};
4874

49-
/// Get the [FilterOption] according the specific [AssetType].
75+
/// Get the [FilterOption] object for the specified [AssetType].
76+
///
77+
/// Parameters:
78+
///
79+
/// * `type`: The type of asset.
80+
///
81+
/// Returns the [FilterOption] object associated with the specified [AssetType].
5082
FilterOption getOption(AssetType type) => _map[type]!;
5183

52-
/// Set the [FilterOption] according the specific [AssetType].
84+
/// Set the [FilterOption] object for the specified [AssetType].
85+
///
86+
/// Parameters:
87+
///
88+
/// * `type`: The type of asset to set the [FilterOption] for.
89+
/// * `option`: The new [FilterOption] to set.
5390
void setOption(AssetType type, FilterOption option) {
5491
_map[type] = option;
5592
}
5693

94+
/// The condition for filtering asset creation time.
95+
///
96+
/// Defaults to `DateTimeCond.def()`.
97+
///
98+
/// See [DateTimeCond] for more information on how to specify date and time conditions.
5799
DateTimeCond createTimeCond = DateTimeCond.def();
100+
101+
/// The condition for filtering asset update time.
102+
///
103+
/// By default, this option is ignored.
104+
///
105+
/// See [DateTimeCond] for more information on how to specify date and time conditions.
58106
DateTimeCond updateTimeCond = DateTimeCond.def().copyWith(ignore: true);
59107

108+
/// A list of options for sorting the results.
109+
///
110+
/// By default, the order is not specified.
111+
///
112+
/// See [OrderOption] for more information on how to specify sorting options.
60113
final List<OrderOption> orders = <OrderOption>[];
61114

115+
/// Adds an [OrderOption] to the list of sorting options.
116+
///
117+
/// Parameters:
118+
///
119+
/// * `option`: The [OrderOption] to add to the list.
62120
void addOrderOption(OrderOption option) {
63121
orders.add(option);
64122
}
65123

124+
/// Merges another [FilterOptionGroup] into this one.
125+
///
126+
/// Parameters:
127+
///
128+
/// * `other`: The [FilterOptionGroup] to merge into this one.
66129
void merge(FilterOptionGroup other) {
67130
for (final AssetType type in _map.keys) {
68131
_map[type] = _map[type]!.merge(other.getOption(type));
@@ -106,6 +169,21 @@ class FilterOptionGroup extends PMFilter {
106169
};
107170
}
108171

172+
/// Returns a new [FilterOptionGroup] with the same options as this one, but with some options replaced.
173+
///
174+
/// Parameters:
175+
///
176+
/// * `imageOption`: New image filter option. Defaults to the current object's option.
177+
/// * `videoOption`: New video filter option. Defaults to the current object's option.
178+
/// * `audioOption`: New audio filter option. Defaults to the current object's option.
179+
/// * `containsPathModified`: Whether to include results with modified paths. Defaults to the same as the current object.
180+
/// * `containsLivePhotos`: Whether to include live photos. Defaults to the same as the current object.
181+
/// * `onlyLivePhotos`: Whether to include only live photos. Defaults to the same as the current object.
182+
/// * `createTimeCond`: Date and time conditions for filtering creation time. Defaults to the same as the current object.
183+
/// * `updateTimeCond`: Date and time conditions for filtering update time. Defaults to the same as the current object.
184+
/// * `orders`: Sorting options for the results. Defaults to the same as the current object.
185+
///
186+
/// Returns a new [FilterOptionGroup] object with the specified options.
109187
FilterOptionGroup copyWith({
110188
FilterOption? imageOption,
111189
FilterOption? videoOption,

0 commit comments

Comments
 (0)