-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement styleTransition #6479
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
Closed
Closed
Changes from 29 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
31f524f
Support for opacity
Latropos 05a2400
Include border Radius
Latropos 5c8ae5a
support color
Latropos 9499ddf
Include string
Latropos 23f19f2
Support for more properties
Latropos d1d6875
Refactor
Latropos 1c7e492
format
Latropos cd10dd9
border widths
Latropos a5c8fec
Refactor
Latropos 0fc1843
Refactor of string properties
Latropos 409626f
Type fix
Latropos 168ccfd
Type fix
Latropos 1478e75
Merge branch 'main' into acynk/style-transition
Latropos f1829f4
Fix cpp lint
Latropos 48e7ffb
Revert logs
Latropos 8f92304
Fix for Android
Latropos 7328b44
Final touches
Latropos 90c465a
Don't use magic numbers
Latropos 2c61a8e
Merge branch 'main' into acynk/style-transition
Latropos f88cf6c
Support for border color animation
Latropos f7b670c
Add support for transform
Latropos edbb841
Merge branch 'main' into acynk/style-transition
Latropos 75a434b
Add hardcoded prop
Latropos 78ff314
Style transition
Latropos 311d8af
Unify
Latropos a3ebb4f
Manual merge
Latropos 423b2d6
Fix merge
Latropos 35a02ff
Type fix
Latropos 5f90644
Refactor
Latropos f281a45
Format
Latropos 9632d52
Basic review resolve
Latropos 0c20c71
More review changes
Latropos ee7837c
Rework types
Latropos 87d16c8
Merge
Latropos addb9a6
Refactor
Latropos ca5d3b5
Make the code build again
Latropos 12927a3
Fix for paper
Latropos 51e1afb
Make it build on paper android
Latropos 0280850
Remove unnecessary imports and format
Latropos 1e57f5f
Fix current and targer
Latropos 358b97f
Fix warning
Latropos cd3be55
Remove unnexessary librasries
Latropos ace4820
Include utility
Latropos 19c867f
lint
Latropos 9eac147
Merge branch 'main' into acynk/style-transition
Latropos 0303d00
Merge branch 'main' into acynk/style-transition
Latropos f764fb5
Fix for border Radius on RN>76
Latropos 2751a58
Format
Latropos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
apps/common-app/src/examples/LayoutAnimations/BasicStyleTransition.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import Animated, { LinearStyleTransition } from 'react-native-reanimated'; | ||
| import { Button, StyleSheet, View } from 'react-native'; | ||
| import React from 'react'; | ||
| import { SelectorRow } from '../commonComponents/RowButtonSelector'; | ||
|
|
||
| export default function BasicLayoutAnimation() { | ||
| const [currentStyleIdx, setCurrentStyleIdx] = React.useState(0); | ||
| const [useLayout, setUseLayout] = React.useState(true); | ||
|
|
||
| const viewStyles = [ | ||
| styles.googleColors, | ||
| styles.rainDrop, | ||
| styles.leaf, | ||
| styles.squareFrame, | ||
| styles.arcFrame, | ||
| ]; | ||
|
|
||
| function incrementStyle() { | ||
| let newStyleIdx = currentStyleIdx + 1; | ||
| if (newStyleIdx >= viewStyles.length) { | ||
| newStyleIdx = 0; | ||
| } | ||
| setCurrentStyleIdx(newStyleIdx); | ||
| } | ||
|
|
||
| const transitionProp = useLayout | ||
| ? { layout: LinearStyleTransition.duration(1000) } | ||
| : { styleTransition: LinearStyleTransition.duration(1000) }; | ||
|
|
||
| return ( | ||
| <View style={styles.container}> | ||
| <SelectorRow | ||
| firstButtonLabel="Layout Transition" | ||
| secondButtonLabel=" Style Transition" | ||
| selectedFirstButton={useLayout} | ||
| setSelectedFirstButton={setUseLayout} | ||
| /> | ||
|
|
||
| <Button onPress={incrementStyle} title="Update" /> | ||
| <Animated.View | ||
| {...transitionProp} | ||
| style={[styles.box, viewStyles[currentStyleIdx]]} | ||
| /> | ||
| <View style={[styles.box, viewStyles[currentStyleIdx]]} /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| googleColors: { | ||
| borderTopColor: 'orangered', | ||
| borderLeftColor: 'gold', | ||
| borderBottomColor: 'green', | ||
| borderRightColor: 'dodgerblue', | ||
| borderRadius: 100, | ||
| borderWidth: 40, | ||
| }, | ||
| rainDrop: { | ||
| borderWidth: 60, | ||
| borderTopWidth: 40, | ||
| borderLeftWidth: 40, | ||
| borderRadius: 100, | ||
| borderTopLeftRadius: 0, | ||
| borderColor: 'deepskyblue', | ||
| backgroundColor: 'skyblue', | ||
| width: 150, | ||
| height: 150, | ||
| transform: [{ translateX: 40 }, { rotateZ: '45deg' }], | ||
| }, | ||
| leaf: { | ||
| borderWidth: 60, | ||
| borderTopWidth: 50, | ||
| borderLeftWidth: 50, | ||
| borderTopLeftRadius: 90, | ||
| borderBottomRightRadius: 100, | ||
| borderColor: 'darkgreen', | ||
| borderBottomColor: 'green', // on Android this is overwritten with borderColor | ||
| borderRightColor: 'green', | ||
| backgroundColor: 'lime', | ||
| transform: [{ rotateZ: '30deg' }, { translateX: 40 }], | ||
| }, | ||
| squareFrame: { | ||
| borderWidth: 40, | ||
| borderColor: 'goldenrod', | ||
| borderBlockColor: 'darkgoldenrod', // on Android this looks different than on IOS, both the transform and borders | ||
| transform: [{ matrix: [1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1] }], | ||
| }, | ||
| arcFrame: { | ||
| borderRadius: 20, | ||
| borderTopRightRadius: 80, | ||
| borderTopLeftRadius: 80, | ||
| borderWidth: 40, | ||
| borderBottomWidth: 60, | ||
| borderTopWidth: 10, | ||
| borderColor: 'goldenrod', | ||
| borderBlockEndColor: 'darkgoldenrod', | ||
| borderBlockStartColor: 'darkgoldenrod', | ||
| transform: [ | ||
| { matrix: [0.5, 5, 0, 0, -1, 0.5, 0, 0, 0, 0, 1, 0, 100, 100, 100, 4] }, | ||
| ], | ||
| }, | ||
|
|
||
| container: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| }, | ||
| box: { | ||
| width: 200, | ||
| height: 200, | ||
| opacity: 0.5, | ||
| margin: 50, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
apps/common-app/src/examples/commonComponents/RowButtonSelector.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import React from 'react'; | ||
| import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; | ||
|
|
||
| const NAVY = '#001A72'; | ||
|
|
||
| export function SelectorRow({ | ||
| firstButtonLabel, | ||
| secondButtonLabel, | ||
| selectedFirstButton, | ||
| setSelectedFirstButton, | ||
| }: { | ||
| firstButtonLabel: string; | ||
| secondButtonLabel: string; | ||
| selectedFirstButton: boolean; | ||
| setSelectedFirstButton: (selectedFirstButton: boolean) => void; | ||
| }) { | ||
| return ( | ||
| <View style={styles.buttonRow}> | ||
| <TouchableOpacity | ||
| style={ | ||
| selectedFirstButton ? styles.selectedButton : styles.notSelectedButton | ||
| } | ||
| onPress={() => setSelectedFirstButton(true)}> | ||
| <Text | ||
| style={ | ||
| selectedFirstButton | ||
| ? styles.selectedButtonText | ||
| : styles.notSelectedButtonText | ||
| }> | ||
| {firstButtonLabel} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| <TouchableOpacity | ||
| style={ | ||
| !selectedFirstButton | ||
| ? styles.selectedButton | ||
| : styles.notSelectedButton | ||
| } | ||
| onPress={() => setSelectedFirstButton(false)}> | ||
| <Text | ||
| style={ | ||
| !selectedFirstButton | ||
| ? styles.selectedButtonText | ||
| : styles.notSelectedButtonText | ||
| }> | ||
| {secondButtonLabel} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| buttonRow: { | ||
| flexDirection: 'row', | ||
| height: 40, | ||
| width: '80%', | ||
| margin: 20, | ||
| marginBottom: 0, | ||
| borderWidth: 2, | ||
| borderColor: NAVY, | ||
| }, | ||
| selectedButton: { | ||
| backgroundColor: NAVY, | ||
| width: '50%', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| }, | ||
| notSelectedButton: { | ||
| backgroundColor: 'white', | ||
| width: '50%', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| }, | ||
| selectedButtonText: { | ||
| color: 'white', | ||
| fontSize: 20, | ||
| }, | ||
| notSelectedButtonText: { | ||
| color: NAVY, | ||
| fontSize: 20, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.