Skip to content

Commit c907c65

Browse files
committed
fix for swift project, can not use func contentShadow() -> HWPanModalShadow
1 parent 6fe96f0 commit c907c65

16 files changed

+78
-44
lines changed

Demo/PanControllerExample/Base/HWBaseViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ - (BOOL)anchorModalToLongForm {
7676
return NO;
7777
}
7878

79-
- (HWPanModalShadow)contentShadow {
80-
return PanModalShadowMake([UIColor yellowColor], 10, CGSizeMake(0, 2), 1);
79+
- (HWPanModalShadow *)contentShadow {
80+
return [[HWPanModalShadow alloc] initWithColor:[UIColor yellowColor] shadowRadius:10 shadowOffset:CGSizeMake(0, 2) shadowOpacity:1];
8181
}
8282

8383
//- (UIViewAnimationOptions)transitionAnimationOptions {

Demo/PanControllerExample/Dynamic/HWDynamicHeightViewController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ @interface HWDynamicHeightViewController () <HWPanModalPresentable>
2525
@property (nonatomic, strong) UIButton *changeShadowButton;
2626
@property (nonatomic, strong) UIButton *clearShadowButton;
2727

28-
@property (nonatomic, assign) HWPanModalShadow shadowConfig;
28+
@property (nonatomic, strong) HWPanModalShadow *shadowConfig;
2929

3030
// corner
3131
@property (nonatomic, strong) UIButton *changeRoundCornerButton;
@@ -132,12 +132,12 @@ - (void)onTapChangeLong {
132132
}
133133

134134
- (void)onTapDefaultShadow {
135-
self.shadowConfig = PanModalShadowMake([UIColor blueColor], 8, CGSizeMake(0, 2), 1);
135+
self.shadowConfig = [[HWPanModalShadow alloc] initWithColor:[UIColor blueColor] shadowRadius:8 shadowOffset:CGSizeMake(0, 2) shadowOpacity:1];
136136
[self hw_panModalSetNeedsLayoutUpdate];
137137
}
138138

139139
- (void)onTapClearShadow {
140-
self.shadowConfig = PanModalShadowNil();
140+
self.shadowConfig = [HWPanModalShadow panModalShadowNil];
141141
[self hw_panModalSetNeedsLayoutUpdate];
142142
}
143143

@@ -188,7 +188,7 @@ - (PanModalHeight)longFormHeight {
188188
return self.longHeight;
189189
}
190190

191-
- (HWPanModalShadow)contentShadow {
191+
- (HWPanModalShadow *)contentShadow {
192192
return self.shadowConfig;
193193
}
194194

Demo/PanControllerExample/TestViewPanModal/HWSimplePanModalView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ - (UIScrollView *)panScrollable {
110110
return self.tableView;
111111
}
112112

113-
- (HWPanModalShadow)contentShadow {
114-
return PanModalShadowMake([UIColor systemPinkColor], 10, CGSizeMake(1, 1), 1);
113+
- (HWPanModalShadow *)contentShadow {
114+
return [[HWPanModalShadow alloc] initWithColor:[UIColor systemPinkColor] shadowRadius:10 shadowOffset:CGSizeMake(1, 1) shadowOpacity:1];
115115
}
116116

117117
//- (BOOL)allowsTouchEventsPassingThroughTransitionView {

HWPanModal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'HWPanModal'
11-
s.version = '0.9.7'
11+
s.version = '0.9.8'
1212
s.summary = 'HWPanModal is used to present controller and drag to dismiss.'
1313

1414
# This description is used to generate tags and improve search results.

HWPanModal.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
7EA0F56B230D5B7300ED20D2 /* HWPanModalPresentationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HWPanModalPresentationDelegate.m; sourceTree = "<group>"; };
134134
7EA0F56C230D5B7300ED20D2 /* HWPanModalPresentationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HWPanModalPresentationDelegate.h; sourceTree = "<group>"; };
135135
7EA0F56E230D5B7400ED20D2 /* UIViewController+Presentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Presentation.h"; sourceTree = "<group>"; };
136-
7EA0F56F230D5B7400ED20D2 /* UIViewController+LayoutHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+LayoutHelper.m"; sourceTree = "<group>"; };
137136
7EA0F570230D5B7400ED20D2 /* UIViewController+PanModalDefault.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+PanModalDefault.m"; sourceTree = "<group>"; };
138137
7EA0F571230D5B7400ED20D2 /* HWPanModalPresentable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HWPanModalPresentable.h; sourceTree = "<group>"; };
139138
7EA0F572230D5B7400ED20D2 /* UIViewController+Presentation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+Presentation.m"; sourceTree = "<group>"; };
@@ -501,7 +500,6 @@
501500
7EA0F56E230D5B7400ED20D2 /* UIViewController+Presentation.h */,
502501
7EA0F572230D5B7400ED20D2 /* UIViewController+Presentation.m */,
503502
7EA0F574230D5B7400ED20D2 /* UIViewController+LayoutHelper.h */,
504-
7EA0F56F230D5B7400ED20D2 /* UIViewController+LayoutHelper.m */,
505503
);
506504
path = Presentable;
507505
sourceTree = "<group>";

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- HWPanModal (0.9.5)
2+
- HWPanModal (0.9.7)
33
- Masonry (1.1.0)
44
- MJRefresh (3.5.0)
55
- SnapKit (5.0.1)
@@ -21,7 +21,7 @@ EXTERNAL SOURCES:
2121
:path: "./"
2222

2323
SPEC CHECKSUMS:
24-
HWPanModal: b6c51a2fd3ab5cfde868eec840c9e2d7465d745e
24+
HWPanModal: 2340d953661dbeadd1f041cde9e059c0704c873a
2525
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
2626
MJRefresh: 6afc955813966afb08305477dd7a0d9ad5e79a16
2727
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

Sources/Animator/HWPanModalPresentationAnimator.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ - (void)animateDismissal:(id<UIViewControllerContextTransitioning>)context {
141141

142142
- (void)springDismiss:(id <UIViewControllerContextTransitioning>)context fromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC presentable:(UIViewController <HWPanModalPresentable> *)presentable panView:(UIView *)panView {
143143
CGFloat offsetY = 0;
144-
HWPanModalShadow shadowConfig = [presentable contentShadow];
144+
HWPanModalShadow *shadowConfig = [presentable contentShadow];
145145
if (shadowConfig.shadowColor) {
146146
// we should make the panView move further to hide the shadow effect.
147147
offsetY = offsetY + shadowConfig.shadowRadius + shadowConfig.shadowOffset.height;

Sources/Controller/HWPanModalPresentationController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ - (void)resetRoundedCornersToView:(UIView *)view {
314314
}
315315

316316
- (void)updateContainerViewShadow {
317-
HWPanModalShadow shadow = [[self presentable] contentShadow];
317+
HWPanModalShadow *shadow = [[self presentable] contentShadow];
318318
if (shadow.shadowColor) {
319319
[self.panContainerView updateShadow:shadow.shadowColor shadowRadius:shadow.shadowRadius shadowOffset:shadow.shadowOffset shadowOpacity:shadow.shadowOpacity];
320320
} else {

Sources/Presentable/HWPanModalHeight.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@ CG_INLINE PanModalHeight PanModalHeightMake(PanModalHeightType heightType, CGFlo
3333
return modalHeight;
3434
}
3535

36-
struct HWPanModalShadow {
37-
UIColor *shadowColor;
38-
CGFloat shadowRadius;
39-
CGSize shadowOffset;
40-
float shadowOpacity;
41-
};
42-
43-
typedef struct HWPanModalShadow HWPanModalShadow;
44-
45-
CG_INLINE HWPanModalShadow PanModalShadowMake(UIColor *shadowColor, CGFloat shadowRadius, CGSize shadowOffset, float shadowOpacity) {
46-
HWPanModalShadow shadowConfig;
47-
shadowConfig.shadowColor = shadowColor;
48-
shadowConfig.shadowRadius = shadowRadius;
49-
shadowConfig.shadowOffset = shadowOffset;
50-
shadowConfig.shadowOpacity = shadowOpacity;
51-
return shadowConfig;
52-
}
53-
54-
CG_INLINE HWPanModalShadow PanModalShadowNil() {
55-
return PanModalShadowMake([UIColor clearColor], 0, CGSizeZero, 0);
56-
}
57-
5836
static inline BOOL HW_FLOAT_IS_ZERO(CGFloat value) {
5937
return (value > -FLT_EPSILON) && (value < FLT_EPSILON);
6038
}

Sources/Presentable/HWPanModalPresentable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import <HWPanModal/HWPresentingVCAnimatedTransitioning.h>
1212
#import <HWPanModal/HWPanModalIndicatorProtocol.h>
1313
#import <HWPanModal/HWBackgroundConfig.h>
14+
#import <HWPanModal/HWPanModalShadow.h>
1415

1516
NS_ASSUME_NONNULL_BEGIN
1617

@@ -271,7 +272,7 @@ typedef NS_ENUM(NSInteger, PresentingViewControllerAnimationStyle) {
271272
* presented content shadow
272273
* Default is None config
273274
*/
274-
- (HWPanModalShadow)contentShadow;
275+
- (HWPanModalShadow *)contentShadow;
275276

276277
#pragma mark - Indicator config
277278

Sources/Presentable/UIViewController+PanModalDefault.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ - (CGFloat)cornerRadius {
172172
return 8;
173173
}
174174

175-
- (HWPanModalShadow)contentShadow {
176-
return PanModalShadowMake(nil, 0, CGSizeZero, 0);
175+
- (HWPanModalShadow *)contentShadow {
176+
return [HWPanModalShadow panModalShadowNil];
177177
}
178178

179179
- (BOOL)showDragIndicator {

Sources/View/HWPanModalShadow.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// HWPanModalShadow.h
3+
// Pods
4+
//
5+
// Created by hb on 2023/8/3.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface HWPanModalShadow : NSObject
13+
14+
@property (nonatomic, strong) UIColor *shadowColor;
15+
@property (nonatomic, assign) CGFloat shadowRadius;
16+
@property (nonatomic, assign) CGSize shadowOffset;
17+
@property (nonatomic, assign) CGFloat shadowOpacity;
18+
19+
- (instancetype)initWithColor:(UIColor *)shadowColor shadowRadius:(CGFloat)shadowRadius shadowOffset:(CGSize)shadowOffset shadowOpacity:(CGFloat)shadowOpacity;
20+
21+
+ (instancetype)panModalShadowNil;
22+
23+
24+
@end
25+
26+
NS_ASSUME_NONNULL_END

Sources/View/HWPanModalShadow.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// HWPanModalShadow.m
3+
// Pods
4+
//
5+
// Created by hb on 2023/8/3.
6+
//
7+
8+
#import "HWPanModalShadow.h"
9+
10+
@implementation HWPanModalShadow
11+
12+
- (instancetype)initWithColor:(UIColor *)shadowColor shadowRadius:(CGFloat)shadowRadius shadowOffset:(CGSize)shadowOffset shadowOpacity:(CGFloat)shadowOpacity {
13+
self = [super init];
14+
if (self) {
15+
_shadowColor = shadowColor;
16+
_shadowRadius = shadowRadius;
17+
_shadowOffset = shadowOffset;
18+
_shadowOpacity = shadowOpacity;
19+
}
20+
21+
return self;
22+
}
23+
24+
+ (instancetype)panModalShadowNil {
25+
return [[HWPanModalShadow alloc] initWithColor:[UIColor clearColor] shadowRadius:0 shadowOffset:CGSizeZero shadowOpacity:0];
26+
}
27+
28+
@end

Sources/View/PanModal/HWPanModalContainerView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ - (void)addDragIndicatorViewToView:(UIView *)view {
277277
}
278278

279279
- (void)updateContainerViewShadow {
280-
HWPanModalShadow shadow = [[self presentable] contentShadow];
280+
HWPanModalShadow *shadow = [[self presentable] contentShadow];
281281
if (shadow.shadowColor) {
282282
[self.panContainerView updateShadow:shadow.shadowColor shadowRadius:shadow.shadowRadius shadowOffset:shadow.shadowOffset shadowOpacity:shadow.shadowOpacity];
283283
} else {

Sources/View/PanModal/HWPanModalContentView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ - (CGFloat)cornerRadius {
230230
return 8;
231231
}
232232

233-
- (HWPanModalShadow)contentShadow {
234-
return PanModalShadowMake(nil, 0, CGSizeZero, 0);
233+
- (HWPanModalShadow *)contentShadow {
234+
return [HWPanModalShadow panModalShadowNil];
235235
}
236236

237237
- (BOOL)showDragIndicator {

SwiftDemo/ControllerExample/Basic/BasicViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ extension BasicViewController {
3030
override func transitionAnimationOptions() -> UIView.AnimationOptions {
3131
return [.curveLinear]
3232
}
33-
33+
34+
override func contentShadow() -> HWPanModalShadow {
35+
return HWPanModalShadow(color: UIColor.red, shadowRadius: 10, shadowOffset: CGSizeMake(0, 2), shadowOpacity: 1)
36+
}
3437
}
3538

0 commit comments

Comments
 (0)