|
@@ -18,6 +18,8 @@ import apiCharge from '../../api/apiCharge';
|
|
|
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
|
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
|
|
import { toTopupPage } from '../payment/PaymentConfig';
|
|
import { toTopupPage } from '../payment/PaymentConfig';
|
|
|
import utils from '../../utils/utils';
|
|
import utils from '../../utils/utils';
|
|
|
|
|
+import apiNotification from '../../api/apiNotification';
|
|
|
|
|
+import TextRadius from '../../components/TextRadius';
|
|
|
|
|
|
|
|
const Drawer = createDrawerNavigator();
|
|
const Drawer = createDrawerNavigator();
|
|
|
|
|
|
|
@@ -29,6 +31,7 @@ export default class Home extends Component {
|
|
|
this.state = {
|
|
this.state = {
|
|
|
isLogin: false,
|
|
isLogin: false,
|
|
|
userInfo: {},
|
|
userInfo: {},
|
|
|
|
|
+ notificationCount: 0
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -45,6 +48,9 @@ export default class Home extends Component {
|
|
|
userInfo: info
|
|
userInfo: info
|
|
|
});
|
|
});
|
|
|
}, true);
|
|
}, true);
|
|
|
|
|
+ if (app.modules.notifications && this.state.isLogin) {
|
|
|
|
|
+ this.getNotificationTotal();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
/*BackHandler.addEventListener('hardwareBackPress', (e) => {
|
|
/*BackHandler.addEventListener('hardwareBackPress', (e) => {
|
|
|
if (global.dialogId !== 0) {
|
|
if (global.dialogId !== 0) {
|
|
@@ -72,6 +78,9 @@ export default class Home extends Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}, true);
|
|
}, true);
|
|
|
|
|
+ if (app.modules.notifications) {
|
|
|
|
|
+ this.getNotificationTotal();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -92,6 +101,24 @@ export default class Home extends Component {
|
|
|
Dialog.dismissLoading();
|
|
Dialog.dismissLoading();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getNotificationTotal() {
|
|
|
|
|
+ apiNotification.getUnreadTotal().then(res => {
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ notificationCount: res.data?.toBeReadCount ?? 0
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ notificationCount: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ notificationCount: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render () {
|
|
render () {
|
|
|
return (
|
|
return (
|
|
|
<Drawer.Navigator
|
|
<Drawer.Navigator
|
|
@@ -102,6 +129,7 @@ export default class Home extends Component {
|
|
|
isLogin={this.state.isLogin}
|
|
isLogin={this.state.isLogin}
|
|
|
userInfo={this.state.userInfo}
|
|
userInfo={this.state.userInfo}
|
|
|
onLogout={() => this.requestLogout()}
|
|
onLogout={() => this.requestLogout()}
|
|
|
|
|
+ notificationCount={this.state.notificationCount}
|
|
|
/>
|
|
/>
|
|
|
}
|
|
}
|
|
|
drawerType={
|
|
drawerType={
|
|
@@ -127,7 +155,7 @@ const CustomerDrawerContent = (props) => {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const DrawerContent = ({isLogin, userInfo, onLogout, navigation}) => {
|
|
|
|
|
|
|
+const DrawerContent = ({isLogin, userInfo, onLogout, notificationCount=0, navigation}) => {
|
|
|
const getCharging = () => {
|
|
const getCharging = () => {
|
|
|
Dialog.showProgressDialog();
|
|
Dialog.showProgressDialog();
|
|
|
apiCharge.getUserCharging().then(res => {
|
|
apiCharge.getUserCharging().then(res => {
|
|
@@ -320,14 +348,19 @@ const DrawerContent = ({isLogin, userInfo, onLogout, navigation}) => {
|
|
|
style={styles.itemButton}
|
|
style={styles.itemButton}
|
|
|
viewStyle={styles.itemView}
|
|
viewStyle={styles.itemView}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
- startPage(PageList.bookmarks);
|
|
|
|
|
|
|
+ startPage(PageList.notification);
|
|
|
}}>
|
|
}}>
|
|
|
<MaterialIcons
|
|
<MaterialIcons
|
|
|
style={styles.icon}
|
|
style={styles.icon}
|
|
|
- name="stars"
|
|
|
|
|
|
|
+ name="notifications"
|
|
|
color="#222"
|
|
color="#222"
|
|
|
size={26}/>
|
|
size={26}/>
|
|
|
- <Text style={styles.label}>{$t('route.bookmarks')}</Text>
|
|
|
|
|
|
|
+ <Text style={styles.label}>{$t('route.notifications')}</Text>
|
|
|
|
|
+ { notificationCount > 0 &&
|
|
|
|
|
+ notificationCount < 100
|
|
|
|
|
+ ? <TextRadius style={styles.bridgeText}>{notificationCount}</TextRadius>
|
|
|
|
|
+ : <TextRadius style={styles.bridgeText2}>99+</TextRadius>
|
|
|
|
|
+ }
|
|
|
</Button>
|
|
</Button>
|
|
|
}
|
|
}
|
|
|
{ (app.modules.bookmarks && isLogin) &&
|
|
{ (app.modules.bookmarks && isLogin) &&
|
|
@@ -679,5 +712,29 @@ const styles = StyleSheet.create({
|
|
|
color: textCancel,
|
|
color: textCancel,
|
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
|
marginRight: 32
|
|
marginRight: 32
|
|
|
|
|
+ },
|
|
|
|
|
+ bridgeText: {
|
|
|
|
|
+ width: 20,
|
|
|
|
|
+ height: 20,
|
|
|
|
|
+ color: textLight,
|
|
|
|
|
+ fontSize: 12,
|
|
|
|
|
+ lineHeight: 19,
|
|
|
|
|
+ marginRight: 16,
|
|
|
|
|
+ borderRadius: 20,
|
|
|
|
|
+ fontWeight: 'bold',
|
|
|
|
|
+ textAlign: 'center',
|
|
|
|
|
+ backgroundColor: "#FF3B30"
|
|
|
|
|
+ },
|
|
|
|
|
+ bridgeText2: {
|
|
|
|
|
+ width: 22,
|
|
|
|
|
+ height: 22,
|
|
|
|
|
+ color: textLight,
|
|
|
|
|
+ fontSize: 10,
|
|
|
|
|
+ lineHeight: 22,
|
|
|
|
|
+ marginRight: 16,
|
|
|
|
|
+ borderRadius: 22,
|
|
|
|
|
+ fontWeight: 'bold',
|
|
|
|
|
+ textAlign: 'center',
|
|
|
|
|
+ backgroundColor: "#FF3B30"
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|