Skip to content

Commit

Permalink
优化一些沉浸的细节
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Sep 5, 2019
1 parent e83bcdf commit e8385b5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
28 changes: 17 additions & 11 deletions components/status-bar-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Author: czy0729
* @Date: 2019-08-11 14:02:16
* @Last Modified by: czy0729
* @Last Modified time: 2019-09-05 19:29:28
* @Last Modified time: 2019-09-05 20:31:35
*/
import React from 'react'
import { StatusBar } from 'react-native'
Expand All @@ -17,24 +17,29 @@ function StatusBarEvents({
barStyle,
translucent,
animated,
...other
action
}) {
const events = () => {
StatusBar.setBackgroundColor(backgroundColor, animated)
StatusBar.setBarStyle(barStyle, animated)
StatusBar.setTranslucent(translucent, animated)
}
const props = {
onDidFocus: () => events()
}
if (action === 'onWillFocus') {
props.onWillFocus = () => events()
}

return (
<>
<NavigationEvents
onDidFocus={() => {
StatusBar.setBackgroundColor(backgroundColor, animated)
StatusBar.setBarStyle(barStyle, animated)
StatusBar.setTranslucent(translucent, animated)
}}
/>
<StatusBar
backgroundColor={backgroundColor}
barStyle={barStyle}
translucent={translucent}
animated={animated}
{...other}
/>
<NavigationEvents {...props} />
</>
)
}
Expand All @@ -43,7 +48,8 @@ StatusBarEvents.defaultProps = {
backgroundColor: '#ffffff',
barStyle: 'dark-content',
translucent: !IOS,
animated: IOS
animated: IOS,
action: 'onDidFocus'
}

export default StatusBarEvents
3 changes: 2 additions & 1 deletion screens/discovery/award/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: czy0729
* @Date: 2019-05-29 19:37:12
* @Last Modified by: czy0729
* @Last Modified time: 2019-09-05 16:11:34
* @Last Modified time: 2019-09-05 20:15:17
*/
import React from 'react'
import { StyleSheet, View, WebView } from 'react-native'
Expand Down Expand Up @@ -96,6 +96,7 @@ class Award extends React.Component {
<StatusBarEvents
barStyle={this.barStyle}
backgroundColor='transparent'
action='onWillFocus'
/>
{loading && (
<Loading
Expand Down
6 changes: 4 additions & 2 deletions screens/discovery/random/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-06-23 02:20:58
* @Last Modified by: czy0729
* @Last Modified time: 2019-09-05 16:33:43
* @Last Modified time: 2019-09-05 20:43:53
*/
import React from 'react'
import PropTypes from 'prop-types'
Expand All @@ -18,7 +18,9 @@ const List = (props, { $ }) => (
contentContainerStyle={_.container.bottom}
keyExtractor={item => String(item.id)}
data={$.random}
ListHeaderComponent={<StatusBarPlaceholder />}
ListHeaderComponent={
<StatusBarPlaceholder style={{ backgroundColor: _.colorBg }} />
}
renderItem={({ item }) => <Item {...item} />}
onHeaderRefresh={() => $.fetchRandom(true)}
onFooterRefresh={$.fetchRandom}
Expand Down
4 changes: 2 additions & 2 deletions screens/home/subject/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-03-23 04:16:27
* @Last Modified by: czy0729
* @Last Modified time: 2019-09-05 15:49:00
* @Last Modified time: 2019-09-05 20:36:35
*/
import React from 'react'
import { StyleSheet } from 'react-native'
Expand Down Expand Up @@ -154,7 +154,7 @@ const styles = StyleSheet.create({
top: 0,
left: 0,
right: 0,
height: _.window.height * 0.5
height: _.window.height * 0.4
},
contentContainerStyle: {
paddingTop: _.headerHeight,
Expand Down
3 changes: 2 additions & 1 deletion utils/decorators/withTransitionHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-05-01 16:57:57
* @Last Modified by: czy0729
* @Last Modified time: 2019-09-05 16:10:36
* @Last Modified time: 2019-09-05 20:10:21
*/
import React from 'react'
import { StyleSheet, View } from 'react-native'
Expand Down Expand Up @@ -191,6 +191,7 @@ const withTransitionHeader = ({
<StatusBarEvents
barStyle={barStyle}
backgroundColor='transparent'
action='onWillFocus'
/>
<ComposedComponent
navigation={navigation}
Expand Down

0 comments on commit e8385b5

Please sign in to comment.