-
Notifications
You must be signed in to change notification settings - Fork 127
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
React-native-web compatibility + typescript typings #73
Changes from all commits
387fa8f
eb37efb
c6117eb
335b7a3
53c8c55
41bf747
e527923
82a2211
ef0a07f
7081b57
22b3c2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ViewStyle, TextStyle } from 'react-native'; | ||
declare module 'react-native-material-bottom-navigation' { | ||
export interface BottomNavigationProps { | ||
activeTab?: number; | ||
labelColor?: string; | ||
activeLabelColor?: string; | ||
rippleColor?: string; | ||
backgroundColor?: string; | ||
onTabChange?: (newTabIndex: number, oldTabIndex: number) => void; | ||
style?: ViewStyle; | ||
innerStyle?: ViewStyle; | ||
shifting?: boolean; | ||
} | ||
|
||
export interface TabProps { | ||
icon?: JSX.Element; | ||
activeIcon?: JSX.Element; | ||
label?: JSX.Element | string; | ||
labelColor?: string; | ||
activeLabelColor?: string; | ||
barBackgroundColor?: string; | ||
onPress?: (newTabIndex?: number) => void; | ||
badgeText?: JSX.Element | string; | ||
badgeSize?: number; | ||
badgeStyle?: { | ||
container?: ViewStyle, | ||
text?: TextStyle | ||
}; | ||
isBadgeVisible?: boolean; | ||
} | ||
|
||
export class BottomNavigation extends React.Component<BottomNavigationProps> { } | ||
export class Tab extends React.Component<TabProps> { } | ||
export default BottomNavigation; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,11 +299,12 @@ const styles = StyleSheet.create({ | |
flex: 1, | ||
alignItems: 'center', | ||
paddingTop: 8, | ||
paddingBottom: 10, | ||
paddingBottom: (Platform.OS !== 'web' ? 10 : 0), | ||
paddingLeft: 12, | ||
paddingRight: 12, | ||
backgroundColor: 'transparent', | ||
position: "relative", | ||
...(Platform.OS !== 'web' ? {} : { transition: '0.5s all' }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a comment, no change request: Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah good point. Let's hope phone users will stick with mobile app then :D I think to avoid the problem, it would probably have to be some width based approach which would definitely be harder to maintain or follow. I'll do some testing on a phone later on though just to check. I think by design, bottom bar should be 5 items or less, right? Wondering if that's "good enough" for performance. Or if it doesn't matter and it will have problems no matter the count of animated objects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A method to make very smooth animations on web is FLIP. Here's the original article by Paul Lewis: https://aerotwist.com/blog/flip-your-animations/ I think for the scope of this PR, using |
||
}, | ||
shiftingInactiveContainer: { | ||
maxWidth: 96, | ||
|
@@ -322,7 +323,7 @@ const styles = StyleSheet.create({ | |
fontSize: 14, | ||
width: 168, | ||
textAlign: 'center', | ||
includeFontPadding: false, | ||
...(Platform.OS !== 'web' ? { includeFontPadding: false } : {}), | ||
textAlignVertical: 'center', | ||
justifyContent: 'flex-end', | ||
backgroundColor: 'transparent', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web sets overflow hidden for all texts and there's not enough room to display it properly. This looks a bit odd but works