Skip to content

Commit

Permalink
fixed events on ti.colorwheel
Browse files Browse the repository at this point in the history
  • Loading branch information
mbender74 committed Sep 11, 2021
1 parent cf14b09 commit 23c26b1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 49 deletions.
10 changes: 5 additions & 5 deletions ios/Classes/TiColorwheelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
UIColorPickerViewController *pickerController;
BOOL touchStarted;
UIView *customView;
//#ifndef TI_USE_AUTOLAYOUT
// //In the rare case where the button is treated as a view group, we must have
// //an empty wrapper for -[parentViewForChild:]
// UIView *viewGroupWrapper;
//#endif
#ifndef TI_USE_AUTOLAYOUT
//In the rare case where the button is treated as a view group, we must have
//an empty wrapper for -[parentViewForChild:]
UIView *viewGroupWrapper;
#endif

}
@property(nonatomic,retain) TiViewProxy *containerViewController;
Expand Down
119 changes: 75 additions & 44 deletions ios/Classes/TiColorwheelView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ - (UIView *)customview

- (void)initializeState
{
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES]){

// Creates and keeps a reference to the view upon initialization
Expand All @@ -53,14 +55,14 @@ - (void)initializeState
//
// [self.proxy replaceValue:[NSNumber numberWithInteger: 44] forKey:@"width" notification:YES];

// colorwheel = [[UIColorWell alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, 50, 50)];
colorwheel = [[UIColorWell alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];


colorwheel = [[UIColorWell alloc] initWithFrame:self.bounds];
//colorwheel = [[UIColorWell alloc] initWithFrame:self.bounds];

//colorwheel = [[UIColorWell alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, 50, 50)];

colorwheel.clipsToBounds = YES;
colorwheel.clipsToBounds = NO;
colorwheel.userInteractionEnabled = NO;

// [colorwheel setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Expand All @@ -77,21 +79,19 @@ - (void)initializeState
colorwheel.supportsAlpha = [TiUtils boolValue:[self.proxy valueForKey:@"supportsAlpha"] def:YES];
}

// UIView* maskView = [[UIView alloc] initWithFrame:self.bounds];
// maskView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// maskView.clipsToBounds = NO;
//
// maskView.userInteractionEnabled = NO;
//
// // [colorwheel addTarget:self action:@selector(pickerDidChangeSelection:) forControlEvents:UIControlEventValueChanged];
//
// [maskView addSubview:colorwheel];
// [self addSubview:maskView];
//
// [self bringSubviewToFront:maskView];
//
UIView* maskView = [[UIView alloc] initWithFrame:self.bounds];
maskView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
maskView.clipsToBounds = NO;

maskView.userInteractionEnabled = NO;

// [colorwheel addTarget:self action:@selector(pickerDidChangeSelection:) forControlEvents:UIControlEventValueChanged];

[maskView addSubview:colorwheel];
[self addSubview:maskView];

[self bringSubviewToFront:maskView];

[self addSubview:colorwheel];


} else {
Expand All @@ -106,9 +106,22 @@ - (void)initializeState
if (customViewProxy != nil){
customView = customViewProxy.view;
customView.clipsToBounds = NO;
customView.userInteractionEnabled = NO;
//customView.userInteractionEnabled = YES;
//customView.frame = self.bounds;
[self addSubview:customView];


UIView* maskView = [[UIView alloc] initWithFrame:self.bounds];
maskView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
maskView.clipsToBounds = NO;

maskView.userInteractionEnabled = NO;

// [colorwheel addTarget:self action:@selector(pickerDidChangeSelection:) forControlEvents:UIControlEventValueChanged];

[maskView addSubview:customView];
[self addSubview:maskView];

[self bringSubviewToFront:maskView];
}
}

Expand All @@ -129,31 +142,43 @@ - (void)initializeState
// [self bringSubviewToFront:maskView];
}

self.userInteractionEnabled = YES;
//self.userInteractionEnabled = YES;


[super initializeState];
}


//#ifndef TI_USE_AUTOLAYOUT
//- (UIView *)viewGroupWrapper
//{
// if (viewGroupWrapper == nil) {
// viewGroupWrapper = [[UIView alloc] initWithFrame:[self bounds]];
// [viewGroupWrapper setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
// }
// if (colorwheel != [viewGroupWrapper superview]) {
// if (colorwheel != nil) {
// [viewGroupWrapper setFrame:[colorwheel bounds]];
// [colorwheel addSubview:viewGroupWrapper];
// } else {
// [viewGroupWrapper removeFromSuperview];
// }
// }
// return viewGroupWrapper;
//}
//#endif
#ifndef TI_USE_AUTOLAYOUT
- (UIView *)viewGroupWrapper
{
if (viewGroupWrapper == nil) {
viewGroupWrapper = [[UIView alloc] initWithFrame:[self bounds]];
[viewGroupWrapper setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
}
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES]){
if (colorwheel != [viewGroupWrapper superview]) {
if (colorwheel != nil) {
[viewGroupWrapper setFrame:[colorwheel bounds]];
[colorwheel addSubview:viewGroupWrapper];
} else {
[viewGroupWrapper removeFromSuperview];
}
}
}
else {
if (customView != [viewGroupWrapper superview]) {
if (customView != nil) {
[viewGroupWrapper setFrame:[customView bounds]];
[customView addSubview:viewGroupWrapper];
} else {
[viewGroupWrapper removeFromSuperview];
}
}
}
return viewGroupWrapper;
}
#endif

//-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
//{
Expand All @@ -173,7 +198,7 @@ - (void)initializeState

- (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES]){
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES] == YES){
[TiUtils setView:colorwheel positionRect:bounds];
}
else {
Expand Down Expand Up @@ -238,27 +263,33 @@ - (NSString *)hexStringFromColor:(UIColor *)color {

- (CGFloat)verifyWidth:(CGFloat)suggestedWidth
{
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES]){
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES] == YES){
// return 38;
return [[self colorwheel] sizeThatFits:CGSizeZero].width;
}
else {
else if([self customview] != nil){
// return self.bounds.size.width;
return [[self customview] sizeThatFits:CGSizeZero].width;
}
else {
return self.bounds.size.width;
}
// return [[self colorwheel] sizeThatFits:CGSizeZero].width;
}

- (CGFloat)verifyHeight:(CGFloat)suggestedHeight
{
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES]){
if ([TiUtils boolValue:[self.proxy valueForKey:@"systemButton"] def:YES] == YES){
// return 38;
return [[self colorwheel] sizeThatFits:CGSizeZero].height;
}
else {
//return self.bounds.size.height;
else if([self customview] != nil){
// return self.bounds.size.width;
return [[self customview] sizeThatFits:CGSizeZero].height;
}
else {
return self.bounds.size.height;
}
// return [[self colorwheel] sizeThatFits:CGSizeZero].height;
}
//#ifndef NO_SYSTEM_BUTTON
Expand Down

0 comments on commit 23c26b1

Please sign in to comment.