Skip to content

Commit f670042

Browse files
committed
Improve UE
1 parent fda2036 commit f670042

File tree

10 files changed

+115
-91
lines changed

10 files changed

+115
-91
lines changed

www/app/messages/messages.controller.coffee

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
angular.module('ionic-nodeclub')
22

33
.controller 'MessagesCtrl', (
4+
toast
45
$scope
5-
messageService
66
$stateParams
7+
$ionicLoading
8+
messageService
79
) ->
810

911
loadMessages = (refresh) ->
@@ -26,7 +28,13 @@ angular.module('ionic-nodeclub')
2628
doRefresh: ->
2729
loadMessages(refresh = true)
2830
markAsRead: ->
31+
$ionicLoading.show()
2932
messageService.markAllAsRead()
30-
.then -> loadMessages(refresh = true)
33+
.then ->
34+
$ionicLoading.hide()
35+
toast $scope.hasnot_read_messages.length + '个被标记为已读'
36+
loadMessages(refresh = true)
37+
.catch ->
38+
$ionicLoading.hide()
3139

3240
loadMessages(refresh = false)

www/app/messages/messages.html

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<ion-view view-title="我的消息">
22
<ion-nav-buttons side="right">
3-
<button class="button button-small button-positive"
4-
ng-click="markAsRead()"
5-
ng-if="hasnot_read_messages.length">
6-
标记为已读
7-
</button>
83
</ion-nav-buttons>
94
<!-- TODO overflow-scroll="true" -->
105
<ion-content>
@@ -13,12 +8,21 @@
138
spinner="spiral"
149
on-refresh="doRefresh()">
1510
</ion-refresher>
11+
<div class="text-center padding"
12+
ng-if="loading && !hasnot_read_messages">
13+
<ion-spinner icon="spiral"></ion-spinner>
14+
<p>加载中...</p>
15+
</div>
16+
<div class="padding text-center"
17+
ng-if="error">
18+
囧,出错啦...
19+
</div>
1620
<div class="list">
1721
<message-tile ng-repeat="message in hasnot_read_messages track by message.id"
1822
message="message">
1923
</message-tile>
2024
<div class="item"
21-
ng-if="!hasnot_read_messages.length && !loading && !error">
25+
ng-if="!hasnot_read_messages.length && hasnot_read_messages && !error">
2226
暂无未读消息
2327
</div>
2428
<div ng-if="has_read_messages.length"
@@ -27,14 +31,8 @@
2731
message="message">
2832
</message-tile>
2933
</div>
30-
<div class="text-center padding"
31-
ng-if="loading && !has_read_messages && !hasnot_read_messages">
32-
<ion-spinner icon="spiral"></ion-spinner>
33-
<p>加载中...</p>
34-
</div>
35-
<div class="padding text-center"
36-
ng-if="error">
37-
囧,出错啦...
38-
</div>
3934
</ion-content>
35+
<button class="button-float button button-stable icon icon-done-all"
36+
ng-if="!hasnot_read_messages.length"
37+
ng-click="markAsRead()"></button>
4038
</ion-view>

