forked from facebook/componentkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dd00d27
Showing
757 changed files
with
28,675 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Pods | ||
Example/WildeGuess/Pod | ||
*xcuserdata |
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 @@ | ||
language: objective-c | ||
|
||
before_install: | ||
- gem install cocoapods | ||
|
||
script: ./build.sh |
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,33 @@ | ||
# Contributing to ComponentKit | ||
We want to make contributing to this project as easy and transparent as | ||
possible, and actively welcome your pull requests. If you run into problems, | ||
please open an issue on GitHub. | ||
|
||
## Pull Requests | ||
1. Fork the repo and create your branch from `master`. | ||
2. If you've added code that should be tested, add tests. | ||
3. If you've changed APIs, update the documentation. | ||
4. Ensure the test suite passes. | ||
5. Make sure your code lints. | ||
6. If you haven't already, complete the Contributor License Agreement ("CLA"). | ||
|
||
## Contributor License Agreement ("CLA") | ||
In order to accept your pull request, we need you to submit a CLA. You only need | ||
to do this once to work on any of Facebook's open source projects. | ||
|
||
Complete your CLA here: <https://code.facebook.com/cla> | ||
|
||
## Issues | ||
We use GitHub issues to track public bugs. Please ensure your description is | ||
clear and has sufficient instructions to be able to reproduce the issue. | ||
|
||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe | ||
disclosure of security bugs. In those cases, please go through the process | ||
outlined on that page and do not file a public issue. | ||
|
||
## Coding Style | ||
* 2 spaces for indentation rather than tabs | ||
|
||
## License | ||
By contributing to ComponentKit, you agree that your contributions will be | ||
licensed under its BSD license. |
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,21 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "ComponentKit" | ||
s.version = "0.9" | ||
s.summary = "A React-inspired view framework for iOS" | ||
s.homepage = "https://componentkit.com" | ||
s.license = 'BSD' | ||
s.source = { | ||
:git => "https://github.com/facebook/ComponentKit.git", | ||
:tag => s.version.to_s | ||
} | ||
s.social_media_url = 'https://twitter.com/componentkit' | ||
s.platform = :ios, '7.0' | ||
s.requires_arc = true | ||
s.source_files = 'ComponentKit/**/*', 'ComponentTextKit/**/*' | ||
s.frameworks = 'UIKit', 'CoreText' | ||
s.library = 'c++' | ||
s.xcconfig = { | ||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11', | ||
'CLANG_CXX_LIBRARY' => 'libc++' | ||
} | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
ComponentKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
158 changes: 158 additions & 0 deletions
158
ComponentKit.xcodeproj/xcshareddata/xcschemes/ComponentKit.xcscheme
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,158 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "0610" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B3EECEC11AC2366600BFC5DA" | ||
BuildableName = "ComponentKit.app" | ||
BlueprintName = "ComponentKit" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DC3F1AC23E8200ACAC53" | ||
BuildableName = "ComponentKitTests.xctest" | ||
BlueprintName = "ComponentKitTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DCA91AC23F2A00ACAC53" | ||
BuildableName = "ComponentTextKitApplicationTests.xctest" | ||
BlueprintName = "ComponentTextKitApplicationTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DC8A1AC23EC300ACAC53" | ||
BuildableName = "ComponentKitApplicationTests.xctest" | ||
BlueprintName = "ComponentKitApplicationTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
buildConfiguration = "Debug"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DC3F1AC23E8200ACAC53" | ||
BuildableName = "ComponentKitTests.xctest" | ||
BlueprintName = "ComponentKitTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DCA91AC23F2A00ACAC53" | ||
BuildableName = "ComponentTextKitApplicationTests.xctest" | ||
BlueprintName = "ComponentTextKitApplicationTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B342DC8A1AC23EC300ACAC53" | ||
BuildableName = "ComponentKitApplicationTests.xctest" | ||
BlueprintName = "ComponentKitApplicationTests" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B3EECEC11AC2366600BFC5DA" | ||
BuildableName = "ComponentKit.app" | ||
BlueprintName = "ComponentKit" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</TestAction> | ||
<LaunchAction | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
buildConfiguration = "Debug" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B3EECEC11AC2366600BFC5DA" | ||
BuildableName = "ComponentKit.app" | ||
BlueprintName = "ComponentKit" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
buildConfiguration = "Release" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "B3EECEC11AC2366600BFC5DA" | ||
BuildableName = "ComponentKit.app" | ||
BlueprintName = "ComponentKit" | ||
ReferencedContainer = "container:ComponentKit.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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,74 @@ | ||
/* | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <ComponentKit/ComponentUtilities.h> | ||
#import <ComponentKit/CKComponentAction.h> | ||
|
||
class CKComponentViewConfiguration; | ||
|
||
typedef NSString *(^CKAccessibilityLazyTextBlock)(); | ||
|
||
/** | ||
A text attribute used for accessibility, this attribute can be initialized in two ways : | ||
- If some computation needs to be done like aggregation or other string manipulations you can provide a block that | ||
will be lazily executed when the component is mounted only when voiceover is enabled, this way we don't do | ||
unnecessary computations when VoiceOver is not enabled. | ||
- Use an NSString directly; reserve this for when no computation is needed to get the string | ||
*/ | ||
struct CKComponentAccessibilityTextAttribute { | ||
CKComponentAccessibilityTextAttribute() {}; | ||
CKComponentAccessibilityTextAttribute(CKAccessibilityLazyTextBlock textBlock) : accessibilityLazyTextBlock(textBlock) {}; | ||
CKComponentAccessibilityTextAttribute(NSString *text) : accessibilityLazyTextBlock(^{ return text; }) {}; | ||
|
||
BOOL hasText() const { | ||
return accessibilityLazyTextBlock != nil; | ||
} | ||
|
||
NSString *value() const { | ||
return accessibilityLazyTextBlock ? accessibilityLazyTextBlock() : nil; | ||
}; | ||
|
||
private: | ||
CKAccessibilityLazyTextBlock accessibilityLazyTextBlock; | ||
}; | ||
|
||
/** | ||
Separate structure to handle accessibility as we want the components infrastructure to decide wether to use it or not depending if accessibility is enabled or not. | ||
*/ | ||
struct CKComponentAccessibilityContext { | ||
NSNumber *isAccessibilityElement; | ||
NSString *accessibilityIdentifier; | ||
CKComponentAccessibilityTextAttribute accessibilityLabel; | ||
CKComponentAction accessibilityComponentAction; | ||
|
||
bool operator==(const CKComponentAccessibilityContext &other) const | ||
{ | ||
return CKObjectIsEqual(other.accessibilityIdentifier, accessibilityIdentifier) | ||
&& CKObjectIsEqual(other.isAccessibilityElement, isAccessibilityElement) | ||
&& CKObjectIsEqual(other.accessibilityLabel.value(), accessibilityLabel.value()) | ||
&& other.accessibilityComponentAction == accessibilityComponentAction; | ||
} | ||
}; | ||
|
||
namespace CK { | ||
namespace Component { | ||
namespace Accessibility { | ||
/** | ||
@return A modified configuration for which extra view component attributes have been added to handle accessibility. | ||
e.g: The following view configuration `{[UIView class], {{@selector(setBlah:), @"Blah"}}, {.accessibilityIdentifier = @"accessibilityId"}}` | ||
will become `{[UIView class], {{@selector(setBlah:), @"Blah"}, {@selector(setAccessibilityIdentifier), @"accessibilityId"}}, {.accessibilityIdentifier = @"accessibilityId"}}` | ||
*/ | ||
CKComponentViewConfiguration AccessibleViewConfiguration(const CKComponentViewConfiguration &viewConfiguration); | ||
BOOL IsAccessibilityEnabled(); | ||
} | ||
} | ||
} |
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,68 @@ | ||
/* | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#import "CKComponentAccessibility.h" | ||
#import "CKComponentAccessibility_Private.h" | ||
|
||
#import <ComponentKit/CKAssert.h> | ||
|
||
#import "ComponentViewManager.h" | ||
#import "CKComponentViewConfiguration.h" | ||
|
||
/** Helper that converts the accessibility context characteristics to a map of component view attributes */ | ||
static CKViewComponentAttributeValueMap ViewAttributesFromAccessibilityContext(const CKComponentAccessibilityContext &accessibilityContext) | ||
{ | ||
CKViewComponentAttributeValueMap accessibilityAttributes; | ||
if (accessibilityContext.accessibilityIdentifier) { | ||
accessibilityAttributes[@selector(setAccessibilityIdentifier:)] = accessibilityContext.accessibilityIdentifier; | ||
} | ||
if (accessibilityContext.isAccessibilityElement) { | ||
accessibilityAttributes[@selector(setIsAccessibilityElement:)] = accessibilityContext.isAccessibilityElement; | ||
} | ||
if (accessibilityContext.accessibilityLabel.hasText()) { | ||
accessibilityAttributes[@selector(setAccessibilityLabel:)] = accessibilityContext.accessibilityLabel.value(); | ||
} | ||
return accessibilityAttributes; | ||
} | ||
|
||
CKComponentViewConfiguration CK::Component::Accessibility::AccessibleViewConfiguration(const CKComponentViewConfiguration &viewConfiguration) | ||
{ | ||
CKCAssertMainThread(); | ||
// Copy is intentional so we can move later. | ||
CKComponentAccessibilityContext accessibilityContext = viewConfiguration.accessibilityContext(); | ||
const CKViewComponentAttributeValueMap &accessibilityAttributes = ViewAttributesFromAccessibilityContext(accessibilityContext); | ||
if (accessibilityAttributes.size() > 0) { | ||
CKViewComponentAttributeValueMap newAttributes(*viewConfiguration.attributes()); | ||
newAttributes.insert(accessibilityAttributes.begin(), accessibilityAttributes.end()); | ||
// Copy is intentional so we can move later. | ||
CKComponentViewClass viewClass = viewConfiguration.viewClass(); | ||
// If the specified view class doesn't have a view, force the creation of one | ||
// so the accessibility attributes can be realized. | ||
return CKComponentViewConfiguration(viewClass.hasView() ? std::move(viewClass) : CKComponentViewClass([UIView class]), | ||
std::move(newAttributes), std::move(accessibilityContext)); | ||
} else { | ||
return viewConfiguration; | ||
} | ||
} | ||
|
||
static BOOL _forceAccessibilityEnabled = NO; | ||
static BOOL _forceAccessibilityDisabled = NO; | ||
|
||
void CK::Component::Accessibility::SetForceAccessibilityEnabled(BOOL enabled) | ||
{ | ||
_forceAccessibilityEnabled = enabled; | ||
_forceAccessibilityDisabled = !enabled; | ||
} | ||
|
||
BOOL CK::Component::Accessibility::IsAccessibilityEnabled() | ||
{ | ||
CKCAssertMainThread(); | ||
return !_forceAccessibilityDisabled && (_forceAccessibilityEnabled || UIAccessibilityIsVoiceOverRunning()); | ||
} |
Oops, something went wrong.