Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove dynamicTypeSize event #245

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions cxx/UnistylesModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ void UnistylesModel::handleContentSizeCategoryChange(std::string contentSizeCate
}

this->contentSizeCategory = contentSizeCategory;
this->onContentSizeCategoryChange(contentSizeCategory);
}

jsi::Value UnistylesModel::getThemeOrFail(jsi::Runtime& runtime) {
Expand Down Expand Up @@ -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", {});
}
Expand Down
1 change: 0 additions & 1 deletion cxx/UnistylesModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions examples/bare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ yarn start
yarn ios
yarn android
```

Install pods with:
```shell
RCT_NEW_ARCH_ENABLED=1 npx pod-install
```
2 changes: 1 addition & 1 deletion examples/bare/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|fontScale"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
Expand Down
10 changes: 5 additions & 5 deletions examples/bare/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -1420,7 +1420,7 @@ SPEC CHECKSUMS:
React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31
ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2f71ecf38d934aecb366e686278102a51679c308
Yoga: ae3c32c514802d30f687a04a6a35b348506d411f

PODFILE CHECKSUM: 6e8b47c8b21657e11e4e323edee6ee184b76d2f4

Expand Down
3 changes: 1 addition & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export enum AndroidContentSizeCategory {
export enum UnistylesEventType {
Theme = 'theme',
Layout = 'layout',
Plugin = 'plugin',
DynamicTypeSize = 'dynamicTypeSize'
Plugin = 'plugin'
}

export enum UnistylesError {
Expand Down
11 changes: 2 additions & 9 deletions src/hooks/useUnistyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -75,7 +69,6 @@ export const useUnistyles = () => {
return {
plugins,
theme,
layout,
contentSizeCategory
layout
}
}
9 changes: 1 addition & 8 deletions src/types/unistyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading