mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
This new API enables clients to customize the corner radius of the filled portion of the progress view. Clients have requested this functionality via https://github.com/material-components/material-components-ios/issues/5429. Example usage to create a "rounded progress pill" effect: ```objc progressView.cornerRadius = CGRectGetHeight(progressView.bounds) / 2; ``` This feature request was requested by client team in service to their brand requirements. This PR adds an example that demonstrates the new behavior. See the associated snapshot tests for a complete suite of screenshots of the new behavior. ## Screenshots  Closes https://github.com/material-components/material-components-ios/issues/5429
135 lines
3.2 KiB
Objective-C
135 lines
3.2 KiB
Objective-C
// Copyright 2019-present the Material Components for iOS authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#import "MaterialSnapshot.h"
|
|
|
|
#import "MaterialProgressView.h"
|
|
|
|
@interface MDCProgressViewCornerRadiusSnapshotTests : MDCSnapshotTestCase
|
|
@property(nonatomic, strong) MDCProgressView *progressView;
|
|
@end
|
|
|
|
@implementation MDCProgressViewCornerRadiusSnapshotTests
|
|
|
|
- (void)setUp {
|
|
[super setUp];
|
|
|
|
// Uncomment below to recreate all the goldens (or add the following line to the specific
|
|
// test you wish to recreate the golden for).
|
|
// self.recordMode = YES;
|
|
|
|
self.progressView = [[MDCProgressView alloc] initWithFrame:CGRectMake(0, 0, 100, 10)];
|
|
self.progressView.cornerRadius = CGRectGetHeight(self.progressView.bounds) / 2;
|
|
}
|
|
|
|
- (void)tearDown {
|
|
self.progressView = nil;
|
|
|
|
[super tearDown];
|
|
}
|
|
|
|
- (void)generateSnapshotAndVerifyForView:(UIView *)view {
|
|
UIView *snapshotView = [view mdc_addToBackgroundView];
|
|
[self snapshotVerifyView:snapshotView];
|
|
}
|
|
|
|
#pragma mark - Tests
|
|
|
|
- (void)testProgress000LTR {
|
|
// When
|
|
self.progressView.progress = 0;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress000RTL {
|
|
// When
|
|
[self changeViewToRTL:self.progressView];
|
|
self.progressView.progress = 0;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress025LTR {
|
|
// When
|
|
self.progressView.progress = (float).25;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress025RTL {
|
|
// When
|
|
[self changeViewToRTL:self.progressView];
|
|
self.progressView.progress = (float).25;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress065LTR {
|
|
// When
|
|
self.progressView.progress = (float).65;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress065RTL {
|
|
// When
|
|
[self changeViewToRTL:self.progressView];
|
|
self.progressView.progress = (float).65;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress097LTR {
|
|
// When
|
|
self.progressView.progress = (float).97;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress097RTL {
|
|
// When
|
|
[self changeViewToRTL:self.progressView];
|
|
self.progressView.progress = (float).97;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress100LTR {
|
|
// When
|
|
self.progressView.progress = 1;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
- (void)testProgress100RTL {
|
|
// When
|
|
[self changeViewToRTL:self.progressView];
|
|
self.progressView.progress = 1;
|
|
|
|
// Then
|
|
[self generateSnapshotAndVerifyForView:self.progressView];
|
|
}
|
|
|
|
@end
|