Commit 8ef3621f authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

update

See merge request !57
parents 1f49b78d 770bef86
...@@ -34,7 +34,8 @@ class HomePageScreen extends Component { ...@@ -34,7 +34,8 @@ class HomePageScreen extends Component {
open: false, open: false,
authView: false, authView: false,
user: this.props.user, user: this.props.user,
cartLength: 0 cartLength: 0,
banner: []
} }
} }
...@@ -76,6 +77,15 @@ class HomePageScreen extends Component { ...@@ -76,6 +77,15 @@ class HomePageScreen extends Component {
}) })
} }
getBanner() {
Api.create().getBanner().then((response) => {
if (response.data.status == 'success') {
this.setState({banner: response.data.data})
}
console.log(response.data)
})
}
drawerContent = () => { drawerContent = () => {
return ( return (
<View style={{flexDirection: 'row', height: '110%', width: '100%',}}> <View style={{flexDirection: 'row', height: '110%', width: '100%',}}>
...@@ -148,7 +158,7 @@ class HomePageScreen extends Component { ...@@ -148,7 +158,7 @@ class HomePageScreen extends Component {
_renderItem = ({item, index}) => { _renderItem = ({item, index}) => {
return ( return (
<View style={{height: '100%'}}> <View style={{height: '100%'}}>
<Image source={item} style={{width: Metrics.screenWidth, height: '100%'}}/> <Image source={{uri: item.banner_image}} style={{width: Metrics.screenWidth, height: '100%'}}/>
</View> </View>
); );
} }
...@@ -168,8 +178,8 @@ class HomePageScreen extends Component { ...@@ -168,8 +178,8 @@ class HomePageScreen extends Component {
componentDidMount() { componentDidMount() {
this.getCart() this.getCart()
this.getAppInfo() this.getAppInfo()
this.getBanner()
if (this.state.user == null) { if (this.state.user == null) {
this.setState({authView: true}) this.setState({authView: true})
} }
BackHandler.addEventListener("hardwareBackPress", this.backAction); BackHandler.addEventListener("hardwareBackPress", this.backAction);
...@@ -214,7 +224,7 @@ class HomePageScreen extends Component { ...@@ -214,7 +224,7 @@ class HomePageScreen extends Component {
> >
<View style={{marginBottom: -15}}> <View style={{marginBottom: -15}}>
<View style={{zIndex: 1, flexGrow: 1, alignItems: 'center', width: '100%', elevation: this.state.opacity == 1? 10 : 0, position: 'absolute', top: 0, paddingBottom: 10, paddingHorizontal: 25, paddingTop: this.state.open? STATUSBAR_HEIGHT - 10 : STATUSBAR_HEIGHT + 25, flexDirection: 'row', justifyContent: 'space-between', backgroundColor:`rgba(255, 255, 255, ${this.state.opacity})`}}> <View style={{zIndex: 1, flexGrow: 1, alignItems: 'center', width: '100%', elevation: this.state.opacity == 1? 10 : 0, position: 'absolute', top: 0, paddingBottom: 10, paddingHorizontal: 25, paddingTop: this.state.open? STATUSBAR_HEIGHT - 10 : STATUSBAR_HEIGHT + 25, flexDirection: 'row', justifyContent: 'space-between', backgroundColor:`rgba(255, 255, 255, ${this.state.opacity})`}}>
<TouchableOpacity onPress={() => this.setState({open: true})} style={{width: '10%'}}> <TouchableOpacity onPress={() => this.setState({open: true})} style={{width: '15%'}}>
<FontAwesome name="bars" size={20} color={this.state.opacity >= .5? '#e3e3e3' : '#FFF'}/> <FontAwesome name="bars" size={20} color={this.state.opacity >= .5? '#e3e3e3' : '#FFF'}/>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={{width: '70%', elevation: this.state.opacity == 1? 0 : 5, alignItems:'center', flexDirection: 'row', paddingVertical: 12, paddingHorizontal: 15, backgroundColor: this.state.opacity >= .5? '#f1f1f1' : '#FFF', borderRadius: 25}} onPress={()=> this.props.navigation.navigate('ListSearchScreen')}> <TouchableOpacity style={{width: '70%', elevation: this.state.opacity == 1? 0 : 5, alignItems:'center', flexDirection: 'row', paddingVertical: 12, paddingHorizontal: 15, backgroundColor: this.state.opacity >= .5? '#f1f1f1' : '#FFF', borderRadius: 25}} onPress={()=> this.props.navigation.navigate('ListSearchScreen')}>
...@@ -237,20 +247,20 @@ class HomePageScreen extends Component { ...@@ -237,20 +247,20 @@ class HomePageScreen extends Component {
<View style={{height: 450, width: '100%', backgroundColor:'white'}}> <View style={{height: 450, width: '100%', backgroundColor:'white'}}>
<Carousel <Carousel
ref={(c) => { this._carousel = c; }} ref={(c) => { this._carousel = c; }}
data={this.state.bannerDummy} data={this.state.banner}
renderItem={this._renderItem} renderItem={this._renderItem}
sliderWidth={Metrics.screenWidth} sliderWidth={Metrics.screenWidth}
itemWidth={Metrics.screenWidth} itemWidth={Metrics.screenWidth}
autoplay={true} autoplay={true}
loop={true} loop={true}
loopClonesPerSide={this.state.bannerDummy.length} loopClonesPerSide={this.state.banner.length}
// layout={'stack'} // layout={'stack'}
onSnapToItem={(index) => this.setState({ activeSlide: index }) } onSnapToItem={(index) => this.setState({ activeSlide: index }) }
/> />
</View> </View>
<View style={{width: '100%', backgroundColor:'transparent', marginTop: -100}}> <View style={{width: '100%', backgroundColor:'transparent', marginTop: -100}}>
{this.state.bannerDummy.length > 0 && <View style={{ backgroundColor:'transparent', alignItems:'center', width: "100%", padding: 20, flexDirection: 'row', justifyContent: 'center',}}> {this.state.banner.length > 0 && <View style={{ backgroundColor:'transparent', alignItems:'center', width: "100%", padding: 20, flexDirection: 'row', justifyContent: 'center',}}>
{this.state.bannerDummy.map((item, index) => { {this.state.banner.map((item, index) => {
return( return(
<View key={index} style={{backgroundColor: this.state.activeSlide == index? '#4cc9f0' : '#e6e6e6', width: this.state.activeSlide == index? 10 : 5, height: this.state.activeSlide == index? 10 : 5, borderRadius: 10, marginLeft: index == 0? 0 : 10}}/> <View key={index} style={{backgroundColor: this.state.activeSlide == index? '#4cc9f0' : '#e6e6e6', width: this.state.activeSlide == index? 10 : 5, height: this.state.activeSlide == index? 10 : 5, borderRadius: 10, marginLeft: index == 0? 0 : 10}}/>
) )
......
...@@ -66,6 +66,13 @@ class MyAccountScreen extends Component { ...@@ -66,6 +66,13 @@ class MyAccountScreen extends Component {
} else if (type == 'Kata Sandi') { } else if (type == 'Kata Sandi') {
this.props.navigation.navigate('ChangePasswordScreen'); this.props.navigation.navigate('ChangePasswordScreen');
} else if (type == 'Keluar') { } else if (type == 'Keluar') {
Alert.alert("Konfirmasi", "Apakah anda yakin ingin keluar?", [
{
text: "Tidak",
onPress: () => null,
style: "cancel"
},
{ text: "Ya", onPress: () => {
this.props.authClearData() this.props.authClearData()
Api.create().logout(this.props.auth.user.data.user_id).then((response) => { Api.create().logout(this.props.auth.user.data.user_id).then((response) => {
// console.log(response.data) // console.log(response.data)
...@@ -91,6 +98,8 @@ class MyAccountScreen extends Component { ...@@ -91,6 +98,8 @@ class MyAccountScreen extends Component {
}); });
AsyncStorage.clear() AsyncStorage.clear()
this.props.navigation.dispatch(resetAction); this.props.navigation.dispatch(resetAction);
} }
]);
} else { } else {
} }
......
...@@ -76,6 +76,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -76,6 +76,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const topUpWallet = (body) => api.post('topup_wallet', body) const topUpWallet = (body) => api.post('topup_wallet', body)
const getPaymentMethod = () => api.get('get_payment_method') const getPaymentMethod = () => api.get('get_payment_method')
const getAllKupon = () => api.get('get_all_coupon') const getAllKupon = () => api.get('get_all_coupon')
const getBanner = () => api.get('get_banner')
// Order // Order
const createOrder = (body) => api.post('create_order', body) const createOrder = (body) => api.post('create_order', body)
...@@ -211,7 +212,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -211,7 +212,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
cancelOrder, cancelOrder,
getCancelReasonOrder, getCancelReasonOrder,
getOrderStatus, getOrderStatus,
getAllKupon getAllKupon,
getBanner
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment