summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Paul <chpwn@chpwn.com>2011-02-01 11:00:09 -0800
committerGrant Paul <chpwn@chpwn.com>2011-02-01 11:00:09 -0800
commita784d0a4a6a8457296ba2c6128e9da29cdd1fcfd (patch)
tree1e21465a7a993a02441674fc380e24b331b9040a
parentd544eabd7ecfac01ec20121d868c78360b3d2dc3 (diff)
Refactor edit button in SectionsController; use system provided UIBarButtonItems.
-rw-r--r--MobileCydia.mm25
1 files changed, 15 insertions, 10 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 023284a..392c173 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -6670,15 +6670,26 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[super dealloc];
}
+- (void) updateNavigationItem {
+ [[self navigationItem] setTitle:editing_ ? UCLocalize("SECTION_VISIBILITY") : UCLocalize("SECTIONS")];
+ if ([sections_ count] == 0) {
+ [[self navigationItem] setRightBarButtonItem:nil];
+ } else {
+ [[self navigationItem] setRightBarButtonItem:[[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:(editing_ ? UIBarButtonSystemItemDone : UIBarButtonSystemItemEdit)
+ target:self
+ action:@selector(editButtonClicked)
+ ] animated:([[self navigationItem] rightBarButtonItem] != nil)];
+ }
+}
+
- (void) setEditing:(BOOL)editing {
if ((editing_ = editing))
[list_ reloadData];
else
[delegate_ updateData];
- [[self navigationItem] setTitle:editing_ ? UCLocalize("SECTION_VISIBILITY") : UCLocalize("SECTIONS")];
- [[[self navigationItem] rightBarButtonItem] setTitle:[sections_ count] == 0 ? nil : editing_ ? UCLocalize("DONE") : UCLocalize("EDIT")];
- [[[self navigationItem] rightBarButtonItem] setStyle:editing_ ? UIBarButtonItemStyleDone : UIBarButtonItemStylePlain];
+ [self updateNavigationItem];
}
- (void) viewDidAppear:(BOOL)animated {
@@ -6802,13 +6813,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[filtered_ addObject:section];
}
- [[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc]
- initWithTitle:([sections_ count] == 0 ? nil : UCLocalize("EDIT"))
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(editButtonClicked)
- ] autorelease] animated:([[self navigationItem] rightBarButtonItem] != nil)];
-
+ [self updateNavigationItem];
[list_ reloadData];
_trace();
}