Skip to content

Commit

Permalink
[Snackbar] Remove non-shared classes from Snackbar supplemental direc…
Browse files Browse the repository at this point in the history
…tory.

PiperOrigin-RevId: 331144273
  • Loading branch information
bryanoltman authored and material-automation committed Sep 11, 2020
1 parent a24993d commit 63670a7
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

#import "MaterialPalettes.h"
#import "MaterialSnackbar.h"
#import "supplemental/SnackbarExampleSupplemental.h"

@interface SnackbarInputAccessoryViewController ()
@interface SnackbarInputAccessoryViewController : UIViewController

@property(nonatomic, strong) UITextField *textField;

Expand Down Expand Up @@ -68,3 +67,15 @@ - (void)showSnackbarWithAction {
}

@end

@implementation SnackbarInputAccessoryViewController (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Input Accessory" ],
@"primaryDemo" : @NO,
@"presentable" : @NO,
};
}

@end
22 changes: 21 additions & 1 deletion components/Snackbar/examples/SnackbarOverlayViewExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@
static const CGFloat kFABSideOffset = 24;
static const CGFloat kBottomBarHeight = 44;

@interface SnackbarOverlayViewExample ()
@interface SnackbarOverlayViewExample : SnackbarExample

/** The floating action button shown in the bottom right corner. */
@property(nonatomic) MDCFloatingButton *floatingButton;

@property(nonatomic) UIView *bottomBar;

@property(nonatomic) BOOL isShowingBottomBar;

@property(nonatomic, assign) CGFloat floatingButtonOffset;
@end

Expand Down Expand Up @@ -177,3 +185,15 @@ - (void)handleOverlayTransition:(id<MDCOverlayTransitioning>)transition {
}

@end

@implementation SnackbarOverlayViewExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Overlay View" ],
@"primaryDemo" : @NO,
@"presentable" : @YES,
};
}

@end
17 changes: 17 additions & 0 deletions components/Snackbar/examples/SnackbarSimpleExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#import "MaterialSnackbar.h"
#import "supplemental/SnackbarExampleSupplemental.h"

@interface SnackbarSimpleExample : SnackbarExample <MDCSnackbarManagerDelegate>
@end

@implementation SnackbarSimpleExample {
BOOL _legacyMode;
BOOL _dynamicType;
Expand Down Expand Up @@ -261,6 +264,20 @@ - (void)willPresentSnackbarWithMessageView:(nullable MDCSnackbarMessageView *)me

@end

@implementation SnackbarSimpleExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar" ],
@"description" : @"Snackbars provide brief messages about app processes at the bottom of "
@"the screen.",
@"primaryDemo" : @YES,
@"presentable" : @YES,
};
}

@end

@implementation SnackbarSimpleExample (SnapshotTestingByConvention)

- (NSDictionary<NSString *, void (^)(void)> *)testRunners {
Expand Down
46 changes: 45 additions & 1 deletion components/Snackbar/examples/SnackbarSuspensionExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
static NSString *const kCategoryA = @"CategoryA";
static NSString *const kCategoryB = @"CategoryB";

@interface SnackbarSuspensionExample ()
@interface SnackbarSuspensionExample : SnackbarExample

- (void)handleSuspendStateChanged:(UISwitch *)sender;

/** The current suspension token. */
@property(nonatomic) id<MDCSnackbarSuspensionToken> allMessagesToken;
Expand Down Expand Up @@ -178,3 +180,45 @@ - (void)handleSuspendStateChanged:(UISwitch *)sender {
}

@end

@implementation SnackbarSuspensionExample (CollectionView)

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCCollectionViewTextCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:kSnackbarExamplesCellIdentifier
forIndexPath:indexPath];

cell.textLabel.text = self.choices[indexPath.row];
cell.isAccessibilityElement = YES;
cell.accessibilityTraits = cell.accessibilityTraits | UIAccessibilityTraitButton;
cell.accessibilityLabel = cell.textLabel.text;
if (indexPath.row > 2) {
UISwitch *editingSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
[editingSwitch setTag:indexPath.row];
[editingSwitch addTarget:self
action:@selector(handleSuspendStateChanged:)
forControlEvents:UIControlEventValueChanged];
cell.accessoryView = editingSwitch;
cell.accessibilityValue = editingSwitch.isOn ? @"on" : @"off";
} else {
cell.accessoryView = nil;
cell.accessibilityValue = nil;
}

