Skip to content

Commit

Permalink
Merge branch 'main' into fix/Sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Jun 26, 2024
2 parents abeca3d + ebbfaaf commit f8395a9
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 13 deletions.
31 changes: 31 additions & 0 deletions PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const styles = StyleSheet.create({
fontSize: 16,
color: '#242424',
height: 30,
// you can use lineHeight/lineSpacing/lineHeightMultiple
// to control the space between lines in multi-line input.(iOS only for now)
// for example:
lineHeight: 30,
// lineSpacing: 50,
// lineHeightMultiple: 1.5,
},
input_style_block: {
height: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export default {
underline-color-android: #40b883;
placeholder-text-color: #666;
align-self: center;
/* you can use line-height/line-spacing/line-height-multiple */
/* to control the space between lines in multi-line input. (iOS only for now) */
line-height: 30;
/*line-spacing: 20;*/
/*line-height-multiple: 1.5;*/
}
#demo-textarea .output {
Expand Down
12 changes: 12 additions & 0 deletions framework/examples/ios-demo/HippyDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
4CBD515D378CB81C4C164353 /* DebugCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 01F6A42F861E597779C10D09 /* DebugCell.xib */; };
5A5A9B087B27BD97E132C49E /* DemoBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4708C41E8571123282E2B806 /* DemoBaseViewController.m */; };
5A60628334CE16EA4F8B1329 /* DemoNavigationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16348E2DEBFF10ADD6FCF7A9 /* DemoNavigationViewController.m */; };
719D92A12C2AF85E00E26339 /* HippyDemo.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 719D92A02C2AF85E00E26339 /* HippyDemo.xctestplan */; };
719D92A32C2AFB0F00E26339 /* hippy-Unit-UnitTests.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 719D92A22C2AFB0F00E26339 /* hippy-Unit-UnitTests.xctestplan */; };
719D92A52C2AFC6300E26339 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 719D92A42C2AFC6300E26339 /* PrivacyInfo.xcprivacy */; };
72328C3389BA8DD5E54D7D5F /* TurboConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 46034630F6D4A25199673157 /* TurboConfig.m */; };
74C51526435B1AB788CBF991 /* TurboBaseModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = CC8AEAE8BF116954FB41BDF9 /* TurboBaseModule.mm */; };
7C8A07982ADCEE2D7C9EAED8 /* Pods_HippyDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 344AB561913707F8A4793EC8 /* Pods_HippyDemo.framework */; };
Expand Down Expand Up @@ -76,6 +79,9 @@
6045C301C6CFDC6C2E87AA66 /* IconUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IconUtils.h; sourceTree = "<group>"; };
6094F1F80FD70F9F9853EE15 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
6C482239432657812B25A59A /* SettingsInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsInfo.h; sourceTree = "<group>"; };
719D92A02C2AF85E00E26339 /* HippyDemo.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HippyDemo.xctestplan; sourceTree = "<group>"; };
719D92A22C2AFB0F00E26339 /* hippy-Unit-UnitTests.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "hippy-Unit-UnitTests.xctestplan"; sourceTree = "<group>"; };
719D92A42C2AFC6300E26339 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = ../../../PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
73A859BDC9C3189E38FD082F /* MyViewManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyViewManager.h; sourceTree = "<group>"; };
7CC425F89818837D6DA1053A /* PageManagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PageManagerViewController.m; sourceTree = "<group>"; };
7DB34DDF95B8E9C9AD87FFE4 /* Pods-HippyDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HippyDemo.release.xcconfig"; path = "Target Support Files/Pods-HippyDemo/Pods-HippyDemo.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -172,6 +178,9 @@
isa = PBXGroup;
children = (
5EF877A8CB4B2AD68A780A12 /* Assets.xcassets */,
719D92A02C2AF85E00E26339 /* HippyDemo.xctestplan */,
719D92A22C2AFB0F00E26339 /* hippy-Unit-UnitTests.xctestplan */,
719D92A42C2AFC6300E26339 /* PrivacyInfo.xcprivacy */,
1E1EECB72C2ACDCB192E6628 /* res */,
F3C07E1B41FBB8BA0834C6BC /* fonts */,
0632A691275B124491E38EA7 /* HippyDemo */,
Expand Down Expand Up @@ -327,7 +336,10 @@
9CF888F990C83ECD4F6C78AA /* Assets.xcassets in Resources */,
4CBD515D378CB81C4C164353 /* DebugCell.xib in Resources */,
36842E3B36BB6E52267BED0F /* HomePageView.xib in Resources */,
719D92A12C2AF85E00E26339 /* HippyDemo.xctestplan in Resources */,
C1A78F8868963E6C790472AA /* PageCreationCell.xib in Resources */,
719D92A32C2AFB0F00E26339 /* hippy-Unit-UnitTests.xctestplan in Resources */,
719D92A52C2AFC6300E26339 /* PrivacyInfo.xcprivacy in Resources */,
EBC6C5A3C36A88BF4DAD00BE /* res in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:HippyDemo.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@
@property (nonatomic, copy) NSString *placeholder;

@property (nonatomic, strong) UIFont *font;

/// ParagraphStyles - lineHeight
@property (nonatomic, strong) NSNumber *lineHeight;
/// ParagraphStyles - lineSpacing
@property (nonatomic, strong) NSNumber *lineSpacing;
/// ParagraphStyles - lineHeightMultiple
@property (nonatomic, strong) NSNumber *lineHeightMultiple;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
#import "HippyUtils.h"
#import "HippyShadowTextView.h"
#import "HippyShadowView+Internal.h"

#include "dom/dom_manager.h"
#include "dom/dom_node.h"
#include "dom/layout_node.h"

/// Default font size of TextView
/// Note that in `HippyFont` it is defined as 14,
/// For the sake of compatibility, keep it the way it is.
static const CGFloat defaultFontSize = 16.0;

@interface HippyShadowTextView ()

/// Cached text attributes
@property (nonatomic, strong) NSDictionary *dicAttributes;

@end
Expand All @@ -40,15 +45,35 @@ @interface HippyShadowTextView ()
hippy::LayoutMeasureMode heightMeasureMode, void *layoutContext) {
hippy::LayoutSize result;
if (weakShadowText) {
HippyShadowTextView *strongShadowText = weakShadowText;
NSString *text = strongShadowText.text ?: strongShadowText.placeholder;
if (nil == strongShadowText.dicAttributes) {
if (strongShadowText.font == nil) {
strongShadowText.font = [UIFont systemFontOfSize:16];
HippyShadowTextView *shadowText = weakShadowText;
NSString *text = shadowText.text ?: shadowText.placeholder;
if (nil == shadowText.dicAttributes) {
if (shadowText.font == nil) {

shadowText.font = [UIFont systemFontOfSize:defaultFontSize];
}
NSDictionary *attrs = nil;
if ((id)shadowText.lineHeight != nil ||
(id)shadowText.lineSpacing != nil ||
(id)shadowText.lineHeightMultiple != nil) {
// Add paragraphStyle
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
if ((id)shadowText.lineHeight != nil) {
paragraphStyle.minimumLineHeight = [shadowText.lineHeight doubleValue];
paragraphStyle.maximumLineHeight = [shadowText.lineHeight doubleValue];
} else if ((id)shadowText.lineSpacing != nil) {
paragraphStyle.lineSpacing = [shadowText.lineSpacing doubleValue];
} else if ((id)shadowText.lineHeightMultiple != nil) {
paragraphStyle.lineHeightMultiple = [shadowText.lineHeightMultiple doubleValue];
}
attrs = @{ NSFontAttributeName: shadowText.font,
NSParagraphStyleAttributeName : paragraphStyle };
} else {
attrs = @{ NSFontAttributeName: shadowText.font };
}
strongShadowText.dicAttributes = @ { NSFontAttributeName: strongShadowText.font };
shadowText.dicAttributes = attrs;
}
CGSize computedSize = [text sizeWithAttributes:strongShadowText.dicAttributes];
CGSize computedSize = [text sizeWithAttributes:shadowText.dicAttributes];
result.width = ceil(computedSize.width);
result.height = ceil(computedSize.height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@
@property (nonatomic, copy) NSString *text;
@property (nonatomic, strong) UIColor *textColor;

/// ParagraphStyles - lineHeight
@property (nonatomic, strong) NSNumber *lineHeight;
/// ParagraphStyles - lineSpacing
@property (nonatomic, strong) NSNumber *lineSpacing;
/// ParagraphStyles - lineHeightMultiple
@property (nonatomic, strong) NSNumber *lineHeightMultiple;

@end
19 changes: 19 additions & 0 deletions renderer/native/ios/renderer/component/textinput/HippyTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ @implementation HippyTextField {
HippyUITextField *_textView;
}

@dynamic lineHeight;
@dynamic lineSpacing;
@dynamic lineHeightMultiple;

- (void)keyboardWillShow:(NSNotification *)aNotification {
[super keyboardWillShow:aNotification];
NSDictionary *userInfo = [aNotification userInfo];
Expand Down Expand Up @@ -434,4 +438,19 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
return YES;
}


#pragma mark - LineHeight Related

- (void)setLineHeight:(NSNumber *)lineHeight {
// LineHeight does not take effect on single-line input.
}

- (void)setLineSpacing:(NSNumber *)lineSpacing {
// LineSpacing does not take effect on single-line input.
}

- (void)setLineHeightMultiple:(NSNumber *)lineHeightMultiple {
// LineHeightMultiple does not take effect on single-line input.
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
@property (nonatomic, strong) NSNumber *fontSize;
@property (nonatomic, strong) NSString *defaultValue;
@property (nonatomic, strong) UIColor *textColor;

/// ParagraphStyles - lineHeight
@property (nonatomic, strong) NSNumber *lineHeight;
/// ParagraphStyles - lineSpacing
@property (nonatomic, strong) NSNumber *lineSpacing;
/// ParagraphStyles - lineHeightMultiple
@property (nonatomic, strong) NSNumber *lineHeightMultiple;

@property (nonatomic, copy) HippyDirectEventBlock onChangeText;
@property (nonatomic, copy) HippyDirectEventBlock onBlur;
@property (nonatomic, copy) HippyDirectEventBlock onFocus;
Expand Down
Loading

0 comments on commit f8395a9

Please sign in to comment.