Skip to content

Commit

Permalink
Added MBProgressHUD subclass for custom styling.
Browse files Browse the repository at this point in the history
Updated MBProgressHUD with bug fix.
  • Loading branch information
nicolasgomollon committed Feb 20, 2018
1 parent 9433ea0 commit 58fdb7b
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/nicolasgomollon/ZIPArchive.git
[submodule "Vendor/MBProgressHUD"]
path = Vendor/MBProgressHUD
url = https://github.com/jdg/MBProgressHUD.git
url = https://github.com/nicolasgomollon/MBProgressHUD.git
[submodule "Vendor/SAMKeychain"]
path = Vendor/SAMKeychain
url = https://github.com/nicolasgomollon/SAMKeychain.git
Expand Down
6 changes: 6 additions & 0 deletions AppSales.xcodeproj/project.pbxproj
Expand Up @@ -116,6 +116,7 @@
DAD39BA71EEC9B3100CB3524 /* passcode_square_filled@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAD39BA61EEC9B3100CB3524 /* passcode_square_filled@3x.png */; };
DAD53A531EFC87630038C925 /* ReviewFilterComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD53A521EFC87630038C925 /* ReviewFilterComparator.m */; };
DAD53A581EFCF6ED0038C925 /* ReviewListHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD53A571EFCF6ED0038C925 /* ReviewListHeaderView.m */; };
DAF2D89D203B5F8100F3C0CF /* ASProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF2D89C203B5F8100F3C0CF /* ASProgressHUD.m */; };
DAFC5F801C16B29D00261B16 /* ReviewsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DAFC5F7F1C16B29D00261B16 /* ReviewsViewController.m */; };
DAFC5F931C16BFAD00261B16 /* Review.m in Sources */ = {isa = PBXBuildFile; fileRef = DAFC5F921C16BFAD00261B16 /* Review.m */; };
DAFC5F961C16C07100261B16 /* Version.m in Sources */ = {isa = PBXBuildFile; fileRef = DAFC5F951C16C07100261B16 /* Version.m */; };
Expand Down Expand Up @@ -319,6 +320,8 @@
DAD53A521EFC87630038C925 /* ReviewFilterComparator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReviewFilterComparator.m; sourceTree = "<group>"; };
DAD53A561EFCF6ED0038C925 /* ReviewListHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReviewListHeaderView.h; sourceTree = "<group>"; };
DAD53A571EFCF6ED0038C925 /* ReviewListHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReviewListHeaderView.m; sourceTree = "<group>"; };
DAF2D89B203B5F8100F3C0CF /* ASProgressHUD.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASProgressHUD.h; sourceTree = "<group>"; };
DAF2D89C203B5F8100F3C0CF /* ASProgressHUD.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASProgressHUD.m; sourceTree = "<group>"; };
DAFC5F7E1C16B29D00261B16 /* ReviewsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReviewsViewController.h; sourceTree = "<group>"; };
DAFC5F7F1C16B29D00261B16 /* ReviewsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReviewsViewController.m; sourceTree = "<group>"; };
DAFC5F841C16B89F00261B16 /* AppSales 4.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AppSales 4.xcdatamodel"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -611,6 +614,8 @@
7FDF601C13DD2107005F1E2D /* Helpers */ = {
isa = PBXGroup;
children = (
DAF2D89B203B5F8100F3C0CF /* ASProgressHUD.h */,
DAF2D89C203B5F8100F3C0CF /* ASProgressHUD.m */,
7F1499C813BE15F500D89064 /* NSData+Compression.h */,
7F1499C913BE15F500D89064 /* NSData+Compression.m */,
7F454F9E13D5C24F00AE47D1 /* UIColor+Extensions.h */,
Expand Down Expand Up @@ -968,6 +973,7 @@
DA4AC6B61EFB54D6003CAF4D /* ReviewDownloadOperation.m in Sources */,
7FA3EA9D13F77DF000C80C07 /* MultiOperation.m in Sources */,
7F0B8A6913F77F95006E9151 /* PromoCodeOperation.m in Sources */,
DAF2D89D203B5F8100F3C0CF /* ASProgressHUD.m in Sources */,
7F0B8A6E13F7B941006E9151 /* PromoCode.m in Sources */,
DA49843D1C129F95009BFC8F /* ZIPArchive.mm in Sources */,
DAFC5F801C16B29D00261B16 /* ReviewsViewController.m in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions Classes/ASProgressHUD.h
@@ -0,0 +1,13 @@
//
// ASProgressHUD.h
// AppSales
//
// Created by Nicolas Gomollon on 2/19/18.
//
//

#import "MBProgressHUD.h"

@interface ASProgressHUD : MBProgressHUD

@end
35 changes: 35 additions & 0 deletions Classes/ASProgressHUD.m
@@ -0,0 +1,35 @@
//
// ASProgressHUD.m
// AppSales
//
// Created by Nicolas Gomollon on 2/19/18.
//
//

#import "ASProgressHUD.h"

@implementation ASProgressHUD

#pragma mark - Lifecycle

- (instancetype)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
[self customInit];
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
[self customInit];
}
return self;
}

- (void)customInit {
self.bezelView.layer.cornerRadius = 9.0f;
self.bezelView.blurEffectStyle = UIBlurEffectStyleDark;
self.contentColor = [UIColor whiteColor];
}

@end
16 changes: 8 additions & 8 deletions Classes/AccountsViewController+ButtonActions.m
Expand Up @@ -7,7 +7,7 @@
//

#import "AccountsViewController+ButtonActions.h"
#import "MBProgressHUD.h"
#import "ASProgressHUD.h"

@implementation AccountsViewController (AccountsViewController_ButtonActions)

Expand Down Expand Up @@ -109,23 +109,23 @@ - (void)loginSucceeded {
}

- (void)loginFailed {
[MBProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
}

- (void)finishedFetchingAccessToken:(NSString *)accessToken {
FieldEditorViewController *vc = self.currentViewController;
[MBProgressHUD hideHUDForView:vc.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:vc.navigationController.view animated:YES];
[vc.values setObject:accessToken forKey:kAccountAccessToken];
[vc.tableView reloadData];
}

- (void)failedToFetchAccessToken {
[MBProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"The access token could not be fetched automatically. Please check your username and password or enter your access token manually. You'll find it in the Sales and Trends module, under the Reports section, by clicking on the (?) beside About Reports on itunesconnect.apple.com.", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
}

- (void)failedToGenerateCSRFToken {
[MBProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"Could not fetch CSRF token from server. Please try again later.", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
}

Expand Down Expand Up @@ -160,21 +160,21 @@ - (void)chooseVendor {
}

[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
[MBProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
}]];

[self.currentViewController presentViewController:alertController animated:YES completion:nil];
}

- (void)finishedLoadingVendorID:(NSString *)vendorID {
FieldEditorViewController *vc = self.currentViewController;
[MBProgressHUD hideHUDForView:vc.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:vc.navigationController.view animated:YES];
[vc.values setObject:vendorID forKey:kAccountVendorID];
[vc.tableView reloadData];
}

- (void)failedToLoadVendorIDs {
[MBProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.currentViewController.navigationController.view animated:YES];
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"The vendor ID could not be filled automatically. Please check your username and password or enter your vendor ID manually. You'll find it at the top of the Sales and Trends module on itunesconnect.apple.com.", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
}

Expand Down
16 changes: 8 additions & 8 deletions Classes/AccountsViewController.m
Expand Up @@ -16,7 +16,7 @@
#import "Product.h"
#import "CurrencyManager.h"
#import "ReportDownloadCoordinator.h"
#import "MBProgressHUD.h"
#import "ASProgressHUD.h"
#import "ReportImportOperation.h"
#import "PaymentsViewController.h"
#import "BadgedCell.h"
Expand Down Expand Up @@ -303,7 +303,7 @@ - (void)deleteAccount:(NSManagedObject *)account {
if (account) {
NSManagedObjectContext *context = self.managedObjectContext;
[context deleteObject:account];
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.navigationController.view animated:YES];
[self reloadAccounts];
[self.navigationController popViewControllerAnimated:YES];
}
Expand Down Expand Up @@ -655,7 +655,7 @@ - (void)fieldEditor:(FieldEditorViewController *)editor pressedButtonWithKey:(NS

NSDictionary *loginInfo = @{kAccountUsername: username, kAccountPassword: password};

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
ASProgressHUD *hud = [ASProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
hud.label.text = NSLocalizedString(@"Getting Access Token...", nil);
[self getAccessTokenWithLogin:loginInfo];
} else if ([key isEqualToString:@"GenerateAccessTokenButton"]) {
Expand All @@ -677,7 +677,7 @@ - (void)fieldEditor:(FieldEditorViewController *)editor pressedButtonWithKey:(NS

NSDictionary *loginInfo = @{kAccountUsername: username, kAccountPassword: password};

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
ASProgressHUD *hud = [ASProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
hud.label.text = NSLocalizedString(@"Generating Access Token...", nil);
[self generateAccessTokenWithLogin:loginInfo];
} else if ([key isEqualToString:@"SelectVendorIDButton"]) {
Expand All @@ -699,14 +699,14 @@ - (void)fieldEditor:(FieldEditorViewController *)editor pressedButtonWithKey:(NS

NSDictionary *loginInfo = @{kAccountUsername: username, kAccountPassword: password};

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
ASProgressHUD *hud = [ASProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
hud.label.text = NSLocalizedString(@"Fetching Vendor ID...", nil);
[self findVendorIDsWithLogin:loginInfo];
}
}

- (void)doExport {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
ASProgressHUD *hud = [ASProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.mode = MBProgressHUDModeDeterminateHorizontalBar;
hud.label.text = NSLocalizedString(@"Exporting", nil);

Expand Down Expand Up @@ -769,7 +769,7 @@ - (void)doExport {
[[NSFileManager defaultManager] removeItemAtURL:exportURL error:nil];

dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
[ASProgressHUD hideHUDForView:self.navigationController.view animated:YES];

self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:exportedReportsZipFileURL];
self.documentInteractionController.delegate = self;
Expand Down Expand Up @@ -804,7 +804,7 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
}
} else if (alertView.tag == kAlertTagConfirmDelete) {
if (buttonIndex != [alertView cancelButtonIndex]) {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
ASProgressHUD *hud = [ASProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.label.text = NSLocalizedString(@"Deleting Account...", nil);

ASAccount *account = self.selectedAccount;
Expand Down
8 changes: 4 additions & 4 deletions Classes/GraphView.m
Expand Up @@ -7,7 +7,7 @@
//

#import "GraphView.h"
#import "MBProgressHUD.h"
#import "ASProgressHUD.h"

#define ANIMATION_DURATION 0.4

Expand Down Expand Up @@ -128,9 +128,9 @@ - (NSString *)title {
- (void)lockScale:(UILongPressGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
maxLocked = !maxLocked;
[MBProgressHUD hideHUDForView:self animated:YES];
[ASProgressHUD hideHUDForView:self animated:YES];

MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self];
ASProgressHUD *hud = [[ASProgressHUD alloc] initWithView:self];
hud.animationType = MBProgressHUDAnimationZoom;
hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:(maxLocked ? @"Lock" : @"Unlock")]];
hud.mode = MBProgressHUDModeCustomView;
Expand All @@ -154,7 +154,7 @@ - (void)lockScale:(UILongPressGestureRecognizer *)recognizer {
}

- (void)hideHUD {
[MBProgressHUD hideHUDForView:self animated:YES];
[ASProgressHUD hideHUDForView:self animated:YES];
}

- (void)barSelected:(StackedBarView *)barView {
Expand Down
1 change: 0 additions & 1 deletion Classes/PromoCodesAppViewController.m
Expand Up @@ -9,7 +9,6 @@
#import "PromoCodesAppViewController.h"
#import "Product.h"
#import "ASAccount.h"
#import "MBProgressHUD.h"
#import "UIImage+Tinting.h"
#import "PromoCodeOperation.h"
#import "PromoCode.h"
Expand Down
6 changes: 3 additions & 3 deletions Classes/PromoCodesLicenseViewController.m
Expand Up @@ -8,7 +8,7 @@

#import "PromoCodesLicenseViewController.h"
#import "DownloadStepOperation.h"
#import "MBProgressHUD.h"
#import "ASProgressHUD.h"

@implementation PromoCodesLicenseViewController

Expand Down Expand Up @@ -48,7 +48,7 @@ - (void)cancel:(id)sender {
- (void)viewWillAppear:(BOOL)animated {
[self.webView loadHTMLString:licenseAgreementHTML baseURL:nil];

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[ASProgressHUD showHUDAddedTo:self.view animated:YES];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
Expand All @@ -67,7 +67,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
[MBProgressHUD hideHUDForView:self.view animated:YES];
[ASProgressHUD hideHUDForView:self.view animated:YES];
}

- (void)done:(id)sender {
Expand Down
2 changes: 1 addition & 1 deletion Support/AppSales-Info.plist
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>672</string>
<string>675</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
2 changes: 1 addition & 1 deletion Vendor/MBProgressHUD

0 comments on commit 58fdb7b

Please sign in to comment.