www/app/scss/_button.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
left: -1px;
1515
bottom: -5px;
1616
}
17+
span {
18+
margin: 0 !important;
19+
}
1720
}
1821
.header-avatar-button {
1922
line-height: 34px;
@@ -37,10 +40,28 @@
3740
color: $button-positive-active-bg !important;
3841
}
3942
}
43+
.button-float {
44+
position: fixed;
45+
bottom: 16px;
46+
right: 16px;
47+
border: none;
48+
border-radius: 50%;
49+
min-width: 3em;
50+
min-height: 3em;
51+
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
52+
z-index: 20;
53+
@include transition(0.2s linear);
54+
@include transition-property('background-color, box-shadow');
55+
&.active,
56+
&.activated {
57+
box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.36) !important;
58+
}
59+
}
4060
.reply-button {
4161
margin-left: 0 !important;
4262
font-size: 16px !important;
4363
border: none;
64+
background-color: #EEE;
4465
}
4566
.new-reply {
4667
background: none;

www/app/scss/_icon.scss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
.icon-person {
2+
@extend .ion-ios-person-outline;
3+
}
14
.icon-new-topic {
2-
@extend .ion-ios-compose-outline;
5+
@extend .ion-ios-paperplane;
36
}
4-
.icon-more {
5-
@extend .ion-ios-more;
7+
.icon-more-action {
8+
@extend .ion-android-more-vertical;
69
}
710
.icon-close {
811
@extend .ion-ios-close-empty;
912
}
13+
.icon-done-all {
14+
@extend .ion-android-done-all;
15+
}
1016

1117
.platform-android {
18+
.icon-person {
19+
@extend .ion-android-person;
20+
}
1221
.icon-new-topic {
1322
@extend .ion-android-add;
1423
}
15-
.icon-more {
16-
@extend .ion-android-more-vertical;
17-
}
1824
.icon-close {
1925
@extend .ion-android-close;
2026
}

www/app/services/auth.service.coffee

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ angular.module('ionic-nodeclub')
2525
.then (user) ->
2626
toast '登录成功,欢迎您: ' + user.loginname
2727
$scope.loginModal?.hide()
28-
.catch (error) ->
28+
, (error) ->
2929
toast '登录失败: ' + error?.data?.error_msg
3030

3131
$ionicModal
@@ -47,11 +47,13 @@ angular.module('ionic-nodeclub')
4747
.all('accessToken')
4848
.post(accesstoken: token)
4949
.then (user) ->
50+
$ionicLoading.hide()
5051
storage.set 'user', angular.extend(user, token: token)
5152
$rootScope.$broadcast 'auth.userUpdated', user
5253
resolve user
53-
.catch reject
54-
.finally $ionicLoading.hide
54+
, (error) ->
55+
$ionicLoading.hide()
56+
reject(error)
5557

5658
#
5759
# 我要在初始化的时候检查localStorage的token是否合法

www/app/topic/topic-popover.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

www/app/topic/topic.controller.coffee

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
angular.module('ionic-nodeclub')
22

33
.controller 'TopicCtrl', (
4+
API
45
toast
56
$scope
67
$state
@@ -11,24 +12,14 @@ angular.module('ionic-nodeclub')
1112
topicService
1213
$stateParams
1314
$ionicPopover
15+
$ionicActionSheet
1416
) ->
1517

16-
$ionicPopover.fromTemplateUrl 'app/topic/topic-popover.html',
17-
scope: $scope
18-
.then (popover) ->
19-
$scope.popover = popover
20-
2118
angular.extend $scope,
2219
loading: false
2320
isCollected: false
2421
error: null
2522
topic: null
26-
popover: null
27-
28-
hidePopover: (event) ->
29-
$timeout ->
30-
$scope.popover.hide(event)
31-
, 100
3223

3324
loadTopic: (reload = false) ->
3425
$scope.loading = true
@@ -44,19 +35,16 @@ angular.module('ionic-nodeclub')
4435
authService
4536
.isAuthenticated()
4637
.then ->
47-
userService.collectTopic topic
48-
.then ->
49-
$scope.isCollected = true
50-
toast '收藏成功'
51-
52-
deCollectTopic: (topic) ->
53-
authService
54-
.isAuthenticated()
55-
.then ->
56-
userService.deCollectTopic topic
57-
.then ->
58-
$scope.isCollected = false
59-
toast '已取消收藏'
38+
if $scope.isCollected
39+
userService.deCollectTopic topic
40+
.then ->
41+
$scope.isCollected = false
42+
toast '已取消收藏'
43+
else
44+
userService.collectTopic topic
45+
.then ->
46+
$scope.isCollected = true
47+
toast '收藏成功'
6048

6149
replyTopic: ->
6250
authService
@@ -70,6 +58,34 @@ angular.module('ionic-nodeclub')
7058
.then (me) ->
7159
$state.go 'app.user', loginname:me.loginname
7260

61+
showTopicAction: ->
62+
$ionicActionSheet.show
63+
buttons: [
64+
text: '重新加载'
65+
,
66+
text: '回复话题'
67+
,
68+
text: if !$scope.isCollected then '收藏话题' else '取消收藏'
69+
,
70+
text: '关于作者'
71+
,
72+
text: '浏览器打开'
73+
]
74+
buttonClicked: (index) ->
75+
switch index
76+
when 0
77+
$scope.loadTopic(true)
78+
when 1
79+
$scope.replyTopic()
80+
when 2
81+
$scope.collectTopic()
82+
when 3
83+
$state.go 'app.user', loginname: $scope.topic.author.loginname
84+
else
85+
window.open "#{API.server}/topic/#{$stateParams.topicId}", '_system'
86+
return true
87+
88+
7389

7490
$scope.loadTopic()
7591
userService.checkCollect $stateParams.topicId

www/app/topic/topic.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
ng-if="topic">
66
{{topic.reply_count}}回复
77
</button>
8-
<button class="button button-icon icon icon-more"
9-
ng-if="popover"
10-
ng-click="popover.show($event)">
11-
</button>
128
</ion-nav-buttons>
139
<!-- TODO overflow-scroll="true" -->
1410
<ion-content>
@@ -40,10 +36,17 @@ <h3>{{topic.title}}</h3>
4036
ui-sref="app.replies({topicId: topic.id})">
4137
<span ng-if="topic.reply_count">
4238
{{topic.reply_count}} 回复
39+
<small class="text-note"> -
40+
<span am-time-ago="topic.last_reply_at">
41+
</span>
42+
</small>
4343
</span>
4444
<span ng-if="!topic.reply_count">
4545
暂无回复
4646
</span>
4747
</div>
4848
</ion-content>
49+
<button class="button-float button button-stable icon icon-more-action"
50+
ng-if="!hasnot_read_messages.length"
51+
ng-click="showTopicAction()"></button>
4952
</ion-view>

www/app/topics/topics.controller.coffee

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ angular.module('ionic-nodeclub')
55
toast
66
$scope
77
$timeout
8+
authService
89
$ionicModal
910
$stateParams
10-
authService
11+
$ionicPopover
1112
topicService
1213
$ionicScrollDelegate
1314
) ->
1415

1516
$ionicModal
16-
.fromTemplateUrl('app/topics/new-topic-modal.html', scope: $scope)
17+
.fromTemplateUrl 'app/topics/new-topic-modal.html',
18+
scope: $scope
1719
.then (modal) ->
1820
$scope.newTopicModal = modal
1921

www/app/topics/topics.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<ion-view view-title="{{selectedTab | tabLabel}}">
22
<ion-nav-buttons side="right">
3-
<button class="button button-icon icon icon-new-topic"
4-
ng-click="createNewTopic()"></button>
53
<span ng-if="!me">
6-
<button class="button button-icon icon ion-ios-person-outline"
4+
<button class="button button-icon icon icon-person"
75
ng-click="auth.login()"></button>
86
</span>
97
<span ng-if="me">
@@ -14,8 +12,6 @@
1412
ng-src="{{me.avatar_url | prefixUrl}}">
1513
</a>
1614
</span>
17-
<button class="button button-icon icon icon-more"
18-
ng-click="more()"></button>
1915
</ion-nav-buttons>
2016
<!-- TODO overflow-scroll="true" -->
2117
<ion-content delegate-handle="topics-handle">
@@ -61,4 +57,6 @@ <h2>{{topic.title}}</h2>
6157
<span ng-if="error">囧,出错啦...</span>
6258
</div>
6359
</ion-content>
60+
<button class="button-float button button-assertive icon icon-new-topic"
61+
ng-click="createNewTopic()"></button>
6462
</ion-view>

0 commit comments

Comments
 (0)