5
5
<advance-countdown-notification v-else-if =" notification.type === 'advance-countdown'" v-bind =" notification" />
6
6
<custom-url-notification v-else-if =" notification.type === 'url'" v-bind =" notification" />
7
7
<reminder-notification v-else-if =" notification.type === 'reminder'" :notification =" notification" />
8
- <phone-call-notification ref =" phoneCall" v-else-if =" notification.type === 'call'" v-bind =" notification" />
8
+ <phone-call-notification :key =" notification.createdAt" ref =" phoneCall" v-else-if =" notification.type === 'call'"
9
+ v-bind =" notification" />
9
10
<message-notification v-else v-bind =" notification" />
10
11
</div >
11
12
</template >
@@ -20,7 +21,7 @@ import CustomUrlNotification from "@/widgets/dynamic-island/components/CustomUrl
20
21
import ReminderNotification from " @/widgets/dynamic-island/components/ReminderNotification.vue" ;
21
22
import {NotificationState } from " @/widgets/dynamic-island/model/NotificationState" ;
22
23
import {useMotion } from " @vueuse/motion" ;
23
- import {SwipeDirection , usePointerSwipe } from " @vueuse/core" ;
24
+ import {SwipeDirection , useDraggable , useIntervalFn , usePointerSwipe } from " @vueuse/core" ;
24
25
import {AppNotification } from " @widget-js/core" ;
25
26
26
27
export default {
@@ -31,7 +32,7 @@ export default {
31
32
MessageNotification ,
32
33
AdvanceCountdownNotification , CountingNotification , PhoneCallNotification
33
34
},
34
- emits: [" mouseEnter" , " mouseLeave" , " hidden " , " update:state" ],
35
+ emits: [" mouseEnter" , " mouseLeave" , " update:state" ],
35
36
setup(props , context ) {
36
37
const container = ref ();
37
38
const backgroundColor = ref (" black" );
@@ -52,15 +53,23 @@ export default {
52
53
height: 48 ,
53
54
scale: 1 ,
54
55
backgroundColor: backgroundColor ,
55
- transition
56
+ transition: {
57
+ duration: 500 ,
58
+ type: ' keyframe' ,
59
+ onComplete : () => {
60
+ },
61
+ }
56
62
}
57
- const {apply, motionProperties} = useMotion (island , {
58
- initial: {... hide },
63
+ const {apply, motionProperties, variant } = useMotion (island , {
64
+ initial: {... hide , },
59
65
hide ,
60
66
tapped: {
61
67
scale: 0.95 ,
62
68
backgroundColor: backgroundColor ,
63
- transition
69
+ transition: {
70
+ ... transition ,
71
+ onComplete : () => (variant .value = ' hovered' ),
72
+ }
64
73
},
65
74
hovered: {
66
75
scale: 1 ,
@@ -92,26 +101,24 @@ export default {
92
101
transition
93
102
},
94
103
});
95
- watch (motionProperties , () => {
96
- if (motionProperties [' y' ] < minY ) {
97
- context .emit (' hidden' );
98
- if (phoneCall ) {
99
- phoneCall .value ?.stop ();
100
- }
101
- }
102
- })
103
104
const stateModel = computed ({
104
105
get : () => {
105
106
return props .state
106
107
},
107
108
set : (value ) => {
108
109
apply (value );
110
+ if (value == NotificationState .HIDE ) {
111
+ if (phoneCall ) {
112
+ phoneCall .value ?.stop ();
113
+ }
114
+ }
109
115
context .emit (' update:state' , value );
110
116
}
111
117
})
112
118
let startTranslateY = - 100 ;
113
- const {distanceY} = usePointerSwipe (island , {
114
- onSwipeStart() {
119
+ const {distanceY, isSwiping, stop : stopSwipe} = usePointerSwipe (island , {
120
+ threshold: 10 ,
121
+ onSwipeStart(e ) {
115
122
startTranslateY = motionProperties [' y' ];
116
123
},
117
124
async onSwipe(e : PointerEvent ) {
@@ -126,20 +133,19 @@ export default {
126
133
})
127
134
},
128
135
async onSwipeEnd(e : PointerEvent , direction : SwipeDirection ) {
129
- console .log (motionProperties [' y' ])
130
136
if (motionProperties [' y' ] < 0 ) {
131
137
stateModel .value = NotificationState .HIDE ;
132
138
} else {
133
139
await apply (stateModel .value )
134
140
}
135
141
},
136
142
});
137
- return {container , phoneCall , backgroundColor , island , stateModel , apply }
143
+ return {container , phoneCall , isSwiping , variant , backgroundColor , island , stateModel , apply }
138
144
},
139
145
methods: {},
140
146
async mounted() {
141
147
await nextTick ();
142
- this .apply (this .state );
148
+ await this .apply (this .state );
143
149
},
144
150
watch: {
145
151
state(newState ) {
@@ -168,6 +174,8 @@ export default {
168
174
<style scoped lang="scss">
169
175
$cubic-bezier : cubic-bezier (0 , 1 , .68 , 1.05 );
170
176
.island {
177
+ -webkit-font-smoothing : antialiased ;
178
+ user-select : none ;
171
179
cursor : pointer ;
172
180
border-radius : 42px ;
173
181
display : flex ;
@@ -176,40 +184,20 @@ $cubic-bezier: cubic-bezier(0, 1, .68, 1.05);
176
184
right : 0 ;
177
185
margin : auto ;
178
186
background-color : black ;
179
- transition-property : width , height ;
180
- transition-duration : 0.8s ;
181
- transition-timing-function : $cubic-bezier ;
182
187
will-change : width , height ;
183
188
clip : auto ;
184
189
overflow : hidden ;
185
190
justify-content : flex-start ;
186
191
box-shadow : (0px 12px 32px 4px rgba (0 , 0 , 0 , 0.04 ), 0px 8px 20px rgba (0 , 0 , 0 , 0.08 ));
187
192
188
- .content {
189
- flex : 1 ;
190
- display : flex ;
191
-
192
- align-items : flex-start ;
193
- margin-left : 1rem ;
194
- margin-right : 1rem ;
193
+ .mask {
194
+ position : absolute ;
195
+ width : 100% ;
195
196
height : 100% ;
196
- justify-content : space-around ;
197
- flex-direction : column ;
198
-
199
- .title {
200
- font-size : 0.8em ;
201
- color : rgba (255 , 255 , 255 , 0.6 );
202
- }
203
-
204
- .description {
205
- color : white ;
206
- font-size : 1em ;
207
- }
208
- }
209
-
210
- .actions {
211
- display : flex ;
212
- justify-content : flex-start ;
197
+ z-index : 5 ;
198
+ left : 0 ;
199
+ top : 0 ;
200
+ background-color : black ;
213
201
}
214
202
}
215
203
</style >
0 commit comments