|
@@ -12,6 +12,10 @@
|
|
|
#define NUMBERS @"0123456789.\n"
|
|
#define NUMBERS @"0123456789.\n"
|
|
|
@interface PortfolioEditQTYViewController ()
|
|
@interface PortfolioEditQTYViewController ()
|
|
|
|
|
|
|
|
|
|
+@property (nonatomic,assign) int checkedCount;
|
|
|
|
|
+@property (strong, nonatomic) IBOutlet UIButton *saveButton;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation PortfolioEditQTYViewController
|
|
@implementation PortfolioEditQTYViewController
|
|
@@ -20,8 +24,10 @@
|
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
|
|
|
|
+ self.checkedCount = 0;
|
|
|
|
|
+ self.saveButton.hidden = YES;
|
|
|
|
|
+ [self addObserver:self forKeyPath:@"checkedCount" options:NSKeyValueObservingOptionNew context:nil];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
self.tv_linenote.delegate = self;
|
|
self.tv_linenote.delegate = self;
|
|
|
self.tv_linenote.text=self.linenotes ;
|
|
self.tv_linenote.text=self.linenotes ;
|
|
|
if(self.qty>=0)
|
|
if(self.qty>=0)
|
|
@@ -215,7 +221,6 @@
|
|
|
bool qtypercentage = self.switchQTY.isOn;
|
|
bool qtypercentage = self.switchQTY.isOn;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
if (!self.qtyCheckButton.selected) {
|
|
if (!self.qtyCheckButton.selected) {
|
|
|
self.qty = -INT32_MAX;
|
|
self.qty = -INT32_MAX;
|
|
|
self.qty_p = -MAXFLOAT;
|
|
self.qty_p = -MAXFLOAT;
|
|
@@ -558,7 +563,13 @@
|
|
|
sender.selected = !sender.selected;
|
|
sender.selected = !sender.selected;
|
|
|
|
|
|
|
|
self.editQTY.enabled = sender.selected;
|
|
self.editQTY.enabled = sender.selected;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (sender.selected) {
|
|
|
|
|
+ self.checkedCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ self.checkedCount--;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)priceCheckButtonClicked:(id)sender {
|
|
- (IBAction)priceCheckButtonClicked:(id)sender {
|
|
@@ -568,6 +579,11 @@
|
|
|
|
|
|
|
|
self.editPrice.enabled = btn.selected;
|
|
self.editPrice.enabled = btn.selected;
|
|
|
|
|
|
|
|
|
|
+ if (btn.selected) {
|
|
|
|
|
+ self.checkedCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ self.checkedCount--;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -575,11 +591,35 @@
|
|
|
sender.selected = !sender.selected;
|
|
sender.selected = !sender.selected;
|
|
|
|
|
|
|
|
self.editDiscount.enabled = sender.selected;
|
|
self.editDiscount.enabled = sender.selected;
|
|
|
|
|
+ if (sender.selected) {
|
|
|
|
|
+ self.checkedCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ self.checkedCount--;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- (IBAction)lineNoteCheckButtonClicked:(UIButton *)sender {
|
|
- (IBAction)lineNoteCheckButtonClicked:(UIButton *)sender {
|
|
|
sender.selected = !sender.selected;
|
|
sender.selected = !sender.selected;
|
|
|
|
|
|
|
|
self.tv_linenote.editable = sender.selected;
|
|
self.tv_linenote.editable = sender.selected;
|
|
|
|
|
+ if (sender.selected) {
|
|
|
|
|
+ self.checkedCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ self.checkedCount--;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
|
|
|
|
|
+ if ([keyPath isEqualToString:@"checkedCount"]) {
|
|
|
|
|
+
|
|
|
|
|
+ self.saveButton.hidden = self.checkedCount == 0;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-(void)dealloc {
|
|
|
|
|
+ [self removeObserver:self forKeyPath:@"checkedCount"];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
@end
|