#155296 - 修复通知组展开显示相关bug;修改控制图标点击事件

This commit is contained in:
wurou 2023-01-12 10:14:43 +08:00
parent 88ef6e4f67
commit 36d15e712c
5 changed files with 35 additions and 38 deletions

View File

@ -18,8 +18,8 @@ export class BrightnessSlider extends StarBaseElement {
@property({type: Number}) currentDistance = 0 @property({type: Number}) currentDistance = 0
@property({type: Number}) barWidth = 0 @property({type: Number}) barWidth = 0
@property({type: Number}) max = 100 @property({type: Number}) max = 100
@property({type: Number}) min = 1 @property({type: Number}) min = 0
@property({type: Number}) _value = 1 @property({type: Number}) _value = 0
@property({type: Number}) progressLen = 0 @property({type: Number}) progressLen = 0
@property() touchAction = { @property() touchAction = {
// 触摸开始落点 // 触摸开始落点
@ -55,15 +55,15 @@ export class BrightnessSlider extends StarBaseElement {
} }
set value(value: number) { set value(value: number) {
if (value == this.min) { // if (value == this.min) {
// 最低亮度限制 // // 最低亮度限制
this.coverLen = '0' // this.coverLen = '0'
this._value = this.min // this._value = this.min
} else { // } else {
this._value = value this._value = value
let len = Math.round((value * this.barWidth) / this.max) let len = Math.round((value * this.barWidth) / this.max)
this.coverLen = len.toString() this.coverLen = len.toString()
} // }
} }
render(): HTMLTemplateResult { render(): HTMLTemplateResult {
@ -103,7 +103,7 @@ export class BrightnessSlider extends StarBaseElement {
this.touchAction.last.clientX - this.touchAction.start.clientX this.touchAction.last.clientX - this.touchAction.start.clientX
this.currentDistance = this.distance + this.progressLen this.currentDistance = this.distance + this.progressLen
if (this.currentDistance < Math.round(this.barWidth / this.max)) { if (this.currentDistance < 0) {
this.currentDistance = 0 this.currentDistance = 0
} }
@ -118,9 +118,9 @@ export class BrightnessSlider extends StarBaseElement {
(this.currentDistance * this.max) / this.barWidth (this.currentDistance * this.max) / this.barWidth
) )
if (this.value < this.min) { // if (this.value < this.min) {
this.value = this.min // this.value = this.min
} // }
if (preValue !== this.value) { if (preValue !== this.value) {
this.dispatchEvent( this.dispatchEvent(

View File

@ -76,8 +76,6 @@ export class IconControlBar extends StarBaseElement {
class="icon-button icon-base without-border" class="icon-button icon-base without-border"
data-icon=${this.icon} data-icon=${this.icon}
@click=${this} @click=${this}
@touchstart=${this}
@touchend=${this}
></div> ></div>
` `
} }
@ -157,6 +155,7 @@ export class IconControlBar extends StarBaseElement {
isActive = target.classList.contains('active') isActive = target.classList.contains('active')
this.activeOrInactive(isActive, target) this.activeOrInactive(isActive, target)
this.fireEvent(isActive) this.fireEvent(isActive)
return
} }
// if (this.type == IconControlBarType.WITH_STATE) { // if (this.type == IconControlBarType.WITH_STATE) {
@ -176,6 +175,8 @@ export class IconControlBar extends StarBaseElement {
this.iconBtn.classList.remove('actived') this.iconBtn.classList.remove('actived')
this.fireEvent() this.fireEvent()
}, 200) }, 200)
} else {
this.fireEvent()
} }
} }

View File

