Skip to content

Commit d5f98ad

Browse files
committed
Add MRCReposViewModelOptionsTableViewCellEditActions
Former-commit-id: 52be359
1 parent 57a8ea2 commit d5f98ad

7 files changed

+15
-1
lines changed

MVVMReactiveCocoa/View/MRCOwnedReposViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ - (void)configureCell:(MRCReposTableViewCell *)cell atIndexPath:(NSIndexPath *)i
5555

5656
#pragma mark - UITableViewDataSource
5757

58+
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
59+
return self.viewModel.options & MRCReposViewModelOptionsTableViewCellEditActions;
60+
}
61+
5862
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {}
5963

6064
#pragma mark - UITableViewDelegate
@@ -65,7 +69,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
6569

6670
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
6771
MRCReposItemViewModel *viewModel = self.viewModel.dataSource[indexPath.section][indexPath.row];
68-
72+
6973
void (^handlerStar)(UITableViewRowAction *, NSIndexPath *) = ^(UITableViewRowAction *action, NSIndexPath *indexPath) {
7074
tableView.editing = false;
7175
[[[self.viewModel.services client] mrc_starRepository:viewModel.repository] subscribeNext:^(id x) {}];

MVVMReactiveCocoa/ViewModel/MRCOwnedReposViewModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef NS_OPTIONS(NSUInteger, MRCReposViewModelOptions) {
2424
MRCReposViewModelOptionsSectionIndex = 1 << 4,
2525
MRCReposViewModelOptionsShowOwnerLogin = 1 << 5,
2626
MRCReposViewModelOptionsMarkStarredStatus = 1 << 6,
27+
MRCReposViewModelOptionsTableViewCellEditActions = 1 << 7,
2728
};
2829

2930
@interface MRCOwnedReposViewModel : MRCTableViewModel

MVVMReactiveCocoa/ViewModel/MRCOwnedReposViewModel.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ - (MRCReposViewModelOptions)options {
124124
options = options | MRCReposViewModelOptionsSectionIndex;
125125
// options = options | MRCReposViewModelOptionsShowOwnerLogin;
126126
// options = options | MRCReposViewModelOptionsMarkStarredStatus;
127+
// options = options | MRCReposViewModelOptionsTableViewCellEditActions;
127128

128129
return options;
129130
}

MVVMReactiveCocoa/ViewModel/MRCPublicReposViewModel.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ - (MRCReposViewModelOptions)options {
3131
// options = options | MRCReposViewModelOptionsSectionIndex;
3232
// options = options | MRCReposViewModelOptionsShowOwnerLogin;
3333
// options = options | MRCReposViewModelOptionsMarkStarredStatus;
34+
options = options | MRCReposViewModelOptionsTableViewCellEditActions;
3435
} else {
3536
// options = options | MRCReposViewModelOptionsObserveStarredReposChange;
3637
// options = options | MRCReposViewModelOptionsSaveOrUpdateRepos;
@@ -39,6 +40,7 @@ - (MRCReposViewModelOptions)options {
3940
// options = options | MRCReposViewModelOptionsSectionIndex;
4041
options = options | MRCReposViewModelOptionsShowOwnerLogin;
4142
options = options | MRCReposViewModelOptionsMarkStarredStatus;
43+
options = options | MRCReposViewModelOptionsTableViewCellEditActions;
4244
}
4345

4446
return options;

MVVMReactiveCocoa/ViewModel/MRCReposSearchResultsViewModel.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ - (MRCReposViewModelOptions)options {
3636
// options = options | MRCReposViewModelOptionsSectionIndex;
3737
options = options | MRCReposViewModelOptionsShowOwnerLogin;
3838
options = options | MRCReposViewModelOptionsMarkStarredStatus;
39+
// options = options | MRCReposViewModelOptionsTableViewCellEditActions;
3940

4041
return options;
4142
}

MVVMReactiveCocoa/ViewModel/MRCStarredReposViewModel.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ - (MRCReposViewModelOptions)options {
6363
options = options | MRCReposViewModelOptionsMarkStarredStatus;
6464
}
6565

66+
if (!(self.isCurrentUser && self.entryPoint == MRCStarredReposViewModelEntryPointHomepage)) {
67+
options = options | MRCReposViewModelOptionsTableViewCellEditActions;
68+
}
69+
6670
return options;
6771
}
6872

MVVMReactiveCocoa/ViewModel/MRCTrendingViewModel.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ - (MRCReposViewModelOptions)options {
6363
// options = options | MRCReposViewModelOptionsSectionIndex;
6464
options = options | MRCReposViewModelOptionsShowOwnerLogin;
6565
options = options | MRCReposViewModelOptionsMarkStarredStatus;
66+
options = options | MRCReposViewModelOptionsTableViewCellEditActions;
6667

6768
return options;
6869
}

0 commit comments

Comments
 (0)