react-native-platform-components 0.8.1 → 0.8.2
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/README.md +137 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ pod install
|
|
|
91
91
|
|
|
92
92
|
- Uses native Android Views with Material Design (including `PopupMenu` for context menus)
|
|
93
93
|
- Supports **Material 3** styling
|
|
94
|
-
-
|
|
94
|
+
- **⚠️ Your app may crash if theme is not configured** — See [Android Theme Configuration](#android-theme-configuration) below
|
|
95
95
|
|
|
96
96
|
### Expo (Managed Workflow)
|
|
97
97
|
|
|
@@ -702,6 +702,142 @@ This is intentional. The goal is native fidelity, not pixel-level customization.
|
|
|
702
702
|
|
|
703
703
|
---
|
|
704
704
|
|
|
705
|
+
## Android Theme Configuration
|
|
706
|
+
|
|
707
|
+
> **⚠️ Your app may hard crash if you skip this section.** Android components require specific theme configuration. Components can crash immediately on mount if the required theme attributes are missing.
|
|
708
|
+
|
|
709
|
+
### Theme Requirements by Component
|
|
710
|
+
|
|
711
|
+
| Component | Mode | Required Theme | Crash if Missing |
|
|
712
|
+
| -------------------- | ---------------------------- | ------------------- | ---------------- |
|
|
713
|
+
| **SegmentedControl** | (always M3) | `Theme.Material3.*` | ✅ Yes |
|
|
714
|
+
| **DatePicker** | `android.material: 'm3'` | `Theme.Material3.*` | ✅ Yes |
|
|
715
|
+
| **DatePicker** | `android.material: 'system'` | `Theme.AppCompat.*` | ✅ Yes |
|
|
716
|
+
| **SelectionMenu** | `android.material: 'm3'` | `Theme.Material3.*` | ✅ Yes |
|
|
717
|
+
| **SelectionMenu** | `android.material: 'system'` | `Theme.AppCompat.*` | ✅ Yes |
|
|
718
|
+
| **ContextMenu** | — | Any | ❌ No |
|
|
719
|
+
| **LiquidGlass** | — | Any | ❌ No |
|
|
720
|
+
|
|
721
|
+
### Material 3 Theme Setup (Required for SegmentedControl)
|
|
722
|
+
|
|
723
|
+
`SegmentedControl` always uses Material 3 widgets (`MaterialButtonToggleGroup`). Your app **must** use a Material 3 theme or the app will crash on component mount.
|
|
724
|
+
|
|
725
|
+
**1. Update your app theme in `android/app/src/main/res/values/styles.xml`:**
|
|
726
|
+
|
|
727
|
+
```xml
|
|
728
|
+
<resources>
|
|
729
|
+
<!-- Base application theme - MUST inherit from Material3 -->
|
|
730
|
+
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
|
|
731
|
+
<!-- Material 3 requires these color attributes -->
|
|
732
|
+
<item name="colorPrimary">@color/md_theme_primary</item>
|
|
733
|
+
<item name="colorOnPrimary">@color/md_theme_onPrimary</item>
|
|
734
|
+
<item name="colorPrimaryContainer">@color/md_theme_primaryContainer</item>
|
|
735
|
+
<item name="colorOnPrimaryContainer">@color/md_theme_onPrimaryContainer</item>
|
|
736
|
+
<item name="colorSecondary">@color/md_theme_secondary</item>
|
|
737
|
+
<item name="colorOnSecondary">@color/md_theme_onSecondary</item>
|
|
738
|
+
<item name="colorSecondaryContainer">@color/md_theme_secondaryContainer</item>
|
|
739
|
+
<item name="colorOnSecondaryContainer">@color/md_theme_onSecondaryContainer</item>
|
|
740
|
+
<item name="colorTertiary">@color/md_theme_tertiary</item>
|
|
741
|
+
<item name="colorOnTertiary">@color/md_theme_onTertiary</item>
|
|
742
|
+
<item name="colorBackground">@color/md_theme_background</item>
|
|
743
|
+
<item name="colorOnBackground">@color/md_theme_onBackground</item>
|
|
744
|
+
<item name="colorSurface">@color/md_theme_surface</item>
|
|
745
|
+
<item name="colorOnSurface">@color/md_theme_onSurface</item>
|
|
746
|
+
<item name="colorError">@color/md_theme_error</item>
|
|
747
|
+
<item name="colorOnError">@color/md_theme_onError</item>
|
|
748
|
+
</style>
|
|
749
|
+
</resources>
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**2. Define your Material 3 colors in `android/app/src/main/res/values/colors.xml`:**
|
|
753
|
+
|
|
754
|
+
```xml
|
|
755
|
+
<resources>
|
|
756
|
+
<!-- Generate these using Material Theme Builder: https://m3.material.io/theme-builder -->
|
|
757
|
+
<color name="md_theme_primary">#6750A4</color>
|
|
758
|
+
<color name="md_theme_onPrimary">#FFFFFF</color>
|
|
759
|
+
<color name="md_theme_primaryContainer">#EADDFF</color>
|
|
760
|
+
<color name="md_theme_onPrimaryContainer">#21005D</color>
|
|
761
|
+
<color name="md_theme_secondary">#625B71</color>
|
|
762
|
+
<color name="md_theme_onSecondary">#FFFFFF</color>
|
|
763
|
+
<color name="md_theme_secondaryContainer">#E8DEF8</color>
|
|
764
|
+
<color name="md_theme_onSecondaryContainer">#1D192B</color>
|
|
765
|
+
<color name="md_theme_tertiary">#7D5260</color>
|
|
766
|
+
<color name="md_theme_onTertiary">#FFFFFF</color>
|
|
767
|
+
<color name="md_theme_background">#FFFBFE</color>
|
|
768
|
+
<color name="md_theme_onBackground">#1C1B1F</color>
|
|
769
|
+
<color name="md_theme_surface">#FFFBFE</color>
|
|
770
|
+
<color name="md_theme_onSurface">#1C1B1F</color>
|
|
771
|
+
<color name="md_theme_error">#B3261E</color>
|
|
772
|
+
<color name="md_theme_onError">#FFFFFF</color>
|
|
773
|
+
</resources>
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
> **Tip:** Use Google's [Material Theme Builder](https://m3.material.io/theme-builder) to generate a complete color scheme.
|
|
777
|
+
|
|
778
|
+
### Common Crash Scenarios
|
|
779
|
+
|
|
780
|
+
#### Crash: `Cannot find theme attribute materialButtonOutlinedStyle`
|
|
781
|
+
|
|
782
|
+
**Cause:** Using `SegmentedControl` without a Material 3 theme.
|
|
783
|
+
|
|
784
|
+
**Fix:** Update your theme to inherit from `Theme.Material3.*`:
|
|
785
|
+
|
|
786
|
+
```xml
|
|
787
|
+
<!-- Change this -->
|
|
788
|
+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
|
789
|
+
|
|
790
|
+
<!-- To this -->
|
|
791
|
+
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
#### Crash: `You need to use a Theme.AppCompat theme`
|
|
795
|
+
|
|
796
|
+
**Cause:** Using `DatePicker` or `SelectionMenu` with `android.material: 'system'` while not extending AppCompat.
|
|
797
|
+
|
|
798
|
+
**Fix:** Ensure your theme inherits from `Theme.AppCompat.*` or `Theme.Material3.*` (which extends AppCompat), and your `MainActivity` extends `AppCompatActivity`.
|
|
799
|
+
|
|
800
|
+
### Mode Selection Guide
|
|
801
|
+
|
|
802
|
+
Choose the appropriate mode based on your app's theme:
|
|
803
|
+
|
|
804
|
+
```tsx
|
|
805
|
+
// If your app uses Theme.Material3.* (recommended)
|
|
806
|
+
<DatePicker android={{ material: 'm3' }} />
|
|
807
|
+
<SelectionMenu android={{ material: 'm3' }} />
|
|
808
|
+
<SegmentedControl /> // Always M3
|
|
809
|
+
|
|
810
|
+
// If your app uses Theme.AppCompat.*
|
|
811
|
+
<DatePicker android={{ material: 'system' }} />
|
|
812
|
+
<SelectionMenu android={{ material: 'system' }} />
|
|
813
|
+
// ⚠️ SegmentedControl will crash - upgrade to Material 3
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Expo Configuration
|
|
817
|
+
|
|
818
|
+
For Expo projects, the config plugin can configure your theme automatically. Add to `app.json`:
|
|
819
|
+
|
|
820
|
+
```json
|
|
821
|
+
{
|
|
822
|
+
"expo": {
|
|
823
|
+
"plugins": [
|
|
824
|
+
[
|
|
825
|
+
"react-native-platform-components/app.plugin",
|
|
826
|
+
{
|
|
827
|
+
"android": {
|
|
828
|
+
"theme": "material3"
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
]
|
|
832
|
+
]
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
Then run `npx expo prebuild` to apply the configuration.
|
|
838
|
+
|
|
839
|
+
---
|
|
840
|
+
|
|
705
841
|
## Icons
|
|
706
842
|
|
|
707
843
|
ContextMenu supports icons on menu items. Icons are specified by name and resolved differently on each platform.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-platform-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Native UI components for React Native: DatePicker, ContextMenu, SelectionMenu, SegmentedControl, LiquidGlass.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|