return cell;
}

@end

@implementation SnackbarSuspensionExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Suspension" ],
@"primaryDemo" : @NO,
@"presentable" : @YES,
};
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,12 @@
#import "MaterialTypography.h"
#import "MaterialTypographyScheme.h"

extern NSString *const kSnackbarExamplesCellIdentifier;

@interface SnackbarExample : MDCCollectionViewController
@property(nonatomic) NSArray *choices;
@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;

- (void)setupExampleViews:(NSArray *)choices;
@end

@interface SnackbarOverlayViewExample : SnackbarExample

/** The floating action button shown in the bottom right corner. */
@property(nonatomic) MDCFloatingButton *floatingButton;

@property(nonatomic) UIView *bottomBar;

@property(nonatomic) BOOL isShowingBottomBar;

@end

@interface SnackbarSimpleExample : SnackbarExample <MDCSnackbarManagerDelegate>
@end

@interface SnackbarSuspensionExample : SnackbarExample

- (void)handleSuspendStateChanged:(UISwitch *)sender;

@end

@interface SnackbarInputAccessoryViewController : UIViewController

@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

#import "SnackbarExampleSupplemental.h"

static NSString *const kCellIdentifier = @"Cell";
NSString *const kSnackbarExamplesCellIdentifier = @"Cell";

@implementation SnackbarExample

- (void)setupExampleViews:(NSArray *)choices {
self.choices = choices;
self.view.backgroundColor = [UIColor whiteColor];
[self.collectionView registerClass:[MDCCollectionViewTextCell class]
forCellWithReuseIdentifier:kCellIdentifier];
forCellWithReuseIdentifier:kSnackbarExamplesCellIdentifier];
}

#pragma mark - UICollectionView
Expand All @@ -35,7 +35,7 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCCollectionViewTextCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier
[collectionView dequeueReusableCellWithReuseIdentifier:kSnackbarExamplesCellIdentifier
forIndexPath:indexPath];
cell.textLabel.text = self.choices[indexPath.row];
cell.accessibilityTraits = cell.accessibilityTraits | UIAccessibilityTraitButton;
Expand All @@ -47,82 +47,3 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView

@end

@implementation SnackbarSimpleExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar" ],
@"description" : @"Snackbars provide brief messages about app processes at the bottom of "
@"the screen.",
@"primaryDemo" : @YES,
@"presentable" : @YES,
};
}

@end

@implementation SnackbarOverlayViewExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Overlay View" ],
@"primaryDemo" : @NO,
@"presentable" : @YES,
};
}

@end

@implementation SnackbarInputAccessoryViewController (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Input Accessory" ],
@"primaryDemo" : @NO,
@"presentable" : @NO,
};
}

@end

@implementation SnackbarSuspensionExample (CollectionView)

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCCollectionViewTextCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier
forIndexPath:indexPath];

cell.textLabel.text = self.choices[indexPath.row];
cell.isAccessibilityElement = YES;
cell.accessibilityTraits = cell.accessibilityTraits | UIAccessibilityTraitButton;
cell.accessibilityLabel = cell.textLabel.text;
if (indexPath.row > 2) {
UISwitch *editingSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
[editingSwitch setTag:indexPath.row];
[editingSwitch addTarget:self
action:@selector(handleSuspendStateChanged:)
forControlEvents:UIControlEventValueChanged];
cell.accessoryView = editingSwitch;
cell.accessibilityValue = editingSwitch.isOn ? @"on" : @"off";
} else {
cell.accessoryView = nil;
cell.accessibilityValue = nil;
}

return cell;
}

@end

@implementation SnackbarSuspensionExample (CatalogByConvention)

+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Snackbar", @"Snackbar Suspension" ],
@"primaryDemo" : @NO,
@"presentable" : @YES,
};
}

@end

0 comments on commit 63670a7

Please sign in to comment.