From df65dbaca669653c304bcde5a576f87008d57333 Mon Sep 17 00:00:00 2001 From: Jacek Pudysz Date: Mon, 15 Jul 2024 13:42:56 +0200 Subject: [PATCH] feat: remove dynamicTypeSize event --- cxx/UnistylesModel.cpp | 8 -------- cxx/UnistylesModel.h | 1 - examples/bare/README.md | 5 +++++ .../bare/android/app/src/main/AndroidManifest.xml | 2 +- examples/bare/ios/Podfile.lock | 10 +++++----- src/common.ts | 3 +-- src/hooks/useUnistyles.ts | 11 ++--------- src/types/unistyles.ts | 9 +-------- 8 files changed, 15 insertions(+), 34 deletions(-) diff --git a/cxx/UnistylesModel.cpp b/cxx/UnistylesModel.cpp index b3d2f230..75c4d800 100644 --- a/cxx/UnistylesModel.cpp +++ b/cxx/UnistylesModel.cpp @@ -67,7 +67,6 @@ void UnistylesModel::handleContentSizeCategoryChange(std::string contentSizeCate } this->contentSizeCategory = contentSizeCategory; - this->onContentSizeCategoryChange(contentSizeCategory); } jsi::Value UnistylesModel::getThemeOrFail(jsi::Runtime& runtime) { @@ -144,13 +143,6 @@ void UnistylesModel::onThemeChange(std::string themeName) { this->emitDeviceEvent("theme", payload); } -void UnistylesModel::onContentSizeCategoryChange(std::string contentSizeCategory) { - EventPayload payload; - payload["contentSizeCategory"] = contentSizeCategory; - - this->emitDeviceEvent("dynamicTypeSize", payload); -} - void UnistylesModel::onPluginChange() { this->emitDeviceEvent("plugin", {}); } diff --git a/cxx/UnistylesModel.h b/cxx/UnistylesModel.h index 868b9bb4..7e554cf3 100644 --- a/cxx/UnistylesModel.h +++ b/cxx/UnistylesModel.h @@ -50,7 +50,6 @@ struct UnistylesModel { void emitDeviceEvent(const std::string eventType, EventPayload payload); void onThemeChange(std::string themeName); void onPluginChange(); - void onContentSizeCategoryChange(std::string contentSizeCategory); void onLayoutChange(); jsi::Object parseEventPayload(EventPayload payload); jsi::Object parseEventNestedPayload(EventNestedValue payload); diff --git a/examples/bare/README.md b/examples/bare/README.md index 50801a91..e447d86c 100644 --- a/examples/bare/README.md +++ b/examples/bare/README.md @@ -5,3 +5,8 @@ yarn start yarn ios yarn android ``` + +Install pods with: +```shell +RCT_NEW_ARCH_ENABLED=1 npx pod-install +``` diff --git a/examples/bare/android/app/src/main/AndroidManifest.xml b/examples/bare/android/app/src/main/AndroidManifest.xml index 4122f36a..60cd5265 100644 --- a/examples/bare/android/app/src/main/AndroidManifest.xml +++ b/examples/bare/android/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ diff --git a/examples/bare/ios/Podfile.lock b/examples/bare/ios/Podfile.lock index 4026578e..500672f3 100644 --- a/examples/bare/ios/Podfile.lock +++ b/examples/bare/ios/Podfile.lock @@ -935,7 +935,7 @@ PODS: - React-Mapbuffer (0.74.2): - glog - React-debug - - react-native-unistyles (2.8.0-rc.3): + - react-native-unistyles (2.8.3): - DoubleConversion - glog - hermes-engine @@ -1395,15 +1395,15 @@ SPEC CHECKSUMS: React-jsitracing: 0fa7f78d8fdda794667cb2e6f19c874c1cf31d7e React-logger: 29fa3e048f5f67fe396bc08af7606426d9bd7b5d React-Mapbuffer: bf56147c9775491e53122a94c423ac201417e326 - react-native-unistyles: b1c5a0d1f66e07747c8ee0069ef329db831b0ef8 + react-native-unistyles: 91d21b6ba5376248ab0f54dcab739ff6df88b0e5 React-nativeconfig: 9f223cd321823afdecf59ed00861ab2d69ee0fc1 React-NativeModulesApple: ff7efaff7098639db5631236cfd91d60abff04c0 React-perflogger: 32ed45d9cee02cf6639acae34251590dccd30994 React-RCTActionSheet: 19f967ddaea258182b56ef11437133b056ba2adf React-RCTAnimation: d7f4137fc44a08bba465267ea7cb1dbdb7c4ec87 - React-RCTAppDelegate: 2b3f4d8009796af209a0d496e73276b743acee08 + React-RCTAppDelegate: dca95e1a6194f7ae06c2b5f1d5f891c61af00ec8 React-RCTBlob: c6c3e1e0251700b7bea036b893913f22e2b9cb47 - React-RCTFabric: 93a3ea55169d19294f07092013c1c9ea7a015c9b + React-RCTFabric: a7874c54aea18f64677446efc5f839ec4fa5e931 React-RCTImage: 40528ab74a4fef0f0e2ee797a074b26d120b6cc6 React-RCTLinking: 385b5beb96749aae9ae1606746e883e1c9f8a6a7 React-RCTNetwork: ffc9f05bd8fa5b3bce562199ba41235ad0af645c @@ -1420,7 +1420,7 @@ SPEC CHECKSUMS: React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31 ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d - Yoga: 2f71ecf38d934aecb366e686278102a51679c308 + Yoga: ae3c32c514802d30f687a04a6a35b348506d411f PODFILE CHECKSUM: 6e8b47c8b21657e11e4e323edee6ee184b76d2f4 diff --git a/src/common.ts b/src/common.ts index c71955e5..512b5125 100644 --- a/src/common.ts +++ b/src/common.ts @@ -46,8 +46,7 @@ export enum AndroidContentSizeCategory { export enum UnistylesEventType { Theme = 'theme', Layout = 'layout', - Plugin = 'plugin', - DynamicTypeSize = 'dynamicTypeSize' + Plugin = 'plugin' } export enum UnistylesError { diff --git a/src/hooks/useUnistyles.ts b/src/hooks/useUnistyles.ts index ded465cf..2e1ed0d0 100644 --- a/src/hooks/useUnistyles.ts +++ b/src/hooks/useUnistyles.ts @@ -2,14 +2,13 @@ import { NativeEventEmitter, NativeModules } from 'react-native' import { useEffect, useState } from 'react' import { unistyles } from '../core' import { UnistylesEventType } from '../common' -import type { UnistylesDynamicTypeSizeEvent, UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types' +import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types' const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles) export const useUnistyles = () => { const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins) const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName)) - const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory) const [layout, setLayout] = useState({ breakpoint: unistyles.runtime.breakpoint, orientation: unistyles.runtime.orientation, @@ -58,11 +57,6 @@ export const useUnistyles = () => { case UnistylesEventType.Plugin: { return setPlugins(unistyles.runtime.enabledPlugins) } - case UnistylesEventType.DynamicTypeSize: { - const dynamicTypeSizeEvent = event as UnistylesDynamicTypeSizeEvent - - return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory) - } default: return } @@ -75,7 +69,6 @@ export const useUnistyles = () => { return { plugins, theme, - layout, - contentSizeCategory + layout } } diff --git a/src/types/unistyles.ts b/src/types/unistyles.ts index 98d4fd57..0f135784 100644 --- a/src/types/unistyles.ts +++ b/src/types/unistyles.ts @@ -90,11 +90,4 @@ export type UnistylesPluginEvent = { type: UnistylesEventType.Plugin } -export type UnistylesDynamicTypeSizeEvent = { - type: UnistylesEventType.DynamicTypeSize, - payload: { - contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory - } -} - -export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent +export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent