| Code-Review | +1 |
}
#pragma mark - TabGroupCreationConsumer```suggestion
}
#pragma mark - TabGroupCreationConsumer
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
}
#pragma mark - TabGroupCreationConsumer```suggestion
}#pragma mark - TabGroupCreationConsumer
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
_gradientBackground.locations = @[ @0.0, @0.15, @1.0 ];If this is the same as the other one, should they be a shared constant?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
_gradientBackground.locations = @[ @0.0, @0.15, @1.0 ];If this is the same as the other one, should they be a shared constant?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
static_cast<tab_groups::TabGroupColorId>(_selectedButton.tag);Since this method is called four times throughout the view, should I store the result in an ivar instead? @ewa...@chromium.org
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// The tabGroupColorID used to generate the variants.TabGroupColorId
_colorID = tabGroupColorID;this doesnt crash ? I think it should be `_tabGroupColorID` ?
const CGFloat kViewBackgroundAlphaWithGradient = 0.6;this is used?
_gradientBackground.frame = _containerBackground.bounds;To avoid managing the layer you can also create a new class:
``` @interface TabGroupGradientView : UIView // update gradient colors.
@implementation TabGroupGradientView {
CAGradientLayer* _gradientLayer;
}- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_gradientLayer = [CAGradientLayer layer];
// Set fixed locations once
_gradientLayer.locations = @[ @0.0, @0.15, @1.0 ];
[self.layer addSublayer:_gradientLayer];
}
return self;
}- (void)layoutSubviews {
[super layoutSubviews];
_gradientLayer.frame = self.bounds;
}- (void)setGradientColors:(NSArray*)colors {
_gradientLayer.colors = colors;
}
@end```| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
static_cast<tab_groups::TabGroupColorId>(_selectedButton.tag);Since this method is called four times throughout the view, should I store the result in an ivar instead? @ewa...@chromium.org
It returns the current selected color, this is not a static value. It could be moved in a helper method but shouldnt be stored in an ivar.
_gradientBackground.frame = _containerBackground.bounds;To avoid managing the layer you can also create a new class:
``` @interface TabGroupGradientView : UIView // update gradient colors.
- (void)setGradientColors:(NSArray*)colors;
- @end
@implementation TabGroupGradientView {
CAGradientLayer* _gradientLayer;
}- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_gradientLayer = [CAGradientLayer layer];
// Set fixed locations once
_gradientLayer.locations = @[ @0.0, @0.15, @1.0 ];
[self.layer addSublayer:_gradientLayer];
}
return self;
}- (void)layoutSubviews {
[super layoutSubviews];
_gradientLayer.frame = self.bounds;
}- (void)setGradientColors:(NSArray*)colors {
_gradientLayer.colors = colors;
}
@end```
If you do that, create a class that takes several stops and colors and put it in ios/chrome/browser/shared/ui/elements/gradient/
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// The tabGroupColorID used to generate the variants.Anis CharaTabGroupColorId
Done
this doesnt crash ? I think it should be `_tabGroupColorID` ?
Done
const CGFloat kViewBackgroundAlphaWithGradient = 0.6;Anis Charathis is used?
Done
_gradientBackground.frame = _containerBackground.bounds;Gauthier AmbardTo avoid managing the layer you can also create a new class:
``` @interface TabGroupGradientView : UIView // update gradient colors.
- (void)setGradientColors:(NSArray*)colors;
- @end
@implementation TabGroupGradientView {
CAGradientLayer* _gradientLayer;
}- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_gradientLayer = [CAGradientLayer layer];
// Set fixed locations once
_gradientLayer.locations = @[ @0.0, @0.15, @1.0 ];
[self.layer addSublayer:_gradientLayer];
}
return self;
}- (void)layoutSubviews {
[super layoutSubviews];
_gradientLayer.frame = self.bounds;
}- (void)setGradientColors:(NSArray*)colors {
_gradientLayer.colors = colors;
}
@end```
If you do that, create a class that takes several stops and colors and put it in ios/chrome/browser/shared/ui/elements/gradient/
Done
static_cast<tab_groups::TabGroupColorId>(_selectedButton.tag);Ewann PelléSince this method is called four times throughout the view, should I store the result in an ivar instead? @ewa...@chromium.org
It returns the current selected color, this is not a static value. It could be moved in a helper method but shouldnt be stored in an ivar.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This CL applies a gradient background to the CreateTabGroup view and
adds specific coloring to the title TextField and the snapshot
background.
It also refactors the TabGroupColorPalette class to allow retrieving the
gradient background without instantiating the entire palette. This is
necessary for the CreateTabGroup view, which requires a new gradient
background each time a color button is tapped.
What about the gradient view update ?
// than 2 colors, colors must be CGColors.why are you not passing UIColors ?
// Initializes the view with a vertical gradient and more than 2 colors.this is not clear.
return [self initWithStartColor:topColorni: call `initWithColors:` directly.
- (instancetype)initWithColors:(NSArray*)colorsthis instancetype seems to be private, I'll suggest to move it at the beginning of the file, also add a comment explaining its purpose.
if (colors.count > 2 || locations.count > 2) {Add a comment explaining why this check is necessary.
- (void)setColors:(NSArray<UIColor*>*)colors {Looks like you are using UIColor here.
NSMutableArray* cgColors = [NSMutableArray arrayWithCapacity:colors.count];
for (UIColor* color in colors) {
[cgColors addObject:(__bridge id)color.CGColor];
}nit `self.gradientLayer.colors = [colors valueForKeyPath:@"CGColor"];`
self.translatesAutoresizingMaskIntoConstraints = NO;In general this is set by the caller.
[(TabGroupGradientView*)_containerBackgroundthis is needed ?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This CL applies a gradient background to the CreateTabGroup view and
adds specific coloring to the title TextField and the snapshot
background.
It also refactors the TabGroupColorPalette class to allow retrieving the
gradient background without instantiating the entire palette. This is
necessary for the CreateTabGroup view, which requires a new gradient
background each time a color button is tapped.
What about the gradient view update ?
Done
why are you not passing UIColors ?
Done
// Initializes the view with a vertical gradient and more than 2 colors.Anis Charathis is not clear.
Done
return [self initWithStartColor:topColorAnis Charani: call `initWithColors:` directly.
Done
this instancetype seems to be private, I'll suggest to move it at the beginning of the file, also add a comment explaining its purpose.
Done
Add a comment explaining why this check is necessary.
Done
Looks like you are using UIColor here.
Done
NSMutableArray* cgColors = [NSMutableArray arrayWithCapacity:colors.count];
for (UIColor* color in colors) {
[cgColors addObject:(__bridge id)color.CGColor];
}nit `self.gradientLayer.colors = [colors valueForKeyPath:@"CGColor"];`
Does not work due to CGColors not being an objective-C object.
In general this is set by the caller.
Done
[(TabGroupGradientView*)_containerBackgroundthis is needed ?
Since _containerBackground is declared as a UIView to support the default background, this cast is required to call setColors, which is a method specific to TabGroupGradientView.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Initializes the view with a vertical gradient, intended for use when morestill not very clear.
#pragma mark - Privateyou should only have one Private pragma mark.
nit: remove it.
NSMutableArray* cgColors = [NSMutableArray arrayWithCapacity:colors.count];
for (UIColor* color in colors) {
[cgColors addObject:(__bridge id)color.CGColor];
}Anis Charanit `self.gradientLayer.colors = [colors valueForKeyPath:@"CGColor"];`
Does not work due to CGColors not being an objective-C object.
Acknowledged
[(TabGroupGradientView*)_containerBackgroundAnis Charathis is needed ?
Since _containerBackground is declared as a UIView to support the default background, this cast is required to call setColors, which is a method specific to TabGroupGradientView.
In that case you should do:
`TabGroupGradientView* gradientBackground = base::apple::ObjCCast<TabGroupGradientView>(_containerBackground);`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Initializes the view with a vertical gradient, intended for use when moreAnis Charastill not very clear.
Done
you should only have one Private pragma mark.
nit: remove it.
Done
[(TabGroupGradientView*)_containerBackgroundAnis Charathis is needed ?
Ewann PelléSince _containerBackground is declared as a UIView to support the default background, this cast is required to call setColors, which is a method specific to TabGroupGradientView.
In that case you should do:
`TabGroupGradientView* gradientBackground = base::apple::ObjCCast<TabGroupGradientView>(_containerBackground);`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
@interface GradientView : UIViewPlease fix order:
go/bling-best-practices#declaration-order-in-header-files
@interface TabGroupGradientView : GradientViewAdd a description.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[cgColors addObject:(__bridge id)color.CGColor];You don't need the __bridge I think
// Returns the colors used for the gradient Background.Remove the comments here and above, those are public methods.
(id)UIColorFromRGB(group.tone30),Why the cast to id here?
@interface TabGroupGradientView : GradientViewAdd comment
base::apple::ObjCCastStrict<TabGroupGradientView>(_containerBackground);Rather than this, WDYT of adding another ivar for the same object but with the right type (i.e. in `configuredBackground` you set it), with a comment mentioning that it should be removed once shipped?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
@interface GradientView : UIViewEwann PelléPlease fix order:
go/bling-best-practices#declaration-order-in-header-files
Done
You don't need the __bridge I think
Done
// Returns the colors used for the gradient Background.Remove the comments here and above, those are public methods.
Done
Why the cast to id here?
removed
@interface TabGroupGradientView : GradientViewAnis CharaAdd comment
Done
@interface TabGroupGradientView : GradientViewAnis CharaAdd a description.
Done
base::apple::ObjCCastStrict<TabGroupGradientView>(_containerBackground);Rather than this, WDYT of adding another ivar for the same object but with the right type (i.e. in `configuredBackground` you set it), with a comment mentioning that it should be removed once shipped?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
_containerGradientBackground = background;Add a TODO here to update the type.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Add a TODO here to update the type.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[iOS] Add TabGroupPalette colors to the CreateTabGroup view
This CL applies a gradient background to the CreateTabGroupView and adds
specific coloring to the title TextField and the snapshot background.
It also refactors the TabGroupColorPalette class to allow retrieving the
gradient background without instantiating the entire palette. This is
necessary for the CreateTabGroup view, which requires a new gradient
background each time a color button is tapped.
Finally, it refactors GradientView by introducing a private initializer
to centralize configurations and a new initializer for gradients with
more than two colors. It also adds a TabGroupGradientView class to
handle the gradients in both CreateTabGroupView and TabGroupView.
screenshot :
https://drive.google.com/file/d/1dyuPCJ2PoHuoE_rl8UoFmYK5Akc9KcJJ/view?usp=sharing&resourcekey=0-GCXy9bNrxJFy1gRqxHo3JQ
record of the animations :
https://drive.google.com/file/d/1hOIkQkrbPoc1c3AgxNzohy89_MH9LiOs/view?usp=sharing&resourcekey=0-UeI-FaN9bfY3ewF_RpwS3Q
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |