Repository navigation
Expand file tree
/
Copy pathKBProgressView.m
More file actions
76 lines (63 loc) · 1.7 KB
/
Copy pathKBProgressView.m
File metadata and controls
76 lines (63 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// KBProgressView.m
// Keybase
//
// Created by Gabriel on 3/6/15.
// Copyright (c) 2015 Gabriel Handford. All rights reserved.
//
#import "KBProgressView.h"
#import "KBProgressOverlayView.h"
#import <YOLayout/YOLayout+PrefabLayouts.h>
@interface KBProgressView ()
@property KBProgressOverlayView *progressView;
@property (copy) dispatch_block_t close;
@property (weak) id sender;
@end
@implementation KBProgressView
- (void)viewInit {
[super viewInit];
[self kb_setBackgroundColor:KBAppearance.currentAppearance.backgroundColor];
_progressView = [[KBProgressOverlayView alloc] init];
_progressView.animating = YES;
[self addSubview:_progressView];
self.viewLayout = [YOLayout fill:_progressView];
}
- (void)doIt:(dispatch_block_t)close {
//GHWeakSelf gself = self;
self.work(^(NSError *error) {
if (error) {
/*
gself.progressView.animating = NO;
[self setError:error];
gself.errorView.closeButton.targetBlock = ^{
[self close:self];
close();
};
*/
[self close:self close:close];
[KBActivity setError:error sender:self.sender];
} else {
[self close:self close:close];
}
});
}
- (void)openAndDoIt:(KBWindow *)window {
[self openInWindow:window];
[self doIt:^{}];
}
- (void)setProgressTitle:(NSString *)progressTitle {
_progressView.title = progressTitle;
}
- (void)openInWindow:(KBWindow *)window {
self.sender = window;
[window addModalWindowForView:self rect:CGRectMake(0, 0, 200, 200)];
GHWeakSelf gself = self;
self.close = ^{
[[gself window] close];
};
}
- (void)close:(id)sender close:(dispatch_block_t)close {
self.close();
if (close) dispatch_async(dispatch_get_main_queue(), close);
}
@end