@ -108,11 +108,11 @@ export class StarNotificationGroup extends LitElement {
} }
firstUpdated() { firstUpdated() {
this.show = false // this.show = false
let id = window.setTimeout(() => { // let id = window.setTimeout(() => {
window.clearTimeout(id) // window.clearTimeout(id)
this.dispatchEventFurther() // this.dispatchEventFurther()
}, 300) // }, 300)
} }
@eventOptions({passive: false}) @eventOptions({passive: false})
@ -188,6 +188,8 @@ export class StarNotificationGroup extends LitElement {
let firstChild = slotElements[0] as StarNotification let firstChild = slotElements[0] as StarNotification
firstChild.count = slotLen firstChild.count = slotLen
let style = window.getComputedStyle(firstChild).height
this._singleHeight = parseInt(style.split('px')[0])
if (slotLen == 1) { if (slotLen == 1) {
// group中只有一条消息应该转为'one-notification'类型,并折叠 // group中只有一条消息应该转为'one-notification'类型,并折叠
firstChild.setAttribute( firstChild.setAttribute(
@ -210,6 +212,8 @@ export class StarNotificationGroup extends LitElement {
} else { } else {
// 折叠 // 折叠
this.addGroupHeight(0) this.addGroupHeight(0)
// this.style.setProperty('--single-noti-bgc', 'var(--notification-bgc)')
// this.setAttribute('removeBackground', 'true')
firstChild.setAttribute('radiusType', 'border-radius') firstChild.setAttribute('radiusType', 'border-radius')
firstChild.setAttribute( firstChild.setAttribute(
'notificationType', 'notificationType',
@ -270,11 +274,15 @@ export class StarNotificationGroup extends LitElement {
if (isShow) { if (isShow) {
// 当前是展开状态,点击需折叠 // 当前是展开状态,点击需折叠
this.show = false this.show = false
// this.style.setProperty('--single-noti-bgc', 'var(--notification-bgc)')
// this.setAttribute('removeBackground', 'true')
firstChild.setAttribute('radiusType', 'border-radius') firstChild.setAttribute('radiusType', 'border-radius')
firstChild.withArrowUp = false firstChild.withArrowUp = false
firstChild.setAttribute('notificationType', 'more-notifiactions-first') firstChild.setAttribute('notificationType', 'more-notifiactions-first')
} else { } else {
this.show = true this.show = true
// this.style.setProperty('--single-noti-bgc', 'transparent')
// this.setAttribute('removeBackground', 'false')
firstChild.setAttribute('radiusType', 'top-border-radius') firstChild.setAttribute('radiusType', 'top-border-radius')
firstChild.withArrowUp = true firstChild.withArrowUp = true
firstChild.setAttribute('notificationType', 'more-notifiactions') firstChild.setAttribute('notificationType', 'more-notifiactions')
@ -310,23 +318,11 @@ export class StarNotificationGroup extends LitElement {
}) })
if (isShow) { if (isShow) {
// 当前是展开状态,点击需折叠 // 当前是展开状态,点击需折叠
let self = this
firstChild.setAttribute('radiusType', 'border-radius') firstChild.setAttribute('radiusType', 'border-radius')
firstChild.withArrowUp = false firstChild.withArrowUp = false
firstChild.setAttribute('notificationType', 'more-notifiactions-first') firstChild.setAttribute('notificationType', 'more-notifiactions-first')
this.slotElements.forEach((element, index) => { this.show = false
if (element !== firstChild) { this.preventDefaultBehavior(true)
;(element as StarNotification).classList.add('animation-out')
element.addEventListener('animationend', function tEnd() {
if (index == self.slotElements.length - 1) {
self.show = false
self.preventDefaultBehavior(true)
}
;(element as StarNotification).classList.remove('animation-out')
element.removeEventListener('animationend', tEnd)
})
}
})
} }
} }

View File

@ -349,7 +349,7 @@ export class StarNotification extends StarBaseElement {
role="link" role="link"
data-id=${this.data_id} data-id=${this.data_id}
> >
<div data-icon="bluetooth-transfer-circle" aria-hidden="true"></div> <div data-icon="bluetooth-transfer" aria-hidden="true"></div>
<div class="bluetooth-title">${this.title}</div> <div class="bluetooth-title">${this.title}</div>
<progress value="${this.value}" max="1"></progress> <progress value="${this.value}" max="1"></progress>
<div class="transfer-detail"> <div class="transfer-detail">

View File

@ -91,7 +91,7 @@ export const sharedStyles: CSSResult = css`
font-family: 'OPPOSans'; font-family: 'OPPOSans';
font-style: normal; font-style: normal;
width: 90.2%; width: 90.2%;
height: 18.4%; height: 22%;
left: 9.8%; left: 9.8%;
top: 24%; top: 24%;
} }