From 63670a7b2c49c376b13be1dc5bb29356469bc516 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Fri, 11 Sep 2020 07:28:24 -0700 Subject: [PATCH] [Snackbar] Remove non-shared classes from Snackbar supplemental directory. PiperOrigin-RevId: 331144273 --- .../SnackbarInputAccessoryViewController.m | 15 +++- .../examples/SnackbarOverlayViewExample.m | 22 ++++- .../Snackbar/examples/SnackbarSimpleExample.m | 17 ++++ .../examples/SnackbarSuspensionExample.m | 46 +++++++++- .../SnackbarExampleSupplemental.h | 26 +----- .../SnackbarExampleSupplemental.m | 85 +------------------ 6 files changed, 101 insertions(+), 110 deletions(-) diff --git a/components/Snackbar/examples/SnackbarInputAccessoryViewController.m b/components/Snackbar/examples/SnackbarInputAccessoryViewController.m index d80057ea7fc..a891c3b686a 100644 --- a/components/Snackbar/examples/SnackbarInputAccessoryViewController.m +++ b/components/Snackbar/examples/SnackbarInputAccessoryViewController.m @@ -16,9 +16,8 @@ #import "MaterialPalettes.h" #import "MaterialSnackbar.h" -#import "supplemental/SnackbarExampleSupplemental.h" -@interface SnackbarInputAccessoryViewController () +@interface SnackbarInputAccessoryViewController : UIViewController @property(nonatomic, strong) UITextField *textField; @@ -68,3 +67,15 @@ - (void)showSnackbarWithAction { } @end + +@implementation SnackbarInputAccessoryViewController (CatalogByConvention) + ++ (NSDictionary *)catalogMetadata { + return @{ + @"breadcrumbs" : @[ @"Snackbar", @"Snackbar Input Accessory" ], + @"primaryDemo" : @NO, + @"presentable" : @NO, + }; +} + +@end diff --git a/components/Snackbar/examples/SnackbarOverlayViewExample.m b/components/Snackbar/examples/SnackbarOverlayViewExample.m index 1a2a39d573d..fd0c1dbcb23 100644 --- a/components/Snackbar/examples/SnackbarOverlayViewExample.m +++ b/components/Snackbar/examples/SnackbarOverlayViewExample.m @@ -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 @@ -177,3 +185,15 @@ - (void)handleOverlayTransition:(id)transition { } @end + +@implementation SnackbarOverlayViewExample (CatalogByConvention) + ++ (NSDictionary *)catalogMetadata { + return @{ + @"breadcrumbs" : @[ @"Snackbar", @"Snackbar Overlay View" ], + @"primaryDemo" : @NO, + @"presentable" : @YES, + }; +} + +@end diff --git a/components/Snackbar/examples/SnackbarSimpleExample.m b/components/Snackbar/examples/SnackbarSimpleExample.m index bf023aa2c84..ff8fa63c849 100644 --- a/components/Snackbar/examples/SnackbarSimpleExample.m +++ b/components/Snackbar/examples/SnackbarSimpleExample.m @@ -18,6 +18,9 @@ #import "MaterialSnackbar.h" #import "supplemental/SnackbarExampleSupplemental.h" +@interface SnackbarSimpleExample : SnackbarExample +@end + @implementation SnackbarSimpleExample { BOOL _legacyMode; BOOL _dynamicType; @@ -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 *)testRunners { diff --git a/components/Snackbar/examples/SnackbarSuspensionExample.m b/components/Snackbar/examples/SnackbarSuspensionExample.m index 9963804620c..73b16867d18 100644 --- a/components/Snackbar/examples/SnackbarSuspensionExample.m +++ b/components/Snackbar/examples/SnackbarSuspensionExample.m @@ -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 allMessagesToken; @@ -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 diff --git a/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.h b/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.h index 6346b8f4a7d..e895d8e2bdb 100644 --- a/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.h +++ b/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.h @@ -21,6 +21,8 @@ #import "MaterialTypography.h" #import "MaterialTypographyScheme.h" +extern NSString *const kSnackbarExamplesCellIdentifier; + @interface SnackbarExample : MDCCollectionViewController @property(nonatomic) NSArray *choices; @property(nonatomic, strong) MDCSemanticColorScheme *colorScheme; @@ -28,27 +30,3 @@ - (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 -@end - -@interface SnackbarSuspensionExample : SnackbarExample - -- (void)handleSuspendStateChanged:(UISwitch *)sender; - -@end - -@interface SnackbarInputAccessoryViewController : UIViewController - -@end diff --git a/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.m b/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.m index 6d26b7f78ab..a45df02d995 100644 --- a/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.m +++ b/components/Snackbar/examples/supplemental/SnackbarExampleSupplemental.m @@ -14,7 +14,7 @@ #import "SnackbarExampleSupplemental.h" -static NSString *const kCellIdentifier = @"Cell"; +NSString *const kSnackbarExamplesCellIdentifier = @"Cell"; @implementation SnackbarExample @@ -22,7 +22,7 @@ - (void)setupExampleViews:(NSArray *)choices { self.choices = choices; self.view.backgroundColor = [UIColor whiteColor]; [self.collectionView registerClass:[MDCCollectionViewTextCell class] - forCellWithReuseIdentifier:kCellIdentifier]; + forCellWithReuseIdentifier:kSnackbarExamplesCellIdentifier]; } #pragma mark - UICollectionView @@ -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; @@ -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