forked from ish-app/ish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
318 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// ProgressReportViewController.h | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 6/18/20. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "Roots.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ProgressReportViewController : UIViewController <ProgressReporter> | ||
|
||
- (void)updateProgress:(double)progressFraction message:(NSString *)progressMessage; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// ProgressReportViewController.m | ||
// iSH | ||
// | ||
// Created by Theodore Dubois on 6/18/20. | ||
// | ||
|
||
#import "ProgressReportViewController.h" | ||
|
||
@interface ProgressReportViewController () | ||
|
||
@property (weak, nonatomic) IBOutlet UIView *popupView; | ||
@property (weak, nonatomic) IBOutlet UILabel *titleLabel; | ||
@property (weak, nonatomic) IBOutlet UILabel *statusLabel; | ||
@property (weak, nonatomic) IBOutlet UIProgressView *bar; | ||
|
||
@property (nonatomic) double progress; | ||
@property (nonatomic) NSString *message; | ||
|
||
@property CADisplayLink *timer; | ||
|
||
@end | ||
|
||
@implementation ProgressReportViewController | ||
|
||
- (void)viewDidLoad { | ||
self.titleLabel.text = self.title; | ||
} | ||
|
||
- (void)viewDidLayoutSubviews { | ||
CAShapeLayer *mask = [CAShapeLayer new]; | ||
mask.path = [UIBezierPath bezierPathWithRoundedRect:self.popupView.bounds cornerRadius:13].CGPath; | ||
self.popupView.layer.mask = mask; | ||
self.popupView.layer.masksToBounds = YES; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
self.timer = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)]; | ||
[self.timer addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes]; | ||
} | ||
|
||
- (void)viewDidDisappear:(BOOL)animated { | ||
[super viewDidDisappear:animated]; | ||
[self.timer invalidate]; | ||
} | ||
|
||
- (void)updateProgress:(double)progressFraction message:(NSString *)progressMessage { | ||
@synchronized (self) { | ||
_progress = progressFraction; | ||
_message = progressMessage; | ||
} | ||
} | ||
|
||
- (void)update { | ||
@synchronized (self) { | ||
self.bar.progress = _progress; | ||
self.statusLabel.text = _message; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.