mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
[ASTextNode] Implement an example comparing ASTextNode 1 & 2 behavior. (#570)
* fix SIMULATE_WEB_RESPONSE not imported #449 * add constraint to using catching for layout * Add TextNode example to test Yoga Layout * update Yoga version * add debugging log * fix lisence * clean up * clean up * fix lisence warning * add shared scheme * change sdk version * revert some metadata * Merge FlexLayoutExample to TextStressText. Add flags to control different TextNode used. * clean up * fix lisence and syntax * clean up * remove xcworkspacedata * Tiny coding style changes * Another tiny change related to code style
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
source 'https://github.com/CocoaPods/Specs.git'
|
source 'https://github.com/CocoaPods/Specs.git'
|
||||||
platform :ios, '8.0'
|
platform :ios, '8.0'
|
||||||
target 'Sample' do
|
target 'Sample' do
|
||||||
pod 'Texture', :path => '../..'
|
pod 'Texture/Yoga', :path => '../..'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; };
|
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; };
|
||||||
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; };
|
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; };
|
||||||
92F1263CECFE3FFCC7A5F936 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8EC8300ABAAEA079224272A /* libPods-Sample.a */; };
|
92F1263CECFE3FFCC7A5F936 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8EC8300ABAAEA079224272A /* libPods-Sample.a */; };
|
||||||
|
C081EE8D1F85AEEC00F0B5F1 /* TabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = C081EE8C1F85AEEC00F0B5F1 /* TabBarController.m */; };
|
||||||
|
C081EE921F85AFB800F0B5F1 /* CollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C081EE8F1F85AFB800F0B5F1 /* CollectionViewController.m */; };
|
||||||
|
C081EE931F85AFB800F0B5F1 /* TextCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = C081EE911F85AFB800F0B5F1 /* TextCellNode.m */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -29,6 +32,12 @@
|
|||||||
6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; };
|
6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||||
6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; };
|
6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; };
|
||||||
A950870A2154F92D5DC91F1A /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
A950870A2154F92D5DC91F1A /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
C081EE8B1F85AEEC00F0B5F1 /* TabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabBarController.h; sourceTree = "<group>"; };
|
||||||
|
C081EE8C1F85AEEC00F0B5F1 /* TabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabBarController.m; sourceTree = "<group>"; };
|
||||||
|
C081EE8E1F85AFB800F0B5F1 /* CollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionViewController.h; sourceTree = "<group>"; };
|
||||||
|
C081EE8F1F85AFB800F0B5F1 /* CollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionViewController.m; sourceTree = "<group>"; };
|
||||||
|
C081EE901F85AFB800F0B5F1 /* TextCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCellNode.h; sourceTree = "<group>"; };
|
||||||
|
C081EE911F85AFB800F0B5F1 /* TextCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextCellNode.m; sourceTree = "<group>"; };
|
||||||
E8EC8300ABAAEA079224272A /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
E8EC8300ABAAEA079224272A /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@@ -68,11 +77,17 @@
|
|||||||
05E2128319D4DB510098F589 /* Sample */ = {
|
05E2128319D4DB510098F589 /* Sample */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
C081EE8E1F85AFB800F0B5F1 /* CollectionViewController.h */,
|
||||||
|
C081EE8F1F85AFB800F0B5F1 /* CollectionViewController.m */,
|
||||||
|
C081EE901F85AFB800F0B5F1 /* TextCellNode.h */,
|
||||||
|
C081EE911F85AFB800F0B5F1 /* TextCellNode.m */,
|
||||||
05E2128819D4DB510098F589 /* AppDelegate.h */,
|
05E2128819D4DB510098F589 /* AppDelegate.h */,
|
||||||
05E2128919D4DB510098F589 /* AppDelegate.m */,
|
05E2128919D4DB510098F589 /* AppDelegate.m */,
|
||||||
05E2128B19D4DB510098F589 /* ViewController.h */,
|
05E2128B19D4DB510098F589 /* ViewController.h */,
|
||||||
05E2128C19D4DB510098F589 /* ViewController.m */,
|
05E2128C19D4DB510098F589 /* ViewController.m */,
|
||||||
05E2128419D4DB510098F589 /* Supporting Files */,
|
05E2128419D4DB510098F589 /* Supporting Files */,
|
||||||
|
C081EE8B1F85AEEC00F0B5F1 /* TabBarController.h */,
|
||||||
|
C081EE8C1F85AEEC00F0B5F1 /* TabBarController.m */,
|
||||||
);
|
);
|
||||||
path = Sample;
|
path = Sample;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -181,13 +196,16 @@
|
|||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
|
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||||
|
"${PODS_ROOT}/Manifest.lock",
|
||||||
);
|
);
|
||||||
name = "[CP] Check Pods Manifest.lock";
|
name = "[CP] Check Pods Manifest.lock";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
|
"$(DERIVED_FILE_DIR)/Pods-Sample-checkManifestLockResult.txt",
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
96436DA0C1AFF84D8041B522 /* [CP] Embed Pods Frameworks */ = {
|
96436DA0C1AFF84D8041B522 /* [CP] Embed Pods Frameworks */ = {
|
||||||
@@ -227,8 +245,11 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
C081EE931F85AFB800F0B5F1 /* TextCellNode.m in Sources */,
|
||||||
05E2128D19D4DB510098F589 /* ViewController.m in Sources */,
|
05E2128D19D4DB510098F589 /* ViewController.m in Sources */,
|
||||||
|
C081EE8D1F85AEEC00F0B5F1 /* TabBarController.m in Sources */,
|
||||||
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */,
|
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */,
|
||||||
|
C081EE921F85AFB800F0B5F1 /* CollectionViewController.m in Sources */,
|
||||||
05E2128719D4DB510098F589 /* main.m in Sources */,
|
05E2128719D4DB510098F589 /* main.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@@ -1,25 +1,39 @@
|
|||||||
/* This file provided by Facebook is for non-commercial testing and evaluation
|
//
|
||||||
* purposes only. Facebook reserves all rights not expressly granted.
|
// AppDelegate.m
|
||||||
*
|
// Texture
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
//
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// Copyright (c) 2017-present, Pinterest, Inc. All rights reserved.
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
// you may not use this file except in compliance with the License.
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
// You may obtain a copy of the License at
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
//
|
||||||
*/
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
|
|
||||||
|
#import "TabBarController.h"
|
||||||
|
#import "CollectionViewController.h"
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||||
{
|
{
|
||||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
self.window.backgroundColor = [UIColor whiteColor];
|
self.window.backgroundColor = [UIColor whiteColor];
|
||||||
self.window.rootViewController = [[ViewController alloc] init];
|
|
||||||
|
ViewController *viewController = [[ViewController alloc] init];
|
||||||
|
viewController.tabBarItem.title = @"TextStress";
|
||||||
|
|
||||||
|
CollectionViewController *cvc = [[CollectionViewController alloc] init];
|
||||||
|
cvc.tabBarItem.title = @"Flexbox";
|
||||||
|
|
||||||
|
TabBarController *tabBarController = [[TabBarController alloc] init];
|
||||||
|
tabBarController.viewControllers = @[cvc, viewController];
|
||||||
|
|
||||||
|
self.window.rootViewController = tabBarController;
|
||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// CollectionViewController.h
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
|
||||||
|
@interface CollectionViewController : ASViewController
|
||||||
|
@end
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
//
|
||||||
|
// CollectionViewController.m
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "CollectionViewController.h"
|
||||||
|
#import "TextCellNode.h"
|
||||||
|
|
||||||
|
@interface CollectionViewController() <ASCollectionDataSource, ASCollectionDelegate>
|
||||||
|
{
|
||||||
|
ASCollectionNode *_collectionNode;
|
||||||
|
NSArray<NSString *> *_labels;
|
||||||
|
TextCellNode *_cellNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CollectionViewController
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||||||
|
_collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:flowLayout];
|
||||||
|
CGRect rect = [[UIApplication sharedApplication] statusBarFrame];
|
||||||
|
_collectionNode.contentInset = UIEdgeInsetsMake(rect.size.height, 0, 0, 0);
|
||||||
|
self = [super initWithNode:_collectionNode];
|
||||||
|
if (self) {
|
||||||
|
_collectionNode.delegate = self;
|
||||||
|
_collectionNode.dataSource = self;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLoad
|
||||||
|
{
|
||||||
|
[super viewDidLoad];
|
||||||
|
_collectionNode.backgroundColor = [UIColor whiteColor];
|
||||||
|
_labels = @[@"Fight of the Living Dead: Experiment Fight of the Living Dead: Experiment", @"S1 • E1"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
return ^{
|
||||||
|
_cellNode = [[TextCellNode alloc] initWithText1:_labels[0] text2:_labels[1]];
|
||||||
|
return _cellNode;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
- (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
CGFloat width = collectionNode.view.bounds.size.width;
|
||||||
|
return ASSizeRangeMake(CGSizeMake(width, 0.0f), CGSizeMake(width, CGFLOAT_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
16
examples_extra/TextStressTest/Sample/TabBarController.h
Normal file
16
examples_extra/TextStressTest/Sample/TabBarController.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// TabBarController.h
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
|
||||||
|
@interface TabBarController : ASTabBarController
|
||||||
|
@end
|
||||||
19
examples_extra/TextStressTest/Sample/TabBarController.m
Normal file
19
examples_extra/TextStressTest/Sample/TabBarController.m
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// TabBarController.m
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TabBarController.h"
|
||||||
|
|
||||||
|
@interface TabBarController ()
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TabBarController
|
||||||
|
@end
|
||||||
17
examples_extra/TextStressTest/Sample/TextCellNode.h
Normal file
17
examples_extra/TextStressTest/Sample/TextCellNode.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// TextCellNode.h
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
|
||||||
|
@interface TextCellNode : ASCellNode
|
||||||
|
- (instancetype)initWithText1:(NSString *)text1 text2:(NSString *)text2;
|
||||||
|
@end
|
||||||
100
examples_extra/TextStressTest/Sample/TextCellNode.m
Normal file
100
examples_extra/TextStressTest/Sample/TextCellNode.m
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
//
|
||||||
|
// TextCellNode.m
|
||||||
|
// Texture
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017-present, Pinterest, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TextCellNode.h"
|
||||||
|
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||||
|
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
|
||||||
|
|
||||||
|
#ifndef USE_ASTEXTNODE_2
|
||||||
|
#define USE_ASTEXTNODE_2 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface TextCellNode()
|
||||||
|
{
|
||||||
|
#if USE_ASTEXTNODE_2
|
||||||
|
ASTextNode2 *_label1;
|
||||||
|
ASTextNode2 *_label2;
|
||||||
|
#else
|
||||||
|
ASTextNode *_label1;
|
||||||
|
ASTextNode *_label2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TextCellNode
|
||||||
|
|
||||||
|
- (instancetype)initWithText1:(NSString *)text1 text2:(NSString *)text2
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
self.automaticallyManagesSubnodes = YES;
|
||||||
|
self.clipsToBounds = YES;
|
||||||
|
#if USE_ASTEXTNODE_2
|
||||||
|
_label1 = [[ASTextNode2 alloc] init];
|
||||||
|
_label2 = [[ASTextNode2 alloc] init];
|
||||||
|
#else
|
||||||
|
_label1 = [[ASTextNode alloc] init];
|
||||||
|
_label2 = [[ASTextNode alloc] init];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_label1.attributedText = [[NSAttributedString alloc] initWithString:text1];
|
||||||
|
_label2.attributedText = [[NSAttributedString alloc] initWithString:text2];
|
||||||
|
|
||||||
|
_label1.maximumNumberOfLines = 1;
|
||||||
|
_label1.truncationMode = NSLineBreakByTruncatingTail;
|
||||||
|
_label2.maximumNumberOfLines = 1;
|
||||||
|
_label2.truncationMode = NSLineBreakByTruncatingTail;
|
||||||
|
|
||||||
|
[self simpleSetupYogaLayout];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is to text a row with two labels, the first should be truncated with "...".
|
||||||
|
Layout is like: [l1Container[_label1], label2].
|
||||||
|
This shows a bug of ASTextNode2.
|
||||||
|
*/
|
||||||
|
- (void)simpleSetupYogaLayout
|
||||||
|
{
|
||||||
|
[self.style yogaNodeCreateIfNeeded];
|
||||||
|
[_label1.style yogaNodeCreateIfNeeded];
|
||||||
|
[_label2.style yogaNodeCreateIfNeeded];
|
||||||
|
|
||||||
|
_label1.style.flexGrow = 0;
|
||||||
|
_label1.style.flexShrink = 1;
|
||||||
|
_label1.backgroundColor = [UIColor lightGrayColor];
|
||||||
|
|
||||||
|
_label2.style.flexGrow = 0;
|
||||||
|
_label2.style.flexShrink = 0;
|
||||||
|
_label2.backgroundColor = [UIColor greenColor];
|
||||||
|
|
||||||
|
ASDisplayNode *l1Container = [ASDisplayNode yogaVerticalStack];
|
||||||
|
|
||||||
|
// TODO(fix ASTextNode2): next two line will show the bug of TextNode2
|
||||||
|
// which works for ASTextNode though
|
||||||
|
// see discussion here: https://github.com/TextureGroup/Texture/pull/553
|
||||||
|
l1Container.style.alignItems = ASStackLayoutAlignItemsCenter;
|
||||||
|
_label1.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
|
|
||||||
|
l1Container.style.flexGrow = 0;
|
||||||
|
l1Container.style.flexShrink = 1;
|
||||||
|
|
||||||
|
l1Container.yogaChildren = @[_label1];
|
||||||
|
|
||||||
|
self.style.justifyContent = ASStackLayoutJustifyContentSpaceBetween;
|
||||||
|
self.style.alignItems = ASStackLayoutAlignItemsStart;
|
||||||
|
self.style.flexDirection = ASStackLayoutDirectionHorizontal;
|
||||||
|
self.yogaChildren = @[l1Container, _label2];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
Reference in New Issue
Block a user