BuilderIndex.ets 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { yTRouter } from "basic"
  2. import { CustomTextStyle } from "../style/CustomTextStyle"
  3. // 标签Item
  4. @Builder
  5. export function tagItemComp(text: string, fontColor: ResourceColor, bgColor: ResourceColor){
  6. Row(){
  7. Text(text)
  8. .attributeModifier(new CustomTextStyle({size: 12, weight: 400 , color: fontColor}))
  9. }
  10. .padding(5)
  11. .backgroundColor(bgColor)
  12. .borderRadius({topLeft: 8.5, topRight: 8.5, bottomRight: 8.5, bottomLeft: 0})
  13. }
  14. // 书单Item
  15. @Builder
  16. export function bookListItemComp(title: string){
  17. Row({space: 11}){
  18. Image($r('[basic].media.png_TopRecommend'))
  19. .width(86)
  20. .aspectRatio(1)
  21. .borderRadius(12)
  22. Column({space: 3}){
  23. Text(title)
  24. .attributeModifier(new CustomTextStyle({size: 14, weight: 600}))
  25. Text('豆瓣平均分9.2分推荐!红红火火恍恍惚惚哈哈哈哈哈给红红火火恍恍惚惚哈哈哈...')
  26. .width('100%')
  27. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#FF555555'}))
  28. Blank()
  29. .layoutWeight(1)
  30. Text('共92本')
  31. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#FF555555'}))
  32. }
  33. .layoutWeight(1)
  34. .alignItems(HorizontalAlign.Start)
  35. }
  36. .padding(8)
  37. .height(102)
  38. .width('100%')
  39. .borderRadius(12)
  40. .border({width: 2, color: '#FF000000'})
  41. .onClick(() => {
  42. yTRouter.router2BookListDetailPage()
  43. })
  44. }
  45. // 书籍Item
  46. @Builder
  47. export function bookItemComp(title: string, onClick: () => void){
  48. Row({space: 11}){
  49. Image($r('[basic].media.png_TopRecommend'))
  50. .width(86)
  51. .aspectRatio(1)
  52. .borderRadius(12)
  53. Column({space: 3}){
  54. Text(title)
  55. .attributeModifier(new CustomTextStyle({size: 14, weight: 600}))
  56. Text('豆瓣平均分9.2分推荐!红红火火恍恍惚惚哈哈哈哈哈给红红火火恍恍惚惚哈哈哈...')
  57. .width('100%')
  58. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#FF555555'}))
  59. Blank()
  60. .layoutWeight(1)
  61. Row(){
  62. Row({space: 13}){
  63. tagItemComp('情绪价值', '#FF4EB1EF', '#FFEDF7FD')
  64. tagItemComp('3-8岁', '#FFFC9911', '#FFFFF5E7')
  65. }
  66. Image(true ? $r('[basic].media.icon_deerIncrease') : $r('[basic].media.icon_reduce'))
  67. .width(24)
  68. .aspectRatio(1)
  69. }
  70. .width("100%")
  71. .justifyContent(FlexAlign.SpaceBetween)
  72. }
  73. .layoutWeight(1)
  74. .alignItems(HorizontalAlign.Start)
  75. }
  76. .padding(8)
  77. .height(102)
  78. .width('100%')
  79. .borderRadius(12)
  80. .border({width: 2, color: '#FF000000'})
  81. .onClick(() => {
  82. onClick()
  83. })
  84. }
  85. // 按钮
  86. @Builder
  87. export function buttonComp(text: string, width: Length, padding: number, font: CustomTextStyle ,onClick: () => void){
  88. Row(){
  89. Text(text)
  90. .attributeModifier(font)
  91. }
  92. .width(width)
  93. .borderRadius(24.5)
  94. .backgroundColor('#FFFECF2F')
  95. .justifyContent(FlexAlign.Center)
  96. .border({width: 2, color: '#FF000000'})
  97. .padding({top: padding, bottom: padding})
  98. .onClick(onClick)
  99. }