@solidx/checkbox 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NuGet.config +11 -0
- package/RNCCheckbox.podspec +22 -0
- package/android/build.gradle +65 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +4 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBox.java +43 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxEvent.java +47 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxManager.java +128 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxPackage.java +29 -0
- package/dist/js/AndroidCheckBoxNativeComponent.d.ts +2 -0
- package/dist/js/AndroidCheckBoxNativeComponent.js +11 -0
- package/dist/js/CheckBox.android.d.ts +83 -0
- package/dist/js/CheckBox.android.js +162 -0
- package/dist/js/CheckBox.d.ts +5 -0
- package/dist/js/CheckBox.ios.d.ts +92 -0
- package/dist/js/CheckBox.ios.js +109 -0
- package/dist/js/CheckBox.js +27 -0
- package/dist/js/CheckBox.windows.d.ts +95 -0
- package/dist/js/CheckBox.windows.js +95 -0
- package/dist/js/CheckboxNativeComponent.d.ts +11 -0
- package/dist/js/CheckboxNativeComponent.js +22 -0
- package/dist/js/IOSCheckBoxNativeComponent.d.ts +2 -0
- package/dist/js/IOSCheckBoxNativeComponent.js +11 -0
- package/dist/js/NativeCheckboxModule.d.ts +11 -0
- package/dist/js/NativeCheckboxModule.js +10 -0
- package/dist/js/RNCCheckboxNativeComponent.d.ts +48 -0
- package/dist/js/RNCCheckboxNativeComponent.js +12 -0
- package/dist/js/index.d.ts +11 -0
- package/dist/js/index.js +34 -0
- package/dist/js/setAndForwardRef.d.ts +40 -0
- package/dist/js/setAndForwardRef.js +53 -0
- package/ios/Podfile +3 -0
- package/ios/Podfile.lock +16 -0
- package/ios/RNCCheckbox.h +16 -0
- package/ios/RNCCheckbox.m +13 -0
- package/ios/RNCCheckbox.xcodeproj/project.pbxproj +322 -0
- package/ios/RNCCheckbox.xcodeproj/xcshareddata/xcschemes/RNCCheckbox.xcscheme +67 -0
- package/ios/RNCCheckbox.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/RNCCheckbox.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/RNCCheckbox.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +10 -0
- package/ios/RNCCheckboxManager.h +12 -0
- package/ios/RNCCheckboxManager.m +86 -0
- package/jest.config.windows.js +3 -0
- package/js/AndroidCheckBoxNativeComponent.ts +12 -0
- package/js/CheckBox.android.tsx +217 -0
- package/js/CheckBox.ios.tsx +175 -0
- package/js/CheckBox.ts +9 -0
- package/js/CheckBox.windows.tsx +158 -0
- package/js/CheckboxNativeComponent.ts +25 -0
- package/js/IOSCheckBoxNativeComponent.ts +12 -0
- package/js/NativeCheckboxModule.ts +15 -0
- package/js/RNCCheckboxNativeComponent.ts +68 -0
- package/js/index.ts +17 -0
- package/js/setAndForwardRef.ts +64 -0
- package/metro.config.js +45 -0
- package/package.json +84 -4
- package/react-native.config.js +22 -0
- package/typings/index.d.ts +14 -0
- package/windows/Checkbox/Checkbox.cpp +20 -0
- package/windows/Checkbox/Checkbox.def +3 -0
- package/windows/Checkbox/Checkbox.h +26 -0
- package/windows/Checkbox/Checkbox.rc +0 -0
- package/windows/Checkbox/Checkbox.vcxproj +146 -0
- package/windows/Checkbox/Checkbox.vcxproj.filters +56 -0
- package/windows/Checkbox/CheckboxView.cpp +186 -0
- package/windows/Checkbox/CheckboxView.h +59 -0
- package/windows/Checkbox/ReactPackageProvider.cpp +24 -0
- package/windows/Checkbox/ReactPackageProvider.h +24 -0
- package/windows/Checkbox/ReactPackageProvider.idl +9 -0
- package/windows/Checkbox/codegen/.clang-format +2 -0
- package/windows/Checkbox/codegen/NativeCheckboxModuleSpec.g.h +31 -0
- package/windows/Checkbox/codegen_manual/react/components/RNCCheckboxSpec/RNCCheckbox.g.h +232 -0
- package/windows/Checkbox/packages.lock.json +151 -0
- package/windows/Checkbox/pch.cpp +1 -0
- package/windows/Checkbox/pch.h +43 -0
- package/windows/Checkbox/resource.h +5 -0
- package/windows/Checkbox/targetver.h +8 -0
- package/windows/Checkbox.sln +43 -0
- package/windows/ExperimentalFeatures.props +33 -0
- package/README.md +0 -3
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- This project was created with react-native-windows 0.80.1 -->
|
|
3
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
4
|
+
<Import Project="$(SolutionDir)\ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)\ExperimentalFeatures.props')" />
|
|
5
|
+
<PropertyGroup Label="Globals">
|
|
6
|
+
<CppWinRTOptimized>true</CppWinRTOptimized>
|
|
7
|
+
<MinimalCoreWin>true</MinimalCoreWin>
|
|
8
|
+
<ProjectGuid>{C11CCEDE-33B9-47AD-AAD4-447924A81ED2}</ProjectGuid>
|
|
9
|
+
<ProjectName>Checkbox</ProjectName>
|
|
10
|
+
<Keyword>Win32Proj</Keyword>
|
|
11
|
+
<RootNamespace>Checkbox</RootNamespace>
|
|
12
|
+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
13
|
+
<DefaultLanguage>en-US</DefaultLanguage>
|
|
14
|
+
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
|
|
15
|
+
<AppxPackage>false</AppxPackage>
|
|
16
|
+
</PropertyGroup>
|
|
17
|
+
<PropertyGroup Label="ReactNativeWindowsProps">
|
|
18
|
+
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
|
|
19
|
+
<RunAutolinkCheck>false</RunAutolinkCheck>
|
|
20
|
+
</PropertyGroup>
|
|
21
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" />
|
|
22
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
23
|
+
<ItemGroup Label="ProjectConfigurations">
|
|
24
|
+
<ProjectConfiguration Include="Debug|Win32">
|
|
25
|
+
<Configuration>Debug</Configuration>
|
|
26
|
+
<Platform>Win32</Platform>
|
|
27
|
+
</ProjectConfiguration>
|
|
28
|
+
<ProjectConfiguration Include="Release|Win32">
|
|
29
|
+
<Configuration>Release</Configuration>
|
|
30
|
+
<Platform>Win32</Platform>
|
|
31
|
+
</ProjectConfiguration>
|
|
32
|
+
<ProjectConfiguration Include="Debug|x64">
|
|
33
|
+
<Configuration>Debug</Configuration>
|
|
34
|
+
<Platform>x64</Platform>
|
|
35
|
+
</ProjectConfiguration>
|
|
36
|
+
<ProjectConfiguration Include="Release|x64">
|
|
37
|
+
<Configuration>Release</Configuration>
|
|
38
|
+
<Platform>x64</Platform>
|
|
39
|
+
</ProjectConfiguration>
|
|
40
|
+
<ProjectConfiguration Include="Debug|ARM64">
|
|
41
|
+
<Configuration>Debug</Configuration>
|
|
42
|
+
<Platform>ARM64</Platform>
|
|
43
|
+
</ProjectConfiguration>
|
|
44
|
+
<ProjectConfiguration Include="Release|ARM64">
|
|
45
|
+
<Configuration>Release</Configuration>
|
|
46
|
+
<Platform>ARM64</Platform>
|
|
47
|
+
</ProjectConfiguration>
|
|
48
|
+
</ItemGroup>
|
|
49
|
+
<PropertyGroup Label="Configuration">
|
|
50
|
+
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
51
|
+
<CharacterSet>Unicode</CharacterSet>
|
|
52
|
+
<PlatformToolset>v143</PlatformToolset>
|
|
53
|
+
<GenerateManifest>false</GenerateManifest>
|
|
54
|
+
</PropertyGroup>
|
|
55
|
+
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
|
56
|
+
<UseDebugLibraries>true</UseDebugLibraries>
|
|
57
|
+
</PropertyGroup>
|
|
58
|
+
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
|
59
|
+
<UseDebugLibraries>false</UseDebugLibraries>
|
|
60
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
61
|
+
</PropertyGroup>
|
|
62
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
63
|
+
<ImportGroup Label="ExtensionSettings">
|
|
64
|
+
</ImportGroup>
|
|
65
|
+
<ImportGroup Label="PropertySheets">
|
|
66
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
67
|
+
</ImportGroup>
|
|
68
|
+
<ImportGroup Label="ReactNativeWindowsPropertySheets">
|
|
69
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props')" />
|
|
70
|
+
</ImportGroup>
|
|
71
|
+
<ItemDefinitionGroup>
|
|
72
|
+
<ClCompile>
|
|
73
|
+
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
74
|
+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
|
75
|
+
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
|
|
76
|
+
<WarningLevel>Level4</WarningLevel>
|
|
77
|
+
<SDLCheck>true</SDLCheck>
|
|
78
|
+
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
|
|
79
|
+
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
|
|
80
|
+
<PreprocessorDefinitions>RNW_NEW_ARCH;_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
81
|
+
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
|
82
|
+
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
83
|
+
<AdditionalIncludeDirectories>
|
|
84
|
+
$(MSBuildThisFileDirectory);
|
|
85
|
+
%(AdditionalIncludeDirectories)
|
|
86
|
+
</AdditionalIncludeDirectories>
|
|
87
|
+
</ClCompile>
|
|
88
|
+
<Link>
|
|
89
|
+
<AdditionalDependencies>shell32.lib;user32.lib;windowsapp.lib;%(AdditionalDependenices)</AdditionalDependencies>
|
|
90
|
+
<SubSystem>Console</SubSystem>
|
|
91
|
+
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
|
92
|
+
<ModuleDefinitionFile>Checkbox.def</ModuleDefinitionFile>
|
|
93
|
+
</Link>
|
|
94
|
+
</ItemDefinitionGroup>
|
|
95
|
+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
96
|
+
<ClCompile>
|
|
97
|
+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
98
|
+
</ClCompile>
|
|
99
|
+
</ItemDefinitionGroup>
|
|
100
|
+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
101
|
+
<ClCompile>
|
|
102
|
+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
103
|
+
</ClCompile>
|
|
104
|
+
</ItemDefinitionGroup>
|
|
105
|
+
<PropertyGroup Label="UserMacros" />
|
|
106
|
+
<ItemGroup>
|
|
107
|
+
<ClInclude Include="Checkbox.h" />
|
|
108
|
+
<ClInclude Include="CheckboxView.h" />
|
|
109
|
+
<ClInclude Include="ReactPackageProvider.h">
|
|
110
|
+
<DependentUpon>ReactPackageProvider.idl</DependentUpon>
|
|
111
|
+
</ClInclude>
|
|
112
|
+
<ClInclude Include="resource.h" />
|
|
113
|
+
<ClInclude Include="pch.h" />
|
|
114
|
+
<ClInclude Include="targetver.h" />
|
|
115
|
+
</ItemGroup>
|
|
116
|
+
<ItemGroup>
|
|
117
|
+
<ClCompile Include="Checkbox.cpp" />
|
|
118
|
+
<ClCompile Include="CheckboxView.cpp" />
|
|
119
|
+
<ClCompile Include="pch.cpp">
|
|
120
|
+
<PrecompiledHeader>Create</PrecompiledHeader>
|
|
121
|
+
</ClCompile>
|
|
122
|
+
<ClCompile Include="ReactPackageProvider.cpp">
|
|
123
|
+
<DependentUpon>ReactPackageProvider.idl</DependentUpon>
|
|
124
|
+
</ClCompile>
|
|
125
|
+
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
|
126
|
+
</ItemGroup>
|
|
127
|
+
<ItemGroup>
|
|
128
|
+
<Midl Include="ReactPackageProvider.idl" />
|
|
129
|
+
</ItemGroup>
|
|
130
|
+
<ItemGroup>
|
|
131
|
+
<ResourceCompile Include="Checkbox.rc" />
|
|
132
|
+
</ItemGroup>
|
|
133
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
134
|
+
<ImportGroup Label="ReactNativeWindowsTargets">
|
|
135
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets')" />
|
|
136
|
+
</ImportGroup>
|
|
137
|
+
<ItemGroup>
|
|
138
|
+
</ItemGroup>
|
|
139
|
+
<Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
|
|
140
|
+
<PropertyGroup>
|
|
141
|
+
<ErrorText>This project references targets in your node_modules\react-native-windows folder. The missing file is {0}.</ErrorText>
|
|
142
|
+
</PropertyGroup>
|
|
143
|
+
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props'))" />
|
|
144
|
+
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets'))" />
|
|
145
|
+
</Target>
|
|
146
|
+
</Project>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup>
|
|
4
|
+
<Filter Include="Source Files">
|
|
5
|
+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
6
|
+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
7
|
+
</Filter>
|
|
8
|
+
<Filter Include="Header Files">
|
|
9
|
+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
10
|
+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
|
11
|
+
</Filter>
|
|
12
|
+
<Filter Include="Resource Files">
|
|
13
|
+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
14
|
+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
15
|
+
</Filter>
|
|
16
|
+
</ItemGroup>
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClInclude Include="targetver.h">
|
|
19
|
+
<Filter>Header Files</Filter>
|
|
20
|
+
</ClInclude>
|
|
21
|
+
<ClInclude Include="resource.h">
|
|
22
|
+
<Filter>Header Files</Filter>
|
|
23
|
+
</ClInclude>
|
|
24
|
+
<ClInclude Include="Checkbox.h">
|
|
25
|
+
<Filter>Header Files</Filter>
|
|
26
|
+
</ClInclude>
|
|
27
|
+
<ClInclude Include="CheckboxView.h">
|
|
28
|
+
<Filter>Header Files</Filter>
|
|
29
|
+
</ClInclude>
|
|
30
|
+
<ClInclude Include="ReactPackageProvider.h">
|
|
31
|
+
<Filter>Header Files</Filter>
|
|
32
|
+
</ClInclude>
|
|
33
|
+
<ClInclude Include="pch.h">
|
|
34
|
+
<Filter>Header Files</Filter>
|
|
35
|
+
</ClInclude>
|
|
36
|
+
</ItemGroup>
|
|
37
|
+
<ItemGroup>
|
|
38
|
+
<ClCompile Include="Checkbox.cpp">
|
|
39
|
+
<Filter>Source Files</Filter>
|
|
40
|
+
</ClCompile>
|
|
41
|
+
<ClCompile Include="CheckboxView.cpp">
|
|
42
|
+
<Filter>Source Files</Filter>
|
|
43
|
+
</ClCompile>
|
|
44
|
+
<ClCompile Include="ReactPackageProvider.cpp">
|
|
45
|
+
<Filter>Source Files</Filter>
|
|
46
|
+
</ClCompile>
|
|
47
|
+
<ClCompile Include="pch.cpp">
|
|
48
|
+
<Filter>Source Files</Filter>
|
|
49
|
+
</ClCompile>
|
|
50
|
+
</ItemGroup>
|
|
51
|
+
<ItemGroup>
|
|
52
|
+
<ResourceCompile Include="Checkbox.rc">
|
|
53
|
+
<Filter>Resource Files</Filter>
|
|
54
|
+
</ResourceCompile>
|
|
55
|
+
</ItemGroup>
|
|
56
|
+
</Project>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "pch.h"
|
|
5
|
+
#include "CheckboxView.h"
|
|
6
|
+
#include <limits>
|
|
7
|
+
|
|
8
|
+
namespace winrt::Checkbox::implementation {
|
|
9
|
+
|
|
10
|
+
void RegisterCheckboxComponentView(
|
|
11
|
+
winrt::Microsoft::ReactNative::IReactPackageBuilder const& packageBuilder) noexcept {
|
|
12
|
+
CheckboxCodegen::RegisterRNCCheckboxNativeComponent<winrt::Checkbox::implementation::RNCCheckboxComponentView>(
|
|
13
|
+
packageBuilder,
|
|
14
|
+
[](const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder& builder) {
|
|
15
|
+
builder.as<winrt::Microsoft::ReactNative::IReactViewComponentBuilder>().XamlSupport(true);
|
|
16
|
+
// Use SetContentIslandComponentViewInitializer
|
|
17
|
+
builder.SetContentIslandComponentViewInitializer(
|
|
18
|
+
[](const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView& islandView) noexcept {
|
|
19
|
+
auto userData = winrt::make_self<winrt::Checkbox::implementation::RNCCheckboxComponentView>();
|
|
20
|
+
userData->InitializeContentIsland(islandView);
|
|
21
|
+
islandView.UserData(*userData);
|
|
22
|
+
});
|
|
23
|
+
// Set up initial state with zero size
|
|
24
|
+
builder.as<winrt::Microsoft::ReactNative::IReactViewComponentBuilder>().SetInitialStateDataFactory(
|
|
25
|
+
[](const winrt::Microsoft::ReactNative::IComponentProps& /*props*/) noexcept {
|
|
26
|
+
return winrt::make<RNCCheckboxStateData>(winrt::Windows::Foundation::Size{ 0, 0 });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Register the measure function - reads from state
|
|
30
|
+
builder.as<winrt::Microsoft::ReactNative::IReactViewComponentBuilder>().SetMeasureContentHandler(
|
|
31
|
+
[](winrt::Microsoft::ReactNative::ShadowNode const& shadowNode,
|
|
32
|
+
winrt::Microsoft::ReactNative::LayoutContext const&,
|
|
33
|
+
winrt::Microsoft::ReactNative::LayoutConstraints const&) noexcept {
|
|
34
|
+
|
|
35
|
+
auto currentState = winrt::get_self<RNCCheckboxStateData>(shadowNode.StateData());
|
|
36
|
+
|
|
37
|
+
if (currentState && currentState->desiredSize.Width > 0) {
|
|
38
|
+
// Return the measured size from state
|
|
39
|
+
return currentState->desiredSize;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Return a default size if we don't have a measurement yet
|
|
43
|
+
return winrt::Windows::Foundation::Size{ 32, 32 };
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Handle state updates
|
|
47
|
+
builder.as<winrt::Microsoft::ReactNative::IReactViewComponentBuilder>().SetUpdateStateHandler(
|
|
48
|
+
[](const winrt::Microsoft::ReactNative::ComponentView& view,
|
|
49
|
+
const winrt::Microsoft::ReactNative::IComponentState& newState) {
|
|
50
|
+
auto islandView = view.as<winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView>();
|
|
51
|
+
auto userData = islandView.UserData().as<winrt::Checkbox::implementation::RNCCheckboxComponentView>();
|
|
52
|
+
userData->UpdateState(view, newState);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void RNCCheckboxComponentView::InitializeContentIsland(
|
|
58
|
+
const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView& islandView) {
|
|
59
|
+
// Create CheckBox
|
|
60
|
+
m_checkBox = winrt::Microsoft::UI::Xaml::Controls::CheckBox();
|
|
61
|
+
m_checkBox.HorizontalAlignment(winrt::Microsoft::UI::Xaml::HorizontalAlignment::Left);
|
|
62
|
+
m_checkBox.VerticalAlignment(winrt::Microsoft::UI::Xaml::VerticalAlignment::Center);
|
|
63
|
+
|
|
64
|
+
// Subscribe to Checked/Unchecked events with auto-revokers
|
|
65
|
+
m_checkedRevoker = m_checkBox.Checked(winrt::auto_revoke, [this](auto const&, auto const&) {
|
|
66
|
+
OnCheckedChanged();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
m_uncheckedRevoker = m_checkBox.Unchecked(winrt::auto_revoke, [this](auto const&, auto const&) {
|
|
70
|
+
OnCheckedChanged();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Listen for size changes on the checkbox with auto-revoker
|
|
74
|
+
m_sizeChangedRevoker = m_checkBox.SizeChanged(winrt::auto_revoke, [this](auto const&, auto const&) {
|
|
75
|
+
RefreshSize();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
m_island = winrt::Microsoft::UI::Xaml::XamlIsland{};
|
|
79
|
+
m_island.Content(m_checkBox);
|
|
80
|
+
islandView.Connect(m_island.ContentIsland());
|
|
81
|
+
m_islandView = winrt::make_weak(islandView);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void RNCCheckboxComponentView::UpdateProps(
|
|
85
|
+
const winrt::Microsoft::ReactNative::ComponentView& view,
|
|
86
|
+
const winrt::com_ptr<CheckboxCodegen::RNCCheckboxProps>& newProps,
|
|
87
|
+
const winrt::com_ptr<CheckboxCodegen::RNCCheckboxProps>& oldProps) noexcept {
|
|
88
|
+
BaseRNCCheckbox::UpdateProps(view, newProps, oldProps);
|
|
89
|
+
|
|
90
|
+
if (!m_checkBox) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Update value (checked state)
|
|
95
|
+
if (newProps->value.has_value()) {
|
|
96
|
+
m_checkBox.IsChecked(newProps->value.value());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Update disabled state
|
|
100
|
+
if (newProps->disabled.has_value()) {
|
|
101
|
+
m_checkBox.IsEnabled(!newProps->disabled.value());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
auto resDict = m_checkBox.Resources();
|
|
105
|
+
auto theme = view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Theme();
|
|
106
|
+
|
|
107
|
+
// onCheckColor - color of the check mark when checked
|
|
108
|
+
if (newProps->onCheckColor) {
|
|
109
|
+
auto brush = winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(newProps->onCheckColor.AsWindowsColor(theme));
|
|
110
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckGlyphForegroundChecked"), brush);
|
|
111
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckGlyphForegroundCheckedPointerOver"), brush);
|
|
112
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckGlyphForegroundCheckedPressed"), brush);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// onTintColor - color of the border when checked
|
|
116
|
+
if (newProps->onTintColor) {
|
|
117
|
+
auto brush = winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(newProps->onTintColor.AsWindowsColor(theme));
|
|
118
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundStrokeChecked"), brush);
|
|
119
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundStrokeCheckedPointerOver"), brush);
|
|
120
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundStrokeCheckedPressed"), brush);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// onFillColor - fill color of the box when checked
|
|
124
|
+
if (newProps->onFillColor) {
|
|
125
|
+
auto brush = winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(newProps->onFillColor.AsWindowsColor(theme));
|
|
126
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillChecked"), brush);
|
|
127
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillCheckedPointerOver"), brush);
|
|
128
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillCheckedPressed"), brush);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// tintColor - color of the box when unchecked
|
|
132
|
+
if (newProps->tintColor) {
|
|
133
|
+
auto brush = winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(newProps->tintColor.AsWindowsColor(theme));
|
|
134
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillUnchecked"), brush);
|
|
135
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillUncheckedPointerOver"), brush);
|
|
136
|
+
resDict.Insert(winrt::box_value(L"CheckBoxCheckBackgroundFillUncheckedPressed"), brush);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// label - text content next to the checkbox
|
|
140
|
+
if (!newProps->label.empty()) {
|
|
141
|
+
m_checkBox.Content(winrt::box_value(winrt::to_hstring(newProps->label)));
|
|
142
|
+
} else {
|
|
143
|
+
m_checkBox.Content(nullptr);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
RefreshSize();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Measure checkbox and update state if needed.
|
|
150
|
+
void RNCCheckboxComponentView::RefreshSize() {
|
|
151
|
+
if (!m_checkBox) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
m_checkBox.Measure(winrt::Windows::Foundation::Size{
|
|
156
|
+
std::numeric_limits<float>::infinity(),
|
|
157
|
+
std::numeric_limits<float>::infinity()
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
auto desiredSize = m_checkBox.DesiredSize();
|
|
161
|
+
|
|
162
|
+
if (m_state) {
|
|
163
|
+
auto currentState = winrt::get_self<RNCCheckboxStateData>(m_state.Data());
|
|
164
|
+
if (desiredSize != currentState->desiredSize) {
|
|
165
|
+
m_state.UpdateStateWithMutation([desiredSize](winrt::Windows::Foundation::IInspectable /*data*/) {
|
|
166
|
+
return winrt::make<RNCCheckboxStateData>(desiredSize);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void RNCCheckboxComponentView::UpdateState(
|
|
173
|
+
const winrt::Microsoft::ReactNative::ComponentView& /*view*/,
|
|
174
|
+
const winrt::Microsoft::ReactNative::IComponentState& newState) noexcept {
|
|
175
|
+
m_state = newState;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
void RNCCheckboxComponentView::OnCheckedChanged() {
|
|
179
|
+
if (auto eventEmitter = EventEmitter()) {
|
|
180
|
+
CheckboxCodegen::RNCCheckboxEventEmitter::OnChange args;
|
|
181
|
+
args.value = m_checkBox.IsChecked().GetBoolean();
|
|
182
|
+
eventEmitter->onChange(args);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
} // namespace winrt::Checkbox::implementation
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "pch.h"
|
|
7
|
+
|
|
8
|
+
#include "codegen_manual/react/components/RNCCheckboxSpec/RNCCheckbox.g.h"
|
|
9
|
+
|
|
10
|
+
#include <winrt/Microsoft.ReactNative.h>
|
|
11
|
+
#include <winrt/Microsoft.ReactNative.Composition.h>
|
|
12
|
+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
13
|
+
#include <winrt/Microsoft.UI.Xaml.h>
|
|
14
|
+
|
|
15
|
+
namespace winrt::Checkbox::implementation {
|
|
16
|
+
|
|
17
|
+
// State to store the measured size
|
|
18
|
+
struct RNCCheckboxStateData : winrt::implements<RNCCheckboxStateData, winrt::IInspectable> {
|
|
19
|
+
RNCCheckboxStateData(winrt::Windows::Foundation::Size ds) : desiredSize(ds) {}
|
|
20
|
+
winrt::Windows::Foundation::Size desiredSize;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
struct RNCCheckboxComponentView : winrt::implements<RNCCheckboxComponentView, winrt::IInspectable>,
|
|
24
|
+
CheckboxCodegen::BaseRNCCheckbox<RNCCheckboxComponentView> {
|
|
25
|
+
void InitializeContentIsland(
|
|
26
|
+
const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView& islandView);
|
|
27
|
+
|
|
28
|
+
void UpdateProps(
|
|
29
|
+
const winrt::Microsoft::ReactNative::ComponentView& view,
|
|
30
|
+
const winrt::com_ptr<CheckboxCodegen::RNCCheckboxProps>& newProps,
|
|
31
|
+
const winrt::com_ptr<CheckboxCodegen::RNCCheckboxProps>& oldProps) noexcept override;
|
|
32
|
+
|
|
33
|
+
void UpdateState(
|
|
34
|
+
const winrt::Microsoft::ReactNative::ComponentView& view,
|
|
35
|
+
const winrt::Microsoft::ReactNative::IComponentState& newState) noexcept override;
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
void RefreshSize();
|
|
39
|
+
void OnCheckedChanged();
|
|
40
|
+
|
|
41
|
+
winrt::weak_ref<winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView> m_islandView;
|
|
42
|
+
winrt::Microsoft::UI::Xaml::XamlIsland m_island{ nullptr };
|
|
43
|
+
winrt::Microsoft::UI::Xaml::Controls::CheckBox m_checkBox{ nullptr };
|
|
44
|
+
winrt::Microsoft::ReactNative::IComponentState m_state{ nullptr };
|
|
45
|
+
|
|
46
|
+
// Auto-revokers for event subscriptions
|
|
47
|
+
winrt::Microsoft::UI::Xaml::Controls::CheckBox::Checked_revoker m_checkedRevoker;
|
|
48
|
+
winrt::Microsoft::UI::Xaml::Controls::CheckBox::Unchecked_revoker m_uncheckedRevoker;
|
|
49
|
+
winrt::Microsoft::UI::Xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
void RegisterCheckboxComponentView(
|
|
53
|
+
winrt::Microsoft::ReactNative::IReactPackageBuilder const& packageBuilder) noexcept;
|
|
54
|
+
|
|
55
|
+
} // namespace winrt::Checkbox::implementation
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#include "pch.h"
|
|
2
|
+
|
|
3
|
+
#include "ReactPackageProvider.h"
|
|
4
|
+
#if __has_include("ReactPackageProvider.g.cpp")
|
|
5
|
+
#include "ReactPackageProvider.g.cpp"
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include "Checkbox.h"
|
|
9
|
+
#include "CheckboxView.h"
|
|
10
|
+
|
|
11
|
+
using namespace winrt::Microsoft::ReactNative;
|
|
12
|
+
|
|
13
|
+
namespace winrt::Checkbox::implementation
|
|
14
|
+
{
|
|
15
|
+
|
|
16
|
+
void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept
|
|
17
|
+
{
|
|
18
|
+
// Register TurboModule
|
|
19
|
+
RegisterCheckboxNativeModule(packageBuilder);
|
|
20
|
+
// Register our Checkbox component (new architecture)
|
|
21
|
+
RegisterCheckboxComponentView(packageBuilder);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace winrt::Checkbox::implementation
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "ReactPackageProvider.g.h"
|
|
4
|
+
|
|
5
|
+
using namespace winrt::Microsoft::ReactNative;
|
|
6
|
+
|
|
7
|
+
namespace winrt::Checkbox::implementation
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider>
|
|
11
|
+
{
|
|
12
|
+
ReactPackageProvider() = default;
|
|
13
|
+
|
|
14
|
+
void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace winrt::Checkbox::implementation
|
|
18
|
+
|
|
19
|
+
namespace winrt::Checkbox::factory_implementation
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
struct ReactPackageProvider : ReactPackageProviderT<ReactPackageProvider, implementation::ReactPackageProvider> {};
|
|
23
|
+
|
|
24
|
+
} // namespace winrt::Checkbox::factory_implementation
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* This file is auto-generated from a NativeModule spec file in js.
|
|
4
|
+
*
|
|
5
|
+
* This is a C++ Spec class that should be used with MakeTurboModuleProvider to register native modules
|
|
6
|
+
* in a way that also verifies at compile time that the native module matches the interface required
|
|
7
|
+
* by the TurboModule JS spec.
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
// clang-format off
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#include <NativeModules.h>
|
|
14
|
+
#include <tuple>
|
|
15
|
+
|
|
16
|
+
namespace CheckboxCodegen {
|
|
17
|
+
|
|
18
|
+
struct CheckboxModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
|
|
19
|
+
static constexpr auto methods = std::tuple{
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
template <class TModule>
|
|
24
|
+
static constexpr void ValidateModule() noexcept {
|
|
25
|
+
constexpr auto methodCheckResults = CheckMethods<TModule, CheckboxModuleSpec>();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace CheckboxCodegen
|