Skip to content

Commit e3a3999

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: ScrollView: primitives and buck target
Summary: Trivial. Reviewed By: fkgozali Differential Revision: D7961870 fbshipit-source-id: 3cfd92bd441dbf516ade777e6428924e9634257a
1 parent b805172 commit e3a3999

File tree

5 files changed

+201
-0
lines changed

5 files changed

+201
-0
lines changed

React.podspec

+9
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ Pod::Spec.new do |s|
171171
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" }
172172
end
173173

174+
ss.subspec "scrollview" do |sss|
175+
sss.dependency "Folly", folly_version
176+
sss.compiler_flags = folly_compiler_flags
177+
sss.source_files = "ReactCommon/fabric/scrollview/**/*.{cpp,h}"
178+
sss.exclude_files = "**/tests/*"
179+
sss.header_dir = "fabric/scrollview"
180+
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" }
181+
end
182+
174183
ss.subspec "text" do |sss|
175184
sss.dependency "Folly", folly_version
176185
sss.compiler_flags = folly_compiler_flags

ReactCommon/fabric/scrollview/BUCK

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
load("//configurations/buck/apple:flag_defs.bzl", "get_application_ios_flags", "get_debug_preprocessor_flags", "OBJC_ARC_PREPROCESSOR_FLAGS")
2+
load("//ReactNative:DEFS.bzl", "IS_OSS_BUILD", "rn_xplat_cxx_library", "get_apple_inspector_flags", "react_native_xplat_target", "ANDROID", "APPLE")
3+
4+
APPLE_COMPILER_FLAGS = []
5+
6+
if not IS_OSS_BUILD:
7+
load("@xplat//configurations/buck/apple:flag_defs.bzl", "get_static_library_ios_flags", "flags")
8+
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), 'compiler_flags')
9+
10+
rn_xplat_cxx_library(
11+
name = "scrollview",
12+
srcs = glob(
13+
["**/*.cpp"],
14+
excludes = glob(["tests/**/*.cpp"]),
15+
),
16+
headers = glob(
17+
["**/*.h"],
18+
excludes = glob(["tests/**/*.h"]),
19+
),
20+
header_namespace = "",
21+
exported_headers = subdir_glob(
22+
[
23+
("", "*.h"),
24+
],
25+
prefix = "fabric/scrollview",
26+
),
27+
compiler_flags = [
28+
"-fexceptions",
29+
"-frtti",
30+
"-std=c++14",
31+
"-Wall",
32+
],
33+
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
34+
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(),
35+
fbobjc_tests = [
36+
":tests",
37+
],
38+
force_static = True,
39+
macosx_tests_override = [],
40+
platforms = (ANDROID, APPLE),
41+
preprocessor_flags = [
42+
"-DLOG_TAG=\"ReactNative\"",
43+
"-DWITH_FBSYSTRACE=1",
44+
],
45+
tests = [],
46+
visibility = ["PUBLIC"],
47+
deps = [
48+
"xplat//fbsystrace:fbsystrace",
49+
"xplat//folly:headers_only",
50+
"xplat//folly:memory",
51+
"xplat//folly:molly",
52+
"xplat//third-party/glog:glog",
53+
"xplat//yoga:yoga",
54+
react_native_xplat_target("fabric/debug:debug"),
55+
react_native_xplat_target("fabric/core:core"),
56+
react_native_xplat_target("fabric/graphics:graphics"),
57+
react_native_xplat_target("fabric/view:view"),
58+
],
59+
)
60+
61+
if not IS_OSS_BUILD:
62+
load("@xplat//build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test")
63+
64+
fb_xplat_cxx_test(
65+
name = "tests",
66+
srcs = glob(["tests/**/*.cpp"]),
67+
headers = glob(["tests/**/*.h"]),
68+
contacts = ["oncall+react_native@xmail.facebook.com"],
69+
compiler_flags = [
70+
"-fexceptions",
71+
"-frtti",
72+
"-std=c++14",
73+
"-Wall",
74+
],
75+
platforms = APPLE,
76+
deps = [
77+
"xplat//folly:molly",
78+
"xplat//third-party/gmock:gtest",
79+
":scrollview",
80+
],
81+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <fabric/scrollview/primitives.h>
11+
#include <folly/dynamic.h>
12+
13+
namespace facebook {
14+
namespace react {
15+
16+
inline void fromDynamic(const folly::dynamic &value, ScrollViewSnapToAlignment &result) {
17+
auto string = value.asString();
18+
if (string == "start") { result = ScrollViewSnapToAlignment::Start; return; }
19+
if (string == "center") { result = ScrollViewSnapToAlignment::Center; return; }
20+
if (string == "end") { result = ScrollViewSnapToAlignment::End; return; }
21+
abort();
22+
}
23+
24+
inline void fromDynamic(const folly::dynamic &value, ScrollViewIndicatorStyle &result) {
25+
auto string = value.asString();
26+
if (string == "default") { result = ScrollViewIndicatorStyle::Default; return; }
27+
if (string == "black") { result = ScrollViewIndicatorStyle::Black; return; }
28+
if (string == "white") { result = ScrollViewIndicatorStyle::White; return; }
29+
abort();
30+
}
31+
32+
inline void fromDynamic(const folly::dynamic &value, ScrollViewKeyboardDismissMode &result) {
33+
auto string = value.asString();
34+
if (string == "none") { result = ScrollViewKeyboardDismissMode::None; return; }
35+
if (string == "on-drag") { result = ScrollViewKeyboardDismissMode::OnDrag; return; }
36+
if (string == "interactive") { result = ScrollViewKeyboardDismissMode::Interactive; return; }
37+
abort();
38+
}
39+
40+
inline std::string toString(const ScrollViewSnapToAlignment &value) {
41+
switch (value) {
42+
case ScrollViewSnapToAlignment::Start: return "start";
43+
case ScrollViewSnapToAlignment::Center: return "center";
44+
case ScrollViewSnapToAlignment::End: return "end";
45+
}
46+
}
47+
48+
inline std::string toString(const ScrollViewIndicatorStyle &value) {
49+
switch (value) {
50+
case ScrollViewIndicatorStyle::Default: return "default";
51+
case ScrollViewIndicatorStyle::Black: return "black";
52+
case ScrollViewIndicatorStyle::White: return "white";
53+
}
54+
}
55+
56+
inline std::string toString(const ScrollViewKeyboardDismissMode &value) {
57+
switch (value) {
58+
case ScrollViewKeyboardDismissMode::None: return "none";
59+
case ScrollViewKeyboardDismissMode::OnDrag: return "on-drag";
60+
case ScrollViewKeyboardDismissMode::Interactive: return "interactive";
61+
}
62+
}
63+
64+
} // namespace react
65+
} // namespace facebook
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
namespace facebook {
11+
namespace react {
12+
13+
enum class ScrollViewSnapToAlignment {
14+
Start,
15+
Center,
16+
End
17+
};
18+
19+
enum class ScrollViewIndicatorStyle {
20+
Default,
21+
Black,
22+
White
23+
};
24+
25+
enum class ScrollViewKeyboardDismissMode {
26+
None,
27+
OnDrag,
28+
Interactive
29+
};
30+
31+
} // namespace react
32+
} // namespace facebook
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include <memory>
9+
10+
#include <gtest/gtest.h>
11+
12+
TEST(ScrollViewTest, testSomething) {
13+
// TODO
14+
}

0 commit comments

Comments
 (0)