Skip to content

Commit

Permalink
Add automatic HUD style, add private thick appearance, remove more de…
Browse files Browse the repository at this point in the history
…precated methods, update test app
  • Loading branch information
JonasGessner committed Oct 14, 2020
1 parent 121877e commit c110901
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 36 deletions.
7 changes: 5 additions & 2 deletions Examples/JGProgressHUD-Tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
LastSwiftMigration = 1030;
ProvisioningStyle = Automatic;
};
6BC018C3197BF28100DA4C49 = {
DevelopmentTeam = VASVVWP22W;
};
};
};
buildConfigurationList = 6BC018BF197BF28100DA4C49 /* Build configuration list for PBXProject "JGProgressHUD-Tests" */;
Expand Down Expand Up @@ -776,7 +779,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "JGProgressHUD-Tests/JGProgressHUD-Tests.entitlements";
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = VASVVWP22W;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JGProgressHUD-Tests/JGProgressHUD-Tests-Prefix.pch";
INFOPLIST_FILE = "$(SRCROOT)/JGProgressHUD-Tests/JGProgressHUD-Tests-Info.plist";
Expand All @@ -798,7 +801,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "JGProgressHUD-Tests/JGProgressHUD-Tests.entitlements";
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = VASVVWP22W;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JGProgressHUD-Tests/JGProgressHUD-Tests-Prefix.pch";
INFOPLIST_FILE = "$(SRCROOT)/JGProgressHUD-Tests/JGProgressHUD-Tests-Info.plist";
Expand Down
62 changes: 47 additions & 15 deletions Examples/JGProgressHUD-Tests/JGMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@

@import JGProgressHUD;

@interface JGProgressHUD ()

@property (nonatomic, assign) BOOL thick;

@end

#define HAS_THICK 0

@interface JGMainViewController () <JGProgressHUDDelegate> {
JGProgressHUDStyle _style;
JGProgressHUDInteractionType _interaction;
BOOL _zoom;
BOOL _dim;
BOOL _vibrancy;
BOOL _shadow;
BOOL _automaticStyle;
BOOL _largeSquare;
}

@end
Expand All @@ -27,6 +37,7 @@ @implementation JGMainViewController
- (instancetype)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
_automaticStyle = YES;
_interaction = JGProgressHUDInteractionTypeBlockTouchesOnHUDView;
}
return self;
Expand Down Expand Up @@ -54,7 +65,7 @@ - (void)progressHUD:(JGProgressHUD *)progressHUD didDismissFromView:(UIView *)vi
#pragma mark -

- (JGProgressHUD *)prototypeHUD {
JGProgressHUD *HUD = [[JGProgressHUD alloc] initWithStyle:_style];
JGProgressHUD *HUD = (_automaticStyle ? [[JGProgressHUD alloc] initWithAutomaticStyle] : [[JGProgressHUD alloc] initWithStyle:_style]);
HUD.interactionType = _interaction;

if (_zoom) {
Expand All @@ -66,6 +77,11 @@ - (JGProgressHUD *)prototypeHUD {
HUD.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f];
}

if (_largeSquare) {
HUD.thick = YES;
HUD.contentInsets = UIEdgeInsetsMake(40, 40, 40, 40);
}

HUD.vibrancyEnabled = _vibrancy;

if (_shadow) {
Expand Down Expand Up @@ -274,7 +290,13 @@ - (void)showTextHUD {
}

- (void)setHUDStyle:(UISegmentedControl *)c {
_style = c.selectedSegmentIndex;
if (c.selectedSegmentIndex == 0) {
_automaticStyle = YES;
}
else {
_automaticStyle = NO;
_style = c.selectedSegmentIndex - 1;
}
}

- (void)setInteraction:(UISegmentedControl *)c {
Expand All @@ -285,6 +307,10 @@ - (void)setZoom:(UISegmentedControl *)c {
_zoom = c.selectedSegmentIndex;
}

- (void)setLargeSquare:(UISwitch *)s {
_largeSquare = s.on;
}

- (void)setVibrancy:(UISwitch *)s {
_vibrancy = s.on;
}
Expand Down Expand Up @@ -312,7 +338,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 7;
return 7 + HAS_THICK;
}
else {
return 8;
Expand All @@ -324,7 +350,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
}

if (indexPath.section == 0) {
Expand All @@ -333,9 +358,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
if (indexPath.row == 0) {
cell.textLabel.text = @"Style";

UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"Extra Light", @"Light", @"Dark"]];
segment.selectedSegmentIndex = _style;
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"Auto", @"Extra Light", @"Light", @"Dark"]];
segment.selectedSegmentIndex = (_automaticStyle ? 0 : _style + 1);
[segment addTarget:self action:@selector(setHUDStyle:) forControlEvents:UIControlEventValueChanged];
segment.apportionsSegmentWidthsByContent = YES;

cell.accessoryView = segment;
[segment sizeToFit];
Expand All @@ -346,12 +372,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"All", @"On HUD", @"None"]];
segment.selectedSegmentIndex = _interaction;
[segment addTarget:self action:@selector(setInteraction:) forControlEvents:UIControlEventValueChanged];
segment.apportionsSegmentWidthsByContent = YES;
[segment sizeToFit];

CGRect f = segment.frame;
f.size.width -= 30.0f;
segment.frame = f;

cell.accessoryView = segment;
}
else if (indexPath.row == 2) {
Expand All @@ -376,16 +399,27 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.accessoryView = t;
cell.textLabel.text = @"Show a keyboard";
}
#if HAS_THICK
else if (indexPath.row == 4) {
cell.textLabel.text = @"Use vibrancy effect";
cell.textLabel.text = @"Large, Square Appearance";
UISwitch *s = [[UISwitch alloc] init];
s.tintColor = [UIColor whiteColor];
s.on = _largeSquare;

[s addTarget:self action:@selector(setLargeSquare:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = s;
}
#endif
else if (indexPath.row == 4 + HAS_THICK) {
cell.textLabel.text = @"Use Vibrancy Effect";
UISwitch *s = [[UISwitch alloc] init];
s.tintColor = [UIColor whiteColor];
s.on = _vibrancy;

[s addTarget:self action:@selector(setVibrancy:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = s;
}
else if (indexPath.row == 5) {
else if (indexPath.row == 5 + HAS_THICK) {
cell.textLabel.text = @"Dim Background";
UISwitch *s = [[UISwitch alloc] init];
s.tintColor = [UIColor whiteColor];
Expand All @@ -394,7 +428,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[s addTarget:self action:@selector(setDim:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = s;
}
else if (indexPath.row == 6) {
else if (indexPath.row == 6 + HAS_THICK) {
cell.textLabel.text = @"Apply Shadow";
UISwitch *s = [[UISwitch alloc] init];
s.tintColor = [UIColor whiteColor];
Expand Down Expand Up @@ -489,8 +523,6 @@ - (void)viewDidLoad {

self.title = @"JGProgressHUD";

self.tableView.backgroundColor = [UIColor colorWithWhite:0.8f alpha:1.0f];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Push VC" style:UIBarButtonItemStylePlain target:self action:@selector(pushDetailVC)];
}

Expand Down
Loading

0 comments on commit c110901

Please sign in to comment.