Skip to content

Commit

Permalink
Merge branch 'next-6.0' of github.com:storybookjs/react-native into r…
Browse files Browse the repository at this point in the history
…aychanks/next-6.0
  • Loading branch information
Daniel committed Feb 7, 2022
2 parents ec8be56 + 8d459bd commit 7aec54d
Show file tree
Hide file tree
Showing 23 changed files with 657 additions and 276 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ With Storybook for React Native you can design and develop individual React Nati

This readme will be used for 6.0 documentation going forward, [find the 5.3 readme here](https://github.com/storybookjs/react-native/tree/v5.3.25#readme)

The 6.0 alpha is out now `6.0.1-alpha.6` to try it out follow [this guide](https://github.com/storybookjs/react-native/blob/next-6.0/v6README.md) (work in progress)
The 6.0 alpha is out now `6.0.1-alpha.7` to try it out follow [this guide](https://github.com/storybookjs/react-native/blob/next-6.0/v6README.md) (work in progress).

To try out the 6.0 alpha alongside react native web storybook you can use the expo template, [see here for more info](https://github.com/dannyhw/expo-template-storybook).

```
expo init --template expo-template-storybook AwesomeStorybook
```

For more information visit: [storybook.js.org](https://storybook.js.org)

Expand Down
4 changes: 2 additions & 2 deletions addons/ondevice-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"core-js": "^3.0.1",
"deep-equal": "^1.0.1",
"prop-types": "^15.7.2",
"react-native-modal-datetime-picker": "^10.1.0",
"react-native-modal-selector": "^2.0.2",
"react-native-modal-datetime-picker": "^13.0.1",
"react-native-modal-selector": "^2.1.0",
"tinycolor2": "^1.4.1"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion addons/ondevice-controls/src/types/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ const DateType = ({ onChange, arg: { name, value } }: DateProps) => {
setVisiblePicker('none');
};

const date = useMemo(() => new Date(value), [value]);
const date = useMemo(() => {
const dateValue = new Date(value);
if (isNaN(dateValue.valueOf())) {
return new Date();
}

return dateValue;
}, [value]);

// https://stackoverflow.com/a/30272803
const dateString = useMemo(
Expand Down
2 changes: 1 addition & 1 deletion app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"util": "^0.12.4"
},
"devDependencies": {
"@types/react-native": "^0.65.1",
"@types/react-native": "^0.66.15",
"babel-jest": "^26.6.3",
"jest": "^26.6.3",
"react-test-renderer": "17.0.2"
Expand Down
2 changes: 2 additions & 0 deletions examples/native/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
1 change: 1 addition & 0 deletions examples/native/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.4
1 change: 1 addition & 0 deletions examples/native/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java adoptopenjdk-8.0.312+7
4 changes: 4 additions & 0 deletions examples/native/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.4'
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
2 changes: 1 addition & 1 deletion examples/native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import com.android.build.OutputFile
*/

project.ext.react = [
enableHermes: false, // clean and rebuild if changing
enableHermes: true, // clean and rebuild if changing
cliPath: "../../../../node_modules/react-native/cli.js",
]

Expand Down
2 changes: 2 additions & 0 deletions examples/native/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
android:insetTop="@dimen/abc_edit_text_inset_top_material"
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
<selector>
<!--
This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
-->
<item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
<item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
</selector>
</inset>
1 change: 1 addition & 0 deletions examples/native/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>

</resources>
13 changes: 8 additions & 5 deletions examples/native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ buildscript {

allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../../node_modules/react-native/android")
Expand All @@ -31,9 +29,14 @@ allprojects {
// Android JSC is installed from npm
url("$rootDir/../../../node_modules/jsc-android/dist")
}

mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { LocalisedDate } from './Date';

const date = new Date('February 25, 1983');
const date = new Date(1983, 1, 25);

const DateMeta: ComponentMeta<typeof LocalisedDate> = {
title: 'Date',
Expand Down
8 changes: 4 additions & 4 deletions examples/native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ target 'rn_example' do
config = use_native_modules!

use_react_native!(
:path => "../../../node_modules/react-native",
path: '../../../node_modules/react-native',
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
hermes_enabled: true
)

target 'rn_exampleTests' do
Expand All @@ -21,10 +21,10 @@ target 'rn_example' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
use_flipper!

post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
end
Loading

0 comments on commit 7aec54d

Please sign in to comment.