【水滴石穿】bstmy-blend-app

该博客介绍了一个简单的底部导航切换页面项目,项目地址为https://github.com/Bstmy/bstmy - blend - app,点击首页和个人中心可切换对应页面,作者对部分代码控制页面切换的原理存疑,项目转载自https://www.cnblogs.com/smart - girl/p/10882254.html。

这个项目是一个简单的底部导航切换页面
项目的地址为:https://github.com/Bstmy/bstmy-blend-app
先看效果
1037363-20190517163537310-1724090901.png
点击首页是首页面,点击个人中心是个人中心页面
先看代码

//index.js
//引用的是根app.js
import {AppRegistry} from 'react-native';
import App from './app/App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
//app/App.js
//这个里面不仅有防止闪屏的,还有倒计时为3的启动页,还有定义了首页
import React, { Component } from 'react';
//闪屏
import SplashScreen from 'react-native-splash-screen';
//导航
import {createAppContainer, createStackNavigator} from 'react-navigation';

//显示首页
import Home from "./Home";
//这个是很好看的启动页很美腻
import GuideView from "./guide/GuideView";
const RootStack = createStackNavigator(
    {
        homes: Home,
        guideView: GuideView
    },
    {
        initialRouteName: 'guideView'   ,
        defaultNavigationOptions: {
            headerStyle: {
                backgroundColor: '#f4511e',
                height:0,
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
        },
    }
);
const AppContainer = createAppContainer(RootStack);
//定义首页
//渲染AppConta
export default class App extends Component {

    constructor(props) {
        super(props);
        SplashScreen.hide(); // 关闭启动屏幕
    }

    render() {
        return (
            <AppContainer />
        );
    }

}
//app/guide/GuideView.js
//配置的启动页
import React, {Component} from 'react';
import {
    Image,
    StyleSheet,
    View,
    Text
} from 'react-native';
import Swiper from 'react-native-swiper';
import AutoSize from '../utils/AutoSize';
class GuideView extends Component {
    constructor() {
        super();
        this.state = { invertedTime: 5 };
    }
    componentDidMount() {
        this.timer1=setInterval(() => {
            this.setState(previousState => {
                return {invertedTime: (previousState.invertedTime-1)};
            })
            console.log("启动倒计时"+this.state.invertedTime );
            if(this.state.invertedTime == 0){
                this.openHomePage();
                clearInterval(this.timer1)
            }
        } ,1000);
    }
    openHomePage(){
        this.props.navigation.navigate('homes');
    }

    //卸载计时器
    componentWillUnmount() {
        this.timer1 && clearInterval(this.timer1);
    }
    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.next} onPress={this.openHomePage.bind(this)}>{this.state.invertedTime}</Text>
                <Swiper style={styles.wrapper}
                    showsButtons={false}       //为false时不显示控制按钮
                    paginationStyle={{      //小圆点位置
                        bottom: 30
                    }}
                    loop={true}        //如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
                    autoplay={true}          //自动轮播
                    autoplayTimeout={3}      //每隔3秒切换
                    >
                    <Image style={styles.image} source={require('../img/guide/geoude2.jpg')}/>
                    <Image style={styles.image} source={require('../img/guide/geoude3.jpg')}/>
                    <Image style={styles.image} source={require('../img/guide/geoude1.jpg')}/>
                </Swiper>
            </View>
        );
    }
};

let styles = StyleSheet.create({
    container: {
        flex: 1,//必写
        flexDirection: 'column',
    },
    image: {
        width:AutoSize.size.width,//等于width:width
        height:AutoSize.size.height,
    },
    next:{
        width: 30,
        height: 30,
        borderRadius:15,
        fontSize:15,
        textAlign:"center",
        textAlignVertical: 'center',
        backgroundColor: "#D4237A",
        zIndex:1,
        position: 'absolute',
        color:"#fff",
        right: 20,
        top: 20,
    }
});

export default GuideView;
//app/utils/AutoSize.js
//这个里面进行的就是屏幕适配
import React from 'react';
import Dimensions from 'Dimensions';

const AutoSize = {
    size: {
        width: Dimensions.get('window').width,
        height: Dimensions.get('window').height
    },
};

export default AutoSize;
//app/route/RootStack.js
//定义的是首页
import { createStackNavigator } from 'react-navigation';
import Home from '../Home'
import GuideView from '../guide/GuideView'
export const RootStack = createStackNavigator(
    {
        home: Home,
        guideView: GuideView,
    },
    {
        initialRouteName: 'guideView',
        defaultNavigationOptions: {
            headerStyle: {
                backgroundColor: '#f4511e',
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
                fontWeight: 'bold',
            },
        },
    }
);
//和index页面类似,不过具体怎么控制的?
//app/pages/User.js
import React, { Component } from 'react';

import {
    View,
    Text
} from 'react-native';

class User extends Component {

    render() {
        return (
            <View>

                <Text>
                    我是用户
                </Text>

            </View>
        );
    }
}

export default User;

上面有一点点的不理解
不知道是什么控制的切换的页面的,因为那个是同时引用的
不过这个项目我喜欢~~哭唧唧,在这个水平这里~~

转载于:https://www.cnblogs.com/smart-girl/p/10882254.html

### CSS `mix-blend-mode` 属性详解 #### 一、什么是 `mix-blend-mode` CSS 属性 `mix-blend-mode` 描述了设置元素与其直接父元素的背景如何混合,通过不同的属性值,可以创建诸如叠加、滤色等多种视觉效果[^1]。 #### 二、支持的属性值及其作用 该属性接受多种模式作为其取值,每种模式都定义了一种特定的方式让两个图层相互影响: - **normal**: 默认值。无特殊混合行为。 - **multiply** (正片叠底): 结果颜色不会比原颜色更亮。黑色乘任何色都是黑;白色则保持不变。 - **screen** (屏幕): 效果正好相反于 multiply。结果总是较浅的颜色。 - **overlay** (叠加): 综合了 multiply 和 screen 的特性,取决于底层颜色是深还是浅。 - ... 更多其他选项如 darken, lighten, color-dodge 等也提供了丰富的可能性[^2]. #### 三、实例展示 为了直观感受这些不同模式带来的变化,这里给出几个简单的例子说明如何应用此属性: ##### 实现文字镂空效果 ```html <div class="backdrop"> <p class="text">Water</p> <div class="overlay"></div> </div> <style> .backdrop { position: relative; } .text { font-size: 7em; margin: 0; padding: 0; z-index: 1; } .overlay { background-color: rgba(0,255,255,.1); mix-blend-mode: multiply; /* 应用了multiply混合模式 */ width: 100%; height: 100%; position: absolute; top: 0; } </style> ``` 上述代码片段展示了当我们将一个半透明蓝色覆盖在一个文本之上并设置了 `mix-blend-mode: multiply` 后所得到的文字镂空样式[^4]。 ##### 创建双背景图像合成 另一个有趣的案例是在同一个容器内同时加载两张图片,并利用 `background-blend-mode` 来控制它们之间的交互方式: ```css .blend { height: 100vh; background-image: url('image1.jpg'), url('image2.jpg'); background-blend-mode: multiply; /* 使用multiply模式进行两幅图间的融合 */ background-size: cover; } ``` 这段样式的目的是使两张照片按照指定的比例相乘在一起形成新的色调组合[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值