Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Commit 4d4bfa7

Browse files
codeman7material-automation
authored andcommitted
#Buttons Refactor private classes to their own files
PiperOrigin-RevId: 761992358
1 parent 02899b8 commit 4d4bfa7

File tree

5 files changed

+67
-43
lines changed

5 files changed

+67
-43
lines changed

components/M3CButton/src/M3CButton.m

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,14 @@
33
#import <UIKit/UIKit.h>
44

55
#import "M3CButton.h"
6+
#import "M3CIconAttributes.h"
7+
#import "M3CVisualBackgroundView.h"
68
#import "M3CAnimationActions.h"
79
#import "MDCShadow.h"
810
#import "MDCShadowsCollection.h"
911

1012
NS_ASSUME_NONNULL_BEGIN
1113

12-
/**
13-
Used to handle shadow animations of a @c M3CButton.
14-
*/
15-
@interface M3CVisualBackgroundView : UIView
16-
@end
17-
18-
@implementation M3CVisualBackgroundView
19-
20-
#pragma mark - CALayerDelegate
21-
22-
- (nullable id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)key {
23-
if (layer == self.layer && M3CIsMDCShadowPathKey(key)) {
24-
// Provide a custom action for the view's layer's shadow path only.
25-
return M3CShadowPathActionForLayer(layer);
26-
}
27-
return [super actionForLayer:layer forKey:key];
28-
}
29-
30-
@end
31-
32-
/** Used to store the scaling curve and initial size of the @c imageView of a @c M3CButton. */
33-
@interface M3CIconAttributes : NSObject
34-
35-
@property(nonatomic, copy, readonly) UIFontTextStyle textStyle;
36-
@property(nonatomic, assign, readonly) CGFloat pointSize;
37-
38-
- (instancetype)initWithTextStyle:(UIFontTextStyle)textStyle pointSize:(CGFloat)pointSize;
39-
40-
@end
41-
42-
@implementation M3CIconAttributes
43-
44-
- (instancetype)initWithTextStyle:(UIFontTextStyle)textStyle pointSize:(CGFloat)pointSize {
45-
self = [super init];
46-
if (self) {
47-
_textStyle = [textStyle copy]; // Use copy for NSString properties
48-
_pointSize = pointSize;
49-
}
50-
return self;
51-
}
52-
53-
@end
54-
5514
// Minimum touch size recommended by Apple:
5615
// https://developer.apple.com/design/human-interface-guidelines/accessibility#Mobility
5716
static const CGFloat kMinimumTouchTarget = 44.f;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#import <Foundation/Foundation.h>
2+
#import <UIKit/UIKit.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
/** Used to store the scaling curve and initial size of the @c imageView of a @c M3CButton. */
7+
@interface M3CIconAttributes : NSObject
8+
9+
@property(nonatomic, copy, readonly) UIFontTextStyle textStyle;
10+
@property(nonatomic, assign, readonly) CGFloat pointSize;
11+
12+
- (instancetype)initWithTextStyle:(UIFontTextStyle)textStyle pointSize:(CGFloat)pointSize;
13+
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import "M3CIconAttributes.h"
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
@implementation M3CIconAttributes
6+
7+
- (instancetype)initWithTextStyle:(UIFontTextStyle)textStyle pointSize:(CGFloat)pointSize {
8+
self = [super init];
9+
if (self) {
10+
_textStyle = [textStyle copy];
11+
_pointSize = pointSize;
12+
}
13+
return self;
14+
}
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import <UIKit/UIKit.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
/**
6+
Used to handle shadow animations of a @c M3CButton.
7+
*/
8+
@interface M3CVisualBackgroundView : UIView
9+
@end
10+
11+
NS_ASSUME_NONNULL_END
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#import "M3CVisualBackgroundView.h"
2+
#import "M3CAnimationActions.h"
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@implementation M3CVisualBackgroundView
7+
8+
#pragma mark - CALayerDelegate
9+
10+
- (nullable id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)key {
11+
if (layer == self.layer && M3CIsMDCShadowPathKey(key)) {
12+
// Provide a custom action for the view's layer's shadow path only.
13+
return M3CShadowPathActionForLayer(layer);
14+
}
15+
return [super actionForLayer:layer forKey:key];
16+
}
17+
18+
@end
19+
20+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)