Skip to content

Commit

Permalink
feat(macOS): add checkbox style to Ti.UI.Switch
Browse files Browse the repository at this point in the history
Fixes TIMOB-28302
  • Loading branch information
jquick-axway authored and sgtcoolguy committed Mar 5, 2021
1 parent 4d81389 commit 446d215
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions iphone/Classes/TiUISwitch.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ - (UISwitch *)switchView
animated = YES;
firstInit = YES;
switchView = [[UISwitch alloc] init];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
if ([TiUtils isMacOS] && [TiUtils isIOSVersionOrGreater:@"14.0"]) {
switchView.preferredStyle = [TiUtils intValue:[[self proxy] valueForKey:@"style"] def:UISwitchStyleAutomatic];
}
#endif
[switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
[self addSubview:switchView];
}
Expand Down
14 changes: 14 additions & 0 deletions iphone/Classes/UIModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@

@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_NONE;
@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_LINE;
@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_UNDERLINED;
@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_BEZEL;
@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_ROUNDED;
@property (nonatomic, readonly) NSNumber *INPUT_BORDERSTYLE_FILLED;

@property (nonatomic, readonly) NSNumber *PORTRAIT;
@property (nonatomic, readonly) NSNumber *LANDSCAPE_LEFT;
Expand Down Expand Up @@ -148,6 +150,18 @@
@property (nonatomic, readonly) NSNumber *BLEND_MODE_PLUS_DARKER;
@property (nonatomic, readonly) NSNumber *BLEND_MODE_PLUS_LIGHTER;

@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_FILLED;
@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_OUTLINED;
@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_TEXT;
@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_OPTION_POSITIVE;
@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_OPTION_NEGATIVE;
@property (nonatomic, readonly) NSNumber *BUTTON_STYLE_OPTION_NEUTRAL;

@property (nonatomic, readonly) NSNumber *SWITCH_STYLE_SLIDER;
@property (nonatomic, readonly) NSNumber *SWITCH_STYLE_CHECKBOX;
@property (nonatomic, readonly) NSNumber *SWITCH_STYLE_TOGGLEBUTTON;
@property (nonatomic, readonly) NSNumber *SWITCH_STYLE_CHIP;

@property (nonatomic, readonly) NSNumber *AUTOLINK_NONE;
@property (nonatomic, readonly) NSNumber *AUTOLINK_ALL;
@property (nonatomic, readonly) NSNumber *AUTOLINK_PHONE_NUMBERS;
Expand Down
21 changes: 21 additions & 0 deletions iphone/Classes/UIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ - (TiUIActivityIndicatorStyleProxy *)ActivityIndicatorStyle

MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_NONE, UITextBorderStyleNone);
MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_LINE, UITextBorderStyleLine);
MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_UNDERLINED, UITextBorderStyleLine);
MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_BEZEL, UITextBorderStyleBezel);
MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_ROUNDED, UITextBorderStyleRoundedRect);
MAKE_SYSTEM_PROP(INPUT_BORDERSTYLE_FILLED, UITextBorderStyleBezel);

MAKE_SYSTEM_PROP(PICKER_TYPE_PLAIN, -1);
MAKE_SYSTEM_PROP(PICKER_TYPE_DATE_AND_TIME, UIDatePickerModeDateAndTime);
Expand Down Expand Up @@ -211,6 +213,25 @@ - (TiUIActivityIndicatorStyleProxy *)ActivityIndicatorStyle
MAKE_SYSTEM_PROP(BLEND_MODE_PLUS_DARKER, kCGBlendModePlusDarker);
MAKE_SYSTEM_PROP(BLEND_MODE_PLUS_LIGHTER, kCGBlendModePlusLighter);

MAKE_SYSTEM_PROP(BUTTON_STYLE_FILLED, UIBarButtonItemStylePlain);
MAKE_SYSTEM_PROP(BUTTON_STYLE_OUTLINED, UIBarButtonItemStylePlain);
MAKE_SYSTEM_PROP(BUTTON_STYLE_TEXT, UIBarButtonItemStylePlain);
MAKE_SYSTEM_PROP(BUTTON_STYLE_OPTION_POSITIVE, UIBarButtonItemStyleDone);
MAKE_SYSTEM_PROP(BUTTON_STYLE_OPTION_NEGATIVE, UIBarButtonItemStylePlain);
MAKE_SYSTEM_PROP(BUTTON_STYLE_OPTION_NEUTRAL, UIBarButtonItemStylePlain);

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
MAKE_SYSTEM_PROP(SWITCH_STYLE_SLIDER, UISwitchStyleSliding);
MAKE_SYSTEM_PROP(SWITCH_STYLE_CHECKBOX, UISwitchStyleCheckbox);
MAKE_SYSTEM_PROP(SWITCH_STYLE_TOGGLEBUTTON, UISwitchStyleCheckbox);
MAKE_SYSTEM_PROP(SWITCH_STYLE_CHIP, UISwitchStyleCheckbox);
#else
MAKE_SYSTEM_PROP(SWITCH_STYLE_SLIDER, 1);
MAKE_SYSTEM_PROP(SWITCH_STYLE_CHECKBOX, 2);
MAKE_SYSTEM_PROP(SWITCH_STYLE_TOGGLEBUTTON, 3);
MAKE_SYSTEM_PROP(SWITCH_STYLE_CHIP, 4);
#endif

MAKE_SYSTEM_PROP(URL_ERROR_AUTHENTICATION, NSURLErrorUserAuthenticationRequired);
MAKE_SYSTEM_PROP(URL_ERROR_BAD_URL, NSURLErrorBadURL);
MAKE_SYSTEM_PROP(URL_ERROR_CONNECT, NSURLErrorCannotConnectToHost);
Expand Down

0 comments on commit 446d215

Please sign in to comment.