-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement useBottomTabBarHeight (#158)
* feat: implement useBottomTabBarHeight * docs(changeset): feat: add useBottomTabBarHeight() hook * feat: add events for old arch * feat: add docs
- Loading branch information
1 parent
153f5f7
commit 51c523b
Showing
17 changed files
with
308 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'react-native-bottom-tabs': patch | ||
--- | ||
|
||
feat: add useBottomTabBarHeight() hook |
This file contains 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 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,75 @@ | ||
import * as React from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
|
||
type MusicControlProps = { | ||
bottomOffset: number; | ||
}; | ||
|
||
export const MusicControl: React.FC<MusicControlProps> = ({ bottomOffset }) => { | ||
return ( | ||
<View | ||
style={[ | ||
styles.musicControlContainer, | ||
{ | ||
bottom: bottomOffset + 10, | ||
}, | ||
]} | ||
> | ||
<View style={styles.musicControlContent}> | ||
<View style={styles.songInfo}> | ||
<Text style={styles.songTitle} numberOfLines={1}> | ||
Currently Playing Song | ||
</Text> | ||
</View> | ||
<View style={styles.controls}> | ||
<Text style={styles.controlButton}>⏸</Text> | ||
<Text style={styles.controlButton}>⏭</Text> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
musicControlContainer: { | ||
position: 'absolute', | ||
left: 15, | ||
right: 15, | ||
borderRadius: 18, | ||
height: 55, | ||
backgroundColor: '#fff', | ||
shadowColor: '#000', | ||
shadowOffset: { | ||
width: 0, | ||
height: 4, | ||
}, | ||
shadowOpacity: 0.25, | ||
shadowRadius: 5, | ||
elevation: 8, | ||
}, | ||
musicControlContent: { | ||
flex: 1, | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingHorizontal: 16, | ||
paddingVertical: 8, | ||
}, | ||
songInfo: { | ||
flex: 1, | ||
marginRight: 16, | ||
}, | ||
songTitle: { | ||
fontSize: 14, | ||
fontWeight: '600', | ||
color: '#000', | ||
}, | ||
controls: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}, | ||
controlButton: { | ||
fontSize: 24, | ||
paddingHorizontal: 12, | ||
color: '#000', | ||
}, | ||
}); |
This file contains 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 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 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
36 changes: 36 additions & 0 deletions
36
packages/react-native-bottom-tabs/ios/Events/TabBarMeasuredEvent.swift
This file contains 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,36 @@ | ||
import React | ||
|
||
@objc public class TabBarMeasuredEvent: NSObject, RCTEvent { | ||
private var height: NSInteger | ||
@objc public var viewTag: NSNumber | ||
@objc public var coalescingKey: UInt16 | ||
|
||
@objc public var eventName: String { | ||
return "onTabBarMeasured" | ||
} | ||
|
||
@objc public init(reactTag: NSNumber, height: NSInteger, coalescingKey: UInt16) { | ||
self.viewTag = reactTag | ||
self.height = height | ||
self.coalescingKey = coalescingKey | ||
super.init() | ||
} | ||
|
||
@objc public func canCoalesce() -> Bool { | ||
return false | ||
} | ||
|
||
@objc public class func moduleDotMethod() -> String { | ||
return "RCTEventEmitter.receiveEvent" | ||
} | ||
|
||
@objc public func arguments() -> [Any] { | ||
return [ | ||
viewTag, | ||
RCTNormalizeInputEventName(eventName) ?? eventName, | ||
[ | ||
"height": height | ||
] | ||
] | ||
} | ||
} |
This file contains 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 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 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 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.