-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated for MaterialComponents for iOS version 34.0.1
- Loading branch information
Showing
22 changed files
with
693 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...nces/v34.0.1.Debug/MDFTextAccessibility.framework/Headers/MDFTextAccessibility-umbrella.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#else | ||
#ifndef FOUNDATION_EXPORT | ||
#if defined(__cplusplus) | ||
#define FOUNDATION_EXPORT extern "C" | ||
#else | ||
#define FOUNDATION_EXPORT extern | ||
#endif | ||
#endif | ||
#endif | ||
|
||
#import "MDFTextAccessibility.h" | ||
|
||
FOUNDATION_EXPORT double MDFTextAccessibilityVersionNumber; | ||
FOUNDATION_EXPORT const unsigned char MDFTextAccessibilityVersionString[]; | ||
|
199 changes: 199 additions & 0 deletions
199
references/v34.0.1.Debug/MDFTextAccessibility.framework/Headers/MDFTextAccessibility.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
/* | ||
Copyright 2016-present Google Inc. 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 <UIKit/UIKit.h> | ||
|
||
/** Options for selecting text colors that provide acceptable contrast ratios. */ | ||
typedef NS_OPTIONS(NSUInteger, MDFTextAccessibilityOptions) { | ||
/** No options. */ | ||
MDFTextAccessibilityOptionsNone = 0, | ||
|
||
/** Font size is at least 14pt bold or 18pt normal. */ | ||
MDFTextAccessibilityOptionsLargeFont = 1 << 0, | ||
|
||
/** Do not modify alpha values to find good colors. */ | ||
MDFTextAccessibilityOptionsPreserveAlpha = 1 << 1, | ||
|
||
/** Prefer darker colors to lighter colors. */ | ||
MDFTextAccessibilityOptionsPreferDarker = 1 << 2, | ||
|
||
/** Prefer lighter colors to darker colors. */ | ||
MDFTextAccessibilityOptionsPreferLighter = 1 << 3, | ||
|
||
/** Use enhanced contrast ratios (level AAA) instead of minimum ratios (level AA). */ | ||
MDFTextAccessibilityOptionsEnhancedContrast = 1 << 4, | ||
}; | ||
|
||
/** | ||
MDFTextAccessiblity provides methods to compute accessible text colors. | ||
*/ | ||
@interface MDFTextAccessibility : NSObject | ||
|
||
/** | ||
An optionally transparent text color suitable for displaying on a background color with a | ||
particular font. | ||
The color returned will be white or black with an alpha value of targetTextAlpha, unless the | ||
contrast ratio is insufficient, in which case the alpha is increased (made more opaque). | ||
If the passed font is nil, then a conservative guess is used. | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@param targetTextAlpha The target alpha of the text. | ||
@param font The font the text will use or nil. | ||
@return A color with acceptable contrast ratio for displaying text on |color|. | ||
*/ | ||
+ (nonnull UIColor *)textColorOnBackgroundColor:(nonnull UIColor *)backgroundColor | ||
targetTextAlpha:(CGFloat)targetTextAlpha | ||
font:(nullable UIFont *)font; | ||
|
||
/** | ||
An optionally transparent text color suitable for displaying on a background image with a | ||
particular font. | ||
The color returned will be white or black with an alpha value of targetTextAlpha, unless the | ||
contrast ratio is insufficient, in which case the alpha is increased (made more opaque). | ||
If the passed font is nil, then a conservative guess is used. | ||
The content of the background image is simply averaged to make an average color, which is then used | ||
as if it were the background color of the text. Depending on the contents of the image, this | ||
approximation may or may not result in legible text. | ||
The supplied image region will be intersected with the image's bounds. If the resulting region is | ||
null or empty then this method returns nil. | ||
@param backgroundImage The opaque background image the text will be displayed on. | ||
@param region The region in which the text will be displayed. Can be conservatively large. | ||
@param targetTextAlpha The target alpha of the text. | ||
@param font The font to be used to display the text. Can be nil. | ||
@return A color with acceptable contrast ratio, or nil if the region is out of bounds of the image. | ||
*/ | ||
+ (nullable UIColor *)textColorOnBackgroundImage:(nonnull UIImage *)backgroundImage | ||
inRegion:(CGRect)region | ||
targetTextAlpha:(CGFloat)targetTextAlpha | ||
font:(nullable UIFont *)font; | ||
|
||
#pragma mark Advanced methods | ||
|
||
/** | ||
An optionally transparent text color suitable for displaying text on a given opaque background | ||
color. | ||
This method calls textColorFromChoices:onColor:options: with the choices [white, black], both | ||
with their alpha set to targetTextAlpha. | ||
If MDFTextAccessibilityOptionsPreserveAlpha is included in the options, then the algorithm will not | ||
modify the alpha values, which may result in no color being returned at all. | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@param targetTextAlpha The target alpha of the text. | ||
@param options A combination of MDFTextAccessibilityOptions values. | ||
@return A color with acceptable contrast ratio or nil if no such color exists. | ||
*/ | ||
+ (nullable UIColor *)textColorOnBackgroundColor:(nonnull UIColor *)backgroundColor | ||
targetTextAlpha:(CGFloat)targetTextAlpha | ||
options:(MDFTextAccessibilityOptions)options; | ||
|
||
/** | ||
A color selected from a set which is suitable for displaying text on a given opaque background | ||
color. | ||
Since the minimum ratio for "large" text is less stringent, set | ||
the MDFTextAccessibilityOptionsLargeFont bit if the font size will be greater than or | ||
equal to 18pt normal or 14pt bold. If in doubt or if the text size can vary, be conservative and do | ||
not specify MDFTextAccessibilityOptionsLargeFont in the options. | ||
By default, the first acceptable color in |choices| will be returned. If | ||
MDFTextAccessibilityOptionsPreferLighter is set, then the lightest acceptable color will be | ||
returned, and if MDFTextAccessibilityOptionsPreferDarker is set, then the darkest acceptable color | ||
will be returned. This allows for a standard set of text colors to be used in different situations. | ||
By default, the algorithm will attempt to modify the alpha value of colors in |choices| instead | ||
of switching to an alternate color, under the assumption that text with slightly different | ||
alpha values is less noticible than, for example, black text where white text is usually used. | ||
If MDFTextAccessibilityOptionsPreserveAlpha is included in the options, then the algorithm will not | ||
modify the alpha values, which may result in no color being returned at all. | ||
@param choices An array of text color UIColor objects with optional alpha values. | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@param options A combination of MDFTextAccessibilityOptions values. | ||
@return A color with acceptable contrast ratio or nil if no such color exists. | ||
*/ | ||
+ (nullable UIColor *)textColorFromChoices:(nonnull NSArray<UIColor *> *)choices | ||
onBackgroundColor:(nonnull UIColor *)backgroundColor | ||
options:(MDFTextAccessibilityOptions)options; | ||
|
||
/** | ||
The minimum alpha that text can have and still have an acceptable contrast ratio. Depending on | ||
color combinations, the minimum useable alpha can vary. | ||
Since the minimum ratio for "large" text is less stringent, set | ||
the MDFTextAccessibilityOptionsLargeFont bit if the font size will be greater than or | ||
equal to 18pt normal or 14pt bold. If in doubt or if the text size can vary, be conservative and do | ||
not specify MDFTextAccessibilityOptionsLargeFont in the options. | ||
@note There are some color combinations (white on white) for which an acceptable alpha value | ||
doesn't exist. | ||
@param textColor The text color (alpha is ignored). | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@param options A combination of MDFTextAccessibilityOptions values. | ||
@return The minimum alpha value to use in this situation, or -1 if there is no such alpha. | ||
*/ | ||
+ (CGFloat)minAlphaOfTextColor:(nonnull UIColor *)textColor | ||
onBackgroundColor:(nonnull UIColor *)backgroundColor | ||
options:(MDFTextAccessibilityOptions)options; | ||
|
||
/** | ||
The contrast ratio of a text color when displayed on an opaque background color. | ||
@param textColor A text color with optional transparency. | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@return The contrast ratio of the text color on the background color. | ||
*/ | ||
+ (CGFloat)contrastRatioForTextColor:(nonnull UIColor *)textColor | ||
onBackgroundColor:(nonnull UIColor *)backgroundColor; | ||
|
||
/** | ||
Whether a text color passes accessibility standards when displayed on an opaque background color. | ||
MDFTextAccessibilityOptionsLargeFont and MDFTextAccessibilityOptionsEnhancedContrast are relevant | ||
options for this method. | ||
@param textColor A text color with optional transparency. | ||
@param backgroundColor The opaque background color the text will be displayed on. | ||
@param options A combination of MDFTextAccessibilityOptions values. | ||
@return YES if the text color would meet accessibility standards. | ||
*/ | ||
+ (BOOL)textColor:(nonnull UIColor *)textColor | ||
passesOnBackgroundColor:(nonnull UIColor *)backgroundColor | ||
options:(MDFTextAccessibilityOptions)options; | ||
|
||
/** | ||
Whether a particular font would be considered "large" for the purposes of calculating | ||
contrast ratios. | ||
Large fonts are defined as greater than 18pt normal or 14pt bold. If the passed font is nil, then | ||
this method returns NO. | ||
For more see: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html | ||
@param font The font to examine, or nil. | ||
@return YES if the font is non-nil and is considered "large". | ||
*/ | ||
+ (BOOL)isLargeForContrastRatios:(nullable UIFont *)font; | ||
|
||
@end |
Binary file not shown.
Binary file added
BIN
+491 KB
references/v34.0.1.Debug/MDFTextAccessibility.framework/MDFTextAccessibility
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
references/v34.0.1.Debug/MDFTextAccessibility.framework/Modules/module.modulemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
framework module MDFTextAccessibility { | ||
umbrella header "MDFTextAccessibility-umbrella.h" | ||
|
||
export * | ||
module * { export * } | ||
} |
70 changes: 70 additions & 0 deletions
70
...rences/v34.0.1.Debug/MDFTextAccessibility.framework/PrivateHeaders/MDFColorCalculations.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Copyright 2016-present Google Inc. 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 <UIKit/UIKit.h> | ||
|
||
#if defined(__cplusplus) | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
Copies the RGBA components of color, expanding greyscale colors out to RGBA if necessary. | ||
@param color The color to extract the components from. | ||
@param rgbaComponents A pointer to four CGFloat values. | ||
*/ | ||
void MDFCopyRGBAComponents(CGColorRef color, CGFloat *rgbaComponents); | ||
|
||
/** | ||
Returns the contrast ratio of a foreground color blended on top of a background color. | ||
@param foregroundColorComponents A pointer to four RGBA CGFloats of the foreground color. | ||
@param backgroundColorComponents A pointer to four RGBA CGFloats of the background color. | ||
@return The contrast ratio of the two colors after blending. | ||
*/ | ||
CGFloat MDFContrastRatioOfRGBAComponents(const CGFloat *foregroundColorComponents, | ||
const CGFloat *backgroundColorComponents); | ||
|
||
/** | ||
Calculates the relative luminance of a sRGB color from its components (ignores alpha). | ||
@see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef | ||
@param components A pointer to three RGB CGFloat values of the color. | ||
@return The relative luminance of the color. | ||
*/ | ||
CGFloat MDFRelativeLuminanceOfRGBComponents(const CGFloat *components); | ||
|
||
/** | ||
Calculates the minimum alpha that a foreground color can have such that, when it's blended on top | ||
of an opaque background color, the resulting contrast ratio is higher than a minimum contrast | ||
ratio. | ||
If there is no such acceptable contrast ratio, then -1 is returned. This is the case when even a | ||
completely opaque foreground color can't produce a high enough contrast ratio. For example, light | ||
grey on white will have a low contrast ratio for any alpha value assigned to the light grey. | ||
@param color The foreground color (alpha ignored). | ||
@param backgroundColor The background color (assumed to be opaque). | ||
@param minContrastRatio The minimum allowable contrast ratio. | ||
@return The minimum acceptable alpha of the foreground color, or -1 if no such alpha exists. | ||
*/ | ||
CGFloat MDFMinAlphaOfColorOnBackgroundColor(UIColor *color, | ||
UIColor *backgroundColor, | ||
CGFloat minContrastRatio); | ||
|
||
#if defined __cplusplus | ||
} // extern "C" | ||
#endif |
37 changes: 37 additions & 0 deletions
37
...rences/v34.0.1.Debug/MDFTextAccessibility.framework/PrivateHeaders/MDFImageCalculations.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2016-present Google Inc. 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 <UIKit/UIKit.h> | ||
|
||
#if defined(__cplusplus) | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
Return the average color of an image in a particular region. | ||
The region will be intersected with the image's bounds. If the resulting region is empty (or the | ||
input region was null) then this function returns nil. | ||
@param image The image to examine. | ||
@param region The region of the image to average, or CGRectInfinite for the entire image. | ||
@return The average color, or nil if the region was invalid. | ||
*/ | ||
UIColor *MDFAverageColorOfOpaqueImage(UIImage *image, CGRect region); | ||
|
||
#if defined __cplusplus | ||
} // extern "C" | ||
#endif |
Oops, something went wrong.