Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from inloop/bugfix/round_corners
Browse files Browse the repository at this point in the history
FEAT: ViewStyle cornerRadius
  • Loading branch information
radimhalfar authored Mar 7, 2018
2 parents 3c713e8 + d669557 commit 6b4de73
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 291 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
Styles: 4764bafc66c398f3125f8fbcc0ad0a0121a7f572
Styles: 279ecbbfed51efad94db005e32089f9c7f9c485a

PODFILE CHECKSUM: f5341d1bc44d76e5ca1e0d50940004053970d8dc

Expand Down
2 changes: 1 addition & 1 deletion Example/Pods/Local Podspecs/Styles.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

280 changes: 142 additions & 138 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions Example/Pods/Target Support Files/Styles/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Example/Styles.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -376,7 +376,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -390,7 +390,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Styles/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
Expand All @@ -406,7 +406,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Styles/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
Expand Down
6 changes: 3 additions & 3 deletions Example/Styles/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ let styleWithEffects = TextStyle(
)

let rounded = ViewStyle(
.roundCorners([.topLeft, .bottomRight], radius: 10),
.cornerRadius(10),
.borderWidth(3),
.borderColor(.red),
.opacity(0.8)
Expand All @@ -114,12 +114,12 @@ let textFieldColorStyle = ViewStyle(
let red = ViewStyle(
.borderColor(.red),
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 0)
.cornerRadius(0)
)

let blue = red.updating(
.borderColor(.blue),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(10)
)

let greenHeadline = TextStyle(
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ let styleWithEffects = TextStyle(

```swift
let pill = ViewStyle(
.roundCorners(.allCorners, radius: 10),
.cornerRadius(10),
.borderWidth(3),
.borderColor(.red),
.opacity(0.8)
Expand Down Expand Up @@ -263,7 +263,7 @@ UITextView.appearance().setViewStyle(blue, for: .inactive)
let blue = ViewStyle(
.borderColor(.blue),
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(10)
)

myButton.viewStyle = blue
Expand All @@ -274,15 +274,15 @@ myButton.viewStyle = blue
```swift
let app = ViewStyle(
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(10)
)

let blue = app.updating(.borderColor(.blue))
```
```swift
let app = ViewStyle(
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(radius: 10)
)

let thick = app.updating(.borderWidth(3))
Expand All @@ -293,7 +293,7 @@ let thick = app.updating(.borderWidth(3))
```swift
let app = ViewStyle(
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(10)
)

let semiVisible = ViewStyle(
Expand All @@ -306,7 +306,7 @@ myLabel.viewStyle = app + semiVisible
```swift
let app = ViewStyle(
.borderWidth(0.5),
.roundCorners(.allCorners, radius: 10)
.cornerRadius(10)
)

let semiVisible = ViewStyle(
Expand Down
4 changes: 2 additions & 2 deletions Styles.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'Styles'
s.version = '0.15.10'
s.version = '0.15.11'
s.summary = 'UI Elements rapid styling'
s.description = <<-DESC
UIElements styling made easy, declarative and rapid.
Expand All @@ -18,7 +18,7 @@ UIElements styling made easy, declarative and rapid.
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Radim Halfar' => '[email protected]', 'Jakub Petrik' => '[email protected]' }
s.source = { :git => 'https://github.com/inloop/Styles.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'
s.swift_version = '4.1'
s.source_files = 'Styles/Classes/**/*'
s.test_spec 'Tests' do |test_spec|
Expand Down
3 changes: 1 addition & 2 deletions Styles/Classes/UIElement+Extensions/UILabel+Styles.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ - (void)applyStyle {
[self updateText];
}

- (void)swizzle_setText:(NSString *)text
{
- (void)swizzle_setText:(NSString *)text {
[self swizzle_setText:text];
[self updateText];
}
Expand Down
2 changes: 1 addition & 1 deletion Styles/Classes/UIElement+Extensions/UITextField+Styles.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (BOOL)swizzle_resignFirstResponder {
- (void)swizzle_awakeFromNib {
[self swizzle_awakeFromNib];
[self addTarget:self
action:@selector(applyStyle)
action:@selector(applyStyleForCurrentState)
forControlEvents:UIControlEventEditingChanged];
}

Expand Down
10 changes: 8 additions & 2 deletions Styles/Classes/UIElement+Extensions/UITextView+Styles.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ - (void)swizzle_awakeFromNib {

- (void)setTextStyle:(TextStyle *)style forState:(TextInputState)state {
self.textStyles[@(state)] = style;
[self applyStyle];
[self applyStylesForCurrentState];
}

- (void)setViewStyle:(ViewStyle *)style forState:(TextInputState)state {
self.viewStyles[@(state)] = style;
[self applyStyle];
[self applyStylesForCurrentState];
}

- (void)applyStylesForState:(TextInputState)state {
Expand All @@ -90,6 +90,12 @@ - (void)applyStylesForState:(TextInputState)state {
[self applyViewStyle:viewSyle];
}

- (void)applyStylesForCurrentState {
TextInputState state = self.isFirstResponder ? kEditing : kInactive;
[self applyStyle];
[self applyStylesForState:state];
}

- (void)checkEqualLayerInStyles {
ViewStyle *editing = self.viewStyles[@(kEditing)];
ViewStyle *inactive = self.viewStyles[@(kInactive)];
Expand Down
13 changes: 0 additions & 13 deletions Styles/Classes/UIElement+Extensions/UIView+Styles.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ @implementation UIView (Styles)

SYNTHESIZE_PROPERTY_OBJ(ViewStyle, viewStyle, ViewStyle);

+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
swizzle_instance_method(class, @selector(layoutSubviews), @selector(swizzle_layoutSubviews));
});
}

- (void)swizzle_layoutSubviews {
[self swizzle_layoutSubviews];
[self.viewStyle applyLayoutTo:self];
}

- (void)applyStyle {
[self.viewStyle applyTo:self];
}
Expand Down
Loading

0 comments on commit 6b4de73

Please sign in to comment.