Skip to content

Commit f7b86b1

Browse files
committed
auth view
1 parent 2179fa1 commit f7b86b1

File tree

12 files changed

+298
-65
lines changed

12 files changed

+298
-65
lines changed

source/action/user.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@ export const login = createAction(
99
},
1010
({username, resolved, rejected})=> {
1111
return {
12-
pending: true,
1312
username,
1413
resolved,
1514
rejected
1615
}
1716
}
17+
);
18+
19+
export const refreshToken = createAction(
20+
types.REFRESH_TOKEN,
21+
async({token})=> {
22+
return await userService.refreshToken(token);
23+
},
24+
({token, resolved, rejected})=> {
25+
return {
26+
token,
27+
resolved,
28+
rejected
29+
}
30+
}
1831
);

source/component/codeLogo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CodeLogo extends Component {
1818

1919
render() {
2020
return (
21-
<View style={ CommonStyles.codeLogoContainer }>
21+
<View style={ [CommonStyles.codeLogoContainer, this.props.style] }>
2222
<Text style={ CommonStyles.codeLogoText }>
2323
{ logoText }
2424
</Text>

source/component/drawerPanel.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,22 @@ class DrawerPanel extends Component {
5353
style={ DrawerPanelStyles.headerBg }
5454
resizeMode="stretch"
5555
source={ {uri:backgroundImageSource} }>
56+
<View style={ CommonStyles.headerBackgroundMask }/>
5657
<View style={ DrawerPanelStyles.headerContent }>
5758
<Image
5859
style={ DrawerPanelStyles.headerAvatar }
5960
source={{uri:"http://123.56.135.166/cnblog/public/img/common/author.jpg"}}/>
6061
<View style={ DrawerPanelStyles.headerText}>
61-
<Text style={ DrawerPanelStyles.headerName}>愤怒的晃晃</Text>
62-
<Text style={ DrawerPanelStyles.headerDate}>2016-09-06 12:23:45</Text>
62+
<Text style={ DrawerPanelStyles.headerName}>
63+
愤怒的晃晃
64+
</Text>
65+
<Text style={ DrawerPanelStyles.headerDate}>
66+
个人中心
67+
</Text>
6368
</View>
6469
</View>
6570
</Image>
71+
6672
</View>
6773
)
6874
}
@@ -79,20 +85,19 @@ class DrawerPanel extends Component {
7985
underlayColor ={ StyleConfig.touchablePressColor }
8086
key={ index }
8187
onPress={ ()=> onDrawerHide(item) }>
82-
<View style={ [ CommonStyles.listItem, { backgroundColor: StyleConfig.secondaryColor } ] }>
88+
<View style={ [ CommonStyles.listItem ] }>
8389
<View style={ CommonStyles.listItemIcon }>
8490
<Icon
85-
name={ item.icon } size={ 22 }
86-
style={ { color: activeForeColor } } />
91+
name={ item.icon } size={ 22 } style={[{color: StyleConfig.secondaryColor }]}/>
8792
</View>
88-
<Text style={ [ CommonStyles.listItemText, { color: activeForeColor } ] }>
93+
<Text style={ [CommonStyles.listItemText, {color: StyleConfig.secondaryColor }] }>
8994
{ item.text }
9095
</Text>
9196
<Text style={ CommonStyles.listItemTail }>
9297
<Icon
93-
name={ "ios-return-right" }
98+
name={ "ios-arrow-round-forward" }
9499
size={22}
95-
style={ [{ color: activeForeColor }] } />
100+
style={[{color: StyleConfig.secondaryColor }]} />
96101
</Text>
97102
</View>
98103
</TouchableHighlight>
@@ -106,7 +111,7 @@ class DrawerPanel extends Component {
106111
onPress={ ()=> this.onItemPress(item) }>
107112
<View style={ CommonStyles.listItem }>
108113
<View style={ CommonStyles.listItemIcon }>
109-
<Icon name={ item.icon } size={ 22 }/>
114+
<Icon name={ item.icon } size={ 22 } />
110115
</View>
111116
<Text style={ CommonStyles.listItemText }>
112117
{ item.text }

source/component/navigation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Authorization from './authorization';
1414
import { CommonStyles, StyleConfig } from '../style';
1515

1616
const defaultRoute = {
17-
name: 'home',
18-
component: Page.Home
17+
name: 'auth',
18+
component: Page.Auth
1919
};
2020

2121
class Navigation extends Component {

source/config/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default {
4343
},
4444
user: {
4545
info: "api/Users",
46-
login: "token",
46+
auth: "token",
4747
blogs:"api/blogs/<%=blogger%>/posts?pageIndex=<%=pageIndex%>",
4848
blogInfo: "api/blogs/<%=blogger%>",
4949
blinks: "api/statuses/@<%=type%>?pageIndex=<%=pageIndex%>&pageSize=<%=pageSize%>&tag=<%=tag%>",

source/config/drawer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ export default [{
1818
flag: postCategory.news
1919
},{
2020
text: "闪存",
21-
icon: "ios-download-outline",
22-
action: "toOffline",
23-
flag:"offline"
21+
icon: "ios-color-filter-outline",
22+
action: "toBlink",
23+
flag: postCategory.blink
2424
},{
2525
text: "博问",
26-
icon: "ios-cog",
27-
action: "toSetting",
28-
flag:"setting"
26+
icon: "ios-help-circle-outline",
27+
action: "toQuestion",
28+
flag: postCategory.ques
2929
},{
3030
text: "离线",
31-
icon: "ios-redo-outline",
32-
action: "toAbout",
33-
flag:"about"
31+
icon: "ios-download-outline",
32+
action: "toOffline",
33+
flag:"offline"
3434
}];

source/constant/actiontype.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const SHOW_MESSAGE = 'SHOW_MESSAGE';
1919

2020
//user
2121
export const LOGIN = 'LOGIN';
22+
export const REFRESH_TOKEN = 'REFRESH_TOKEN';
2223

2324
//config
2425
export const UPDATE_CONFIG = 'UPDATE_CONFIG';

source/image/modal-header.jpg

89.9 KB
Loading

source/service/userService.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,26 @@ function filterData(data) {
1818

1919
export function login(username, password){
2020

21-
let fetchApi = dataApi.user.login;
21+
let fetchApi = dataApi.user.auth;
2222

2323
let data = `grant_type=password&username=${username}&password=${password}`.replace(/\+/g, "%2B");
2424
let headers = {
25-
'Authorization': "Basic " + Base64.btoa(`${authData.clientId}:${authData.clientSecret}`),
25+
'Authorization': "Basic " + Base64.btoa(`${authData.clientId}:${authData.clientSecret}`)
2626
};
2727

2828
return requestService.post(fetchApi, data, headers).then(filterData);
29+
}
30+
31+
export function refreshToken(token){
32+
let fetchApi = dataApi.user.auth;
33+
let data = `grant_type=refresh_token&refresh_token=${token}`;
34+
let headers = {
35+
'Authorization': "Basic " + Base64.btoa(`${authData.clientId}:${authData.clientSecret}`)
36+
};
37+
38+
return requestService.post(fetchApi, data, headers).then(filterData);
39+
}
40+
41+
export function getToken(){
42+
2943
}

source/style/index.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,32 +499,37 @@ export const DrawerPanelStyles = StyleSheet.create({
499499
flex:1,
500500
height: 200,
501501
width: width - 80,
502-
justifyContent: 'center',
502+
justifyContent: 'flex-end',
503503
flexDirection:'column',
504-
paddingLeft: StyleConfig.contentPadding
504+
paddingVertical:StyleConfig.contentPadding,
505+
paddingHorizontal:StyleConfig.contentPadding
505506
},
506507
headerContent:{
507-
flexDirection:'row',
508-
alignItems:'center'
508+
flexDirection:'column',
509+
alignItems:'flex-start'
509510
},
510511
headerAvatar:{
511512
width: 60,
512513
height: 60,
513514
borderRadius: 30,
514-
marginRight: 10
515+
marginBottom: 10
515516
},
516517
headerText:{
517-
flexDirection:'column',
518+
flexDirection:'row',
519+
alignItems:'center',
518520
justifyContent:'space-between'
519521
},
520522
headerName:{
521-
fontSize: 20,
523+
fontSize: 18,
522524
color:'#f2f2f2',
523-
marginBottom: 5
525+
marginBottom: 5,
526+
flex:1
524527
},
525528
headerDate:{
526-
fontSize: 12,
527-
color: '#aaa'
529+
flex:1,
530+
textAlign:'right',
531+
fontSize: 14,
532+
color: '#fff'
528533
},
529534
list:{
530535
paddingTop: 10
@@ -677,7 +682,8 @@ export const CommonStyles = StyleSheet.create({
677682
backgroundColor:'rgba(255,255,255, 0.8)',
678683
alignItems:'center',
679684
justifyContent:'center',
680-
marginBottom: 10
685+
marginBottom: 10,
686+
overflow:'hidden'
681687
},
682688

683689
codeLogoText:{
@@ -732,6 +738,7 @@ export const CommonStyles = StyleSheet.create({
732738
headerBackgroundMask:{
733739
position: 'absolute',
734740
top: 0,
741+
left: 0,
735742
width: width,
736743
backgroundColor: 'rgba( 0, 0, 0, 0.2)',
737744
height: StyleConfig.parallaxHeaderHeight

0 commit comments

Comments
 (0)