Skip to content

Commit

Permalink
add default values
Browse files Browse the repository at this point in the history
  • Loading branch information
SunriseOYR committed Apr 12, 2019
1 parent 926359b commit 4a0dbf0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions SKUDataFilter/ORSKUDataFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
//当前 结果
@property (nonatomic, strong, readonly) id currentResult;

@property (nonatomic, assign) BOOL needDefaultValue;

//init
- (instancetype)initWithDataSource:(id<ORSKUDataFilterDataSource>)dataSource;
Expand Down
21 changes: 18 additions & 3 deletions SKUDataFilter/ORSKUDataFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ @interface ORSKUDataFilter()

@property (nonatomic, strong) NSMutableArray <NSIndexPath *> *selectedIndexPaths;


@property (nonatomic, strong) NSMutableSet <NSIndexPath *> *availableIndexPathsSet;

//全可用的
@property (nonatomic, strong) NSSet <NSIndexPath *> *allAvailableIndexPaths;


@property (nonatomic, strong) id currentResult;

@end
Expand Down Expand Up @@ -124,6 +122,12 @@ - (void)initPropertiesSkuListData {
model.properties = [self propertiesWithConditionRawData:conditions];
model.result = [_dataSource filter:self resultOfConditionForRow:i];

if (self.selectedIndexPaths.count == 0 && _needDefaultValue) {
[model.properties enumerateObjectsUsingBlock:^(ORSKUProperty * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self didSelectedPropertyWithIndexPath:obj.indexPath];
}];
}

[modelSet addObject:model];
}
_conditions = [modelSet copy];
Expand Down Expand Up @@ -317,7 +321,18 @@ - (BOOL)isAvailableWithPropertyIndexPath:(NSIndexPath *)indexPath {
#pragma mark -- setter
- (void)setDataSource:(id<ORSKUDataFilterDataSource>)dataSource {
_dataSource = dataSource;
[self initPropertiesSkuListData];
[self reloadData];
}

- (void)setNeedDefaultValue:(BOOL)needDefaultValue {

_needDefaultValue = needDefaultValue;

if (_selectedIndexPaths.count > 0 || !needDefaultValue) {
return;
}

[self reloadData];
}

@end
Expand Down
4 changes: 2 additions & 2 deletions SKUDataFilterDemo/SKUDataFilterDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 43WNAPBJGK;
DEVELOPMENT_TEAM = 44UDNU83L4;
INFOPLIST_FILE = SKUDataFilterDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -519,7 +519,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 43WNAPBJGK;
DEVELOPMENT_TEAM = 44UDNU83L4;
INFOPLIST_FILE = SKUDataFilterDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
9 changes: 9 additions & 0 deletions SKUDataFilterDemo/SKUDataFilterDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ - (void)viewDidLoad {
[_filter reloadData];
[self.collectionView reloadData];


//默认选中

{
_filter.needDefaultValue = YES;
[self.collectionView reloadData];
[self action_complete:nil];
}

}

#pragma mark -- collectionView
Expand Down

0 comments on commit 4a0dbf0

Please sign in to comment.