YtButton.ets 881 B

12345678910111213141516171819202122232425262728293031
  1. @Component
  2. export struct YtButton {
  3. btHeight: number = 37
  4. btWidth: Length = '100%'
  5. btContent: string = ''
  6. click = () => {
  7. }
  8. btPadding?: Length | Padding
  9. btFontSize: number = 12
  10. bgc: ResourceColor = $r('app.color.main_ac_color_dark')
  11. btFontColor: ResourceColor = Color.White
  12. btBorder?: BorderOptions
  13. btState: boolean = true
  14. btBorderRadius: Length | BorderRadiuses | LocalizedBorderRadiuses = this.btHeight / 2
  15. build() {
  16. Button(this.btContent)
  17. .buttonStyle(ButtonStyleMode.NORMAL)
  18. .fontSize($r(`app.float.page_text_font_size_${this.btFontSize}`))
  19. .fontColor(this.btFontColor)
  20. .backgroundColor(this.bgc)
  21. .height(this.btHeight)
  22. .width(this.btWidth)
  23. .onClick(this.click)
  24. .padding(this.btPadding ?? {})
  25. .border(this.btBorder)
  26. .enabled(this.btState)
  27. .borderRadius(this.btBorderRadius)
  28. }
  29. }