YTDiaLogBuild.ets 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. import { BasicType, IBestToast } from 'basic'
  2. import { DiaLogPageEnum, DiaLogParam } from 'basic/src/main/ets/models/YTDiaLogModel'
  3. import { Recipe, TurnTableRouteParams } from '../model/Index'
  4. import { ReNameInput } from './bigwheel/ReNameInput'
  5. import { NumberKeyBoard, NumberKeyBoardStyle } from './NumberKeyboard'
  6. import { YtDatePicker } from './YtDatePicker'
  7. import { _YtHeader } from './_YtHeader'
  8. @Builder
  9. export function getBuilder(param: DiaLogParam, onBack: (ans?: string) => void){
  10. if(param.pageEnum == DiaLogPageEnum.BottomMenu) BottomMenu(onBack, param.params)
  11. else if (param.pageEnum == DiaLogPageEnum.DatePicker) DatePickerBuilder(onBack, param.param)
  12. else if (param.pageEnum == DiaLogPageEnum.NumBerInput) NumberInputBuilder({onBack: onBack, param: param.param})
  13. else if (param.pageEnum == DiaLogPageEnum.Confirm) DoubleConfirm(onBack, param.param)
  14. else if (param.pageEnum == DiaLogPageEnum.TextInput) InputComp({onBack: onBack, param: param.param})
  15. /******** 额外的 ***********/
  16. else if (param.pageEnum == DiaLogPageEnum.SelectGender) GenderPickerBuilder(onBack, param.param)
  17. else if (param.pageEnum == DiaLogPageEnum.RecipePopup) RecipePopupBuilder(onBack, param.param as BasicType<Recipe>)
  18. else if (param.pageEnum == DiaLogPageEnum.AddToRecipe) AddPlanComp({onBack: onBack})
  19. else if (param.pageEnum == DiaLogPageEnum.TurnTableSetting) BigWheelManagerBuilder({onBack: onBack, param: param.param})
  20. else if (param.pageEnum == DiaLogPageEnum.TurnTableName) BigWheelNameBuilder({onBack: onBack, param: param.param})
  21. }
  22. // 底部菜单
  23. @Builder
  24. function BottomMenu(onBack: (ans:string) => void, params?: Array<BasicType>) {
  25. Column(){
  26. ForEach(params, (item: BasicType, index) => {
  27. Row(){
  28. Text(item.text)
  29. .fontSize(16)
  30. .textAlign(TextAlign.Center)
  31. }
  32. .width("100%")
  33. .alignItems(VerticalAlign.Center)
  34. .justifyContent(FlexAlign.Center)
  35. .padding({ top: 24, bottom: 24 })
  36. .onClick(() => {
  37. let ans = item.message ?? item.text ?? `${index}`
  38. onBack(ans)
  39. })
  40. Divider().width("80%").height(1).backgroundColor('#000000F2')
  41. })
  42. }
  43. .width("100%")
  44. .padding({ bottom: 30 })
  45. .backgroundColor(Color.White)
  46. .justifyContent(FlexAlign.Center)
  47. .alignItems(HorizontalAlign.Center)
  48. .borderRadius({ topLeft: 8, topRight: 8 })
  49. }
  50. // 时间选择器
  51. @Builder
  52. function DatePickerBuilder(onBack: (ans?:string) => void, param?: BasicType){
  53. YtDatePicker({
  54. selectDateBack: (date?: Date) => {
  55. if(!date) return onBack()
  56. // 转换为 YY-MM-DD HH:mm:ss 格式
  57. const year = date.getFullYear().toString();
  58. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  59. const day = date.getDate().toString().padStart(2, '0');
  60. const result = `${year}-${month}-${day}`;
  61. onBack(result)
  62. },
  63. selectedDate: param?.date ? new Date(param.date) : new Date(),
  64. linearInfo: { colors: [['#95C50A', 1]] },
  65. needCancel: true
  66. })
  67. }
  68. // 对话框
  69. @Builder
  70. function DoubleConfirm(onBack: (ans?:string) => void, param?: BasicType) {
  71. Column() {
  72. if(param?.text)
  73. Text(param.text)
  74. .fontColor(Color.Black)
  75. .lineHeight(18)
  76. .fontSize(18)
  77. .textAlign(TextAlign.Center)
  78. .margin({ bottom: 18 })
  79. Row() {
  80. Text('取消')
  81. .fontSize(16)
  82. .fontWeight(400)
  83. .borderRadius(param?.number ?? 36)
  84. .fontColor(Color.Black)
  85. .backgroundColor('#F5F5F7')
  86. .padding({ left: 36, top: 9, right: 36, bottom: 9})
  87. .onClick(() => {
  88. onBack()
  89. })
  90. Text('确定')
  91. .fontSize(16)
  92. .fontWeight(400)
  93. .borderRadius(param?.number ?? 36)
  94. .fontColor(Color.Black)
  95. .padding({ left: 36, top: 9, right: 36, bottom: 9})
  96. .linearGradient({
  97. colors: [ param?.color ? [param.color, 1 ] : ['#30E3CE', 0.4], ['#91F1FF', 0.8] ],
  98. angle: 200
  99. })
  100. .onClick(() => {
  101. onBack('true')
  102. })
  103. }
  104. .justifyContent(FlexAlign.SpaceBetween)
  105. .width('100%')
  106. }
  107. // .height(160)
  108. .width(280)
  109. .padding({ top: 28, left: 32, right: 32, bottom: 20 })
  110. .backgroundColor(Color.White)
  111. .borderRadius(8)
  112. }
  113. // 数字输入框
  114. @ComponentV2
  115. struct NumberInputBuilder{
  116. @Event onBack: (ans:string) => void
  117. @Param @Require param: BasicType
  118. @Local ans: string = ''
  119. aboutToAppear(): void {
  120. this.ans = this.param.text ?? ''
  121. }
  122. build() {
  123. Column(){
  124. // 标题
  125. RelativeContainer(){
  126. _YtHeader({ title: this.param?.text ?? '', isShowBackComp: false, })
  127. .height(44)
  128. .id('_title')
  129. .width("100%")
  130. .alignRules({
  131. top: { anchor: "__container__", align: VerticalAlign.Top},
  132. left: { anchor: "__container__", align: HorizontalAlign.Start}
  133. })
  134. Text(this.ans)
  135. .fontSize(32)
  136. .fontWeight(500)
  137. .fontColor('#30E3CE')
  138. .id('weight')
  139. .padding({left: 58, right: 58, bottom: 10, top: 60})
  140. .alignRules({
  141. top: { anchor: "_title", align: VerticalAlign.Bottom},
  142. middle: { anchor: "__container__", align: HorizontalAlign.Center}
  143. })
  144. Row()
  145. .width(151)
  146. .height(3)
  147. .backgroundColor('#30E3CE')
  148. .borderRadius(8)
  149. .alignRules({
  150. top: { anchor: "weight", align: VerticalAlign.Bottom},
  151. middle: { anchor: "__container__", align: HorizontalAlign.Center}
  152. })
  153. Text(this.param?.message ?? '')
  154. .fontSize(20)
  155. .fontWeight(500)
  156. .padding({ bottom: 10 })
  157. .fontColor('rgba(0, 0, 0, 0.5)')
  158. .alignRules({
  159. bottom: { anchor: "weight", align: VerticalAlign.Bottom},
  160. right: { anchor: "weight", align: HorizontalAlign.End}
  161. })
  162. }
  163. .height(210)
  164. .backgroundColor(Color.White)
  165. // 数字键盘
  166. Column(){
  167. NumberKeyBoard({
  168. textInputValue: this.ans,
  169. maxInputNum: 3,
  170. keyBoardStyle: new NumberKeyBoardStyle()
  171. .setFinishBackGround('#30E3CE')
  172. .setZeroBackGround(Color.White)
  173. .setBorder({ width: 0 })
  174. .setDeleteIcon($r('app.media.icon_delback')),
  175. onTextInputValueChange: (textInputValue: string) => {
  176. this.ans = textInputValue
  177. },
  178. onFinishClick: (text: string) => {
  179. if(!text || text == '0' || text == '0.') return
  180. if(text.charAt(text.length-1) === '.') this.ans += '0'
  181. this.onBack(this.ans!)
  182. }
  183. })
  184. }
  185. .height(260)
  186. .width("100%")
  187. .backgroundColor('#F5F6FA')
  188. .padding({ top: 10, bottom: 35, left: 10, right: 10})
  189. }
  190. // .height(470)
  191. .width("100%")
  192. .backgroundColor(Color.White)
  193. .padding({
  194. top: 24,
  195. })
  196. }
  197. }
  198. // 输入框
  199. @ComponentV2
  200. struct InputComp{
  201. @Event onBack: (ans?:string) => void
  202. @Param @Require param: BasicType
  203. @Local ans: string = ''
  204. aboutToAppear(): void {
  205. this.ans = this.param.text ?? ''
  206. }
  207. build() {
  208. Column({space: 10}){
  209. Row(){
  210. Text("取消")
  211. .fontSize(12)
  212. .fontWeight(400)
  213. .borderRadius(45)
  214. // .backgroundColor('#C1EDE9')
  215. .padding({ left: 20,top: 8, right: 20, bottom: 8})
  216. .onClick(() => {
  217. this.onBack()
  218. })
  219. // Text(this.param.text ?? '')
  220. // .fontSize(18)
  221. // .fontWeight(500)
  222. Text("确定")
  223. .fontSize(12)
  224. .fontWeight(400)
  225. .borderRadius(45)
  226. .fontColor(Color.Black)
  227. // .backgroundColor('#30E3CE')
  228. .padding({ left: 20,top: 8, right: 20, bottom: 8})
  229. .onClick(() => {
  230. this.onBack(this.ans)
  231. })
  232. }
  233. .width("100%")
  234. .alignItems(VerticalAlign.Center)
  235. .justifyContent(FlexAlign.SpaceBetween)
  236. TextInput({text: $$this.ans, placeholder: this.param.message})
  237. .height('48')
  238. .borderRadius(8)
  239. .defaultFocus(true)
  240. .maxLength(13)
  241. .backgroundColor('#F6F6F6')
  242. .onSubmit(() => {
  243. this.onBack(this.ans)
  244. })
  245. }
  246. .width("100%")
  247. .borderRadius({ topLeft: 10, topRight: 10 })
  248. .backgroundColor(this.param.color ?? '#ffff')
  249. .padding({ bottom: 42, left: 16, right: 16, top: 24 })
  250. }
  251. }
  252. // 性别 - 选择器
  253. @Builder
  254. function GenderPickerBuilder(onBack: (ans?:string) => void, param?: BasicType){
  255. Column({space: 20}) {
  256. Row(){
  257. Text("性别")
  258. .fontSize(18)
  259. .fontWeight(500)
  260. }
  261. .alignItems(VerticalAlign.Center)
  262. .justifyContent(FlexAlign.Center)
  263. .width("100%")
  264. Row({space: 16}){
  265. Text("女生")
  266. .fontSize(16)
  267. .textAlign(TextAlign.Center)
  268. .fontWeight(500)
  269. .fontColor(param?.number == 2 ? Color.White : Color.Black)
  270. .backgroundColor(param?.number == 2 ? '#FF5F84' : '#F6F6F6')
  271. .borderRadius(10)
  272. .layoutWeight(1)
  273. .padding({ left: 38, right: 38, top: 12, bottom: 12 })
  274. .onClick(() => {
  275. onBack('女')
  276. })
  277. Text("男生")
  278. .fontSize(16)
  279. .fontWeight(500)
  280. .textAlign(TextAlign.Center)
  281. .fontColor(param?.number == 1 ? Color.White : Color.Black)
  282. .backgroundColor(param?.number == 1 ? '#FF5F84' : '#F6F6F6')
  283. .borderRadius(10)
  284. .layoutWeight(1)
  285. .padding({ left: 38, right: 38, top: 12, bottom: 12 })
  286. .onClick(() => {
  287. onBack('男')
  288. })
  289. }
  290. .width('100%')
  291. .alignItems(VerticalAlign.Center)
  292. .justifyContent(FlexAlign.SpaceBetween)
  293. }
  294. .width("100%")
  295. .backgroundColor(Color.White)
  296. .padding({ bottom: 60, left: 16, right: 16, top: 24 })
  297. }
  298. // 食谱弹窗
  299. @Builder
  300. function RecipePopupBuilder(onBack: (ans?:string) => void, param?: BasicType<Recipe>){
  301. Column(){
  302. // 关闭按钮
  303. Row(){
  304. Image($r('app.media.close'))
  305. .width(20)
  306. .aspectRatio(1)
  307. .onClick(() => {
  308. onBack()
  309. })
  310. }
  311. .width('100%')
  312. .justifyContent(FlexAlign.End)
  313. .alignItems(VerticalAlign.Center)
  314. .padding({ top: 12, right: 20 })
  315. // 食谱名
  316. Column(){
  317. Text(param?.generics?.name)
  318. .fontSize(24)
  319. .fontWeight(600)
  320. }
  321. .width("100%")
  322. .padding({ left: 32 })
  323. .alignItems(HorizontalAlign.Start)
  324. .justifyContent(FlexAlign.Center)
  325. Row({space: 13}){
  326. // 图片和标签
  327. Column({space: 30}){
  328. Text(param?.generics?.monthRange)
  329. .fontSize(10)
  330. .borderRadius(4)
  331. .fontColor('#F0A040')
  332. .backgroundColor('#F8F0E6')
  333. .padding({left: 10, top: 4, right: 10, bottom: 4})
  334. Row()
  335. .width(180)
  336. .aspectRatio(1)
  337. .offset({x: -30})
  338. .backgroundImage(param?.generics?.imageUrl)
  339. .backgroundImageSize(ImageSize.Cover)
  340. }
  341. .width(134)
  342. .clip(true)
  343. .height('100%')
  344. .alignItems(HorizontalAlign.End)
  345. // 描述
  346. List(){
  347. ListItem(){
  348. Column(){
  349. Text(){
  350. Span('食材:\n')
  351. ForEach(param?.generics?.ingredients, (i: string) => {
  352. Span(i + '\n')
  353. .fontSize(12)
  354. .fontWeight(400)
  355. .fontColor('#99161616')
  356. })
  357. }
  358. .fontSize(10)
  359. .fontWeight(400)
  360. .fontColor('#161616')
  361. Text(){
  362. Span('制作步骤:\n')
  363. ForEach(param?.generics?.steps, (i: string) => {
  364. Span(i + '\n')
  365. .fontSize(12)
  366. .fontWeight(400)
  367. .fontColor('#99161616')
  368. })
  369. }
  370. .fontSize(10)
  371. .fontWeight(400)
  372. .fontColor('#161616')
  373. Text(){
  374. Span('营养信息:\n')
  375. Span(param?.generics?.description)
  376. .fontSize(12)
  377. .fontWeight(400)
  378. .fontColor('#99161616')
  379. }
  380. .fontSize(10)
  381. .fontWeight(400)
  382. .fontColor('#161616')
  383. }
  384. .justifyContent(FlexAlign.Start)
  385. .alignItems(HorizontalAlign.Start)
  386. }
  387. }
  388. .height('100%')
  389. .layoutWeight(1)
  390. }
  391. .width("100%")
  392. .height(250)
  393. .padding({top: 6, right: 16})
  394. .justifyContent(FlexAlign.SpaceBetween)
  395. // 确认按钮
  396. Row(){
  397. Text('添加至本周计划')
  398. .fontSize(16)
  399. .fontWeight(500)
  400. .borderRadius(10)
  401. .fontColor(Color.White)
  402. .backgroundColor('#95C50A')
  403. .padding({ left: 60, top: 10, right: 60, bottom: 10})
  404. .onClick(() => {
  405. onBack('好嘞')
  406. })
  407. }
  408. .width("100%")
  409. .alignItems(VerticalAlign.Center)
  410. .justifyContent(FlexAlign.Center)
  411. .padding({top: 26, bottom: 29})
  412. }
  413. .width(320)
  414. .height(432)
  415. .borderRadius(8)
  416. .backgroundColor(Color.White)
  417. }
  418. // 添加周计划
  419. @ComponentV2
  420. struct AddPlanComp{
  421. @Local week: number = -1
  422. @Local meal: number = -1
  423. @Event onBack: (ans?:string) => void
  424. private weekList: string[] = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
  425. private mealList: string[] = ['早餐', '午餐', '晚餐']
  426. @Monitor('week', 'meal')
  427. checkAns(){
  428. if(this.week != -1 && this.meal != -1) {
  429. this.onBack(`${this.week}-${this.meal}`)
  430. }
  431. }
  432. build() {
  433. Column(){
  434. Row(){
  435. Text('添加至周计划')
  436. .fontColor(Color.White)
  437. Image($r('app.media.close'))
  438. .width(20)
  439. .aspectRatio(1)
  440. .onClick(() => { this.onBack() })
  441. }
  442. .width("100%")
  443. .backgroundColor('#95C50A')
  444. .padding({ top: 12, bottom: 12, left: 20, right: 20 })
  445. .alignItems(VerticalAlign.Center)
  446. .justifyContent(FlexAlign.SpaceBetween)
  447. .borderRadius({topLeft: 8, topRight: 8})
  448. Column({space: 20}){
  449. Column({space: 8}){
  450. Text('选择日期')
  451. .fontSize(14)
  452. .fontWeight(500)
  453. .padding({top: 8, bottom: 8})
  454. Row(){
  455. Text(this.weekList[this.week])
  456. .fontSize(16)
  457. .fontWeight(500)
  458. Image($r('[basic].media.ic_back'))
  459. .width(16)
  460. .aspectRatio(1)
  461. .rotate({angle: 270})
  462. }
  463. .width("100%")
  464. .borderRadius(10)
  465. .backgroundColor('#F6F6F6')
  466. .padding({ left: 16, right: 16, top: 12, bottom: 12 })
  467. .justifyContent(FlexAlign.SpaceBetween)
  468. .bindMenu(this.weekMenu, { hapticFeedbackMode: HapticFeedbackMode.ENABLED })
  469. }
  470. .alignItems(HorizontalAlign.Start)
  471. Column({space: 8}){
  472. Text('选择餐次')
  473. .fontSize(14)
  474. .fontWeight(500)
  475. .padding({top: 8, bottom: 8})
  476. Row(){
  477. Text(this.mealList[this.meal] ?? '')
  478. .fontSize(16)
  479. .fontWeight(500)
  480. Image($r('[basic].media.ic_back'))
  481. .width(16)
  482. .aspectRatio(1)
  483. .rotate({angle: 270})
  484. }
  485. .width("100%")
  486. .borderRadius(10)
  487. .backgroundColor('#F6F6F6')
  488. .padding({ left: 16, right: 16, top: 12, bottom: 12 })
  489. .justifyContent(FlexAlign.SpaceBetween)
  490. .bindMenu(this.mealMenu, { hapticFeedbackMode: HapticFeedbackMode.ENABLED })
  491. }
  492. .alignItems(HorizontalAlign.Start)
  493. }
  494. .width("100%")
  495. .layoutWeight(1)
  496. .padding({ left: 16, right: 16, top: 12})
  497. .alignItems(HorizontalAlign.Center)
  498. .justifyContent(FlexAlign.Start)
  499. .borderRadius({bottomLeft: 8, bottomRight: 8})
  500. }
  501. .width(320)
  502. .height(270)
  503. .borderRadius(8)
  504. .backgroundColor(Color.White)
  505. }
  506. @Builder
  507. weekMenu(){
  508. Column({space: 5}){
  509. ForEach(this.weekList, (item: string, index) => {
  510. Text(item)
  511. .fontSize(16)
  512. .fontWeight(500)
  513. .textAlign(TextAlign.Center)
  514. .fontColor(this.week == index ? Color.White : Color.Black)
  515. .backgroundColor(this.week == index ? '#FF5F84' : '#F6F6F6')
  516. .borderRadius(10)
  517. .padding({ left: 16, right: 16, top: 5, bottom: 5 })
  518. .onClick(() => { this.week = index })
  519. })
  520. }
  521. }
  522. @Builder
  523. mealMenu(){
  524. Column({space: 5}){
  525. ForEach(this.mealList, (item: string, index) => {
  526. Text(item)
  527. .fontSize(16)
  528. .fontWeight(500)
  529. .textAlign(TextAlign.Center)
  530. .fontColor(this.meal == index ? Color.White : Color.Black)
  531. .backgroundColor(this.meal == index ? '#FF5F84' : '#F6F6F6')
  532. .borderRadius(10)
  533. .padding({ left: 16, right: 16, top: 5, bottom: 5 })
  534. .onClick(() => { this.meal = index })
  535. })
  536. }
  537. }
  538. }
  539. // 大转盘 - 设置弹窗
  540. @ComponentV2
  541. struct BigWheelManagerBuilder{
  542. @Local isRepeat: boolean = true
  543. @Local spinDurationTime: number = 1
  544. @Local spinDuration: number = 1
  545. @Event onBack: (ans?:string) => void
  546. @Param @Require param: BasicType<TurnTableRouteParams>
  547. aboutToAppear(): void {
  548. this.isRepeat = this.param.generics?.isRepeat!
  549. this.spinDurationTime = this.param.generics?.spinDurationTime!
  550. this.spinDuration = this.param.generics?.spinDuration!
  551. }
  552. build() {
  553. Column() {
  554. //允许结果是否重复
  555. Row() {
  556. Row({ space: 10 }) {
  557. Image($r('app.media.qiehuan')).width(24)
  558. Text('允许结果重复').fontWeight(700)
  559. }
  560. Row() {
  561. Toggle({ type: ToggleType.Switch ,isOn:$$this.isRepeat})
  562. .width(38)
  563. .height(20)
  564. .selectedColor('rgba(253, 84, 227, 1)') //打开状态下的背景颜色
  565. .switchStyle({
  566. pointRadius: 8, //圆形滑块半径
  567. trackBorderRadius: 14, //滑轨的圆角
  568. pointColor: Color.White, //圆形滑块颜色 switchPointColor不生效
  569. unselectedColor: 'rgba(233, 233, 234, 1)' //关闭状态的背景颜色
  570. })
  571. .onClick(() => {
  572. this.isRepeat=!this.isRepeat
  573. })
  574. }
  575. }
  576. .width('100%')
  577. .height(40)
  578. .backgroundColor('#F6F6F6')
  579. .borderRadius(8)
  580. .justifyContent(FlexAlign.SpaceBetween)
  581. .padding({ left: 12, right: 12 })
  582. .alignItems(VerticalAlign.Center)
  583. Row() {
  584. Text('每次转动轮盘可能会随机选中相同的选项').fontSize(12).fontColor('rgba(0, 0, 0, 0.45)')
  585. }.width('100%')
  586. .justifyContent(FlexAlign.Start)
  587. .padding({ left: 22 })
  588. .margin({ bottom: 25, top: 10 })
  589. Row() {
  590. Row({ space: 10 }) {
  591. Image($r('app.media.xuanzhuantime')).width(24)
  592. Text('旋转时长').fontWeight(700)
  593. }
  594. Row() {
  595. Counter() {
  596. Text(this.spinDurationTime.toString() + 's').border({ width: 0 })
  597. }
  598. .onInc(() => {
  599. this.spinDurationTime++
  600. this.spinDuration = this.spinDurationTime * 1000
  601. })
  602. .onDec(() => {
  603. if(this.spinDurationTime==1){
  604. IBestToast.show({
  605. message:'秒数最低为1秒'
  606. })
  607. return
  608. }
  609. this.spinDurationTime--
  610. this.spinDuration = this.spinDurationTime * 1000
  611. })
  612. }
  613. }
  614. .width('100%')
  615. .height(40)
  616. .backgroundColor('#F6F6F6')
  617. .borderRadius(8)
  618. .justifyContent(FlexAlign.SpaceBetween)
  619. .padding({ left: 12, right: 12 })
  620. .alignItems(VerticalAlign.Center)
  621. Row({space: 45}){
  622. Text('取消')
  623. .borderRadius(15)
  624. .fontColor(Color.Black)
  625. .backgroundColor('#F5F5F7')
  626. .padding({left: 30, right: 30, top: 12, bottom: 12})
  627. .onClick(() => {
  628. this.onBack()
  629. })
  630. Text('确定')
  631. .borderRadius(15)
  632. .fontColor(Color.White)
  633. .backgroundColor('#95C50A')
  634. .padding({left: 30, right: 30, top: 12, bottom: 12})
  635. .onClick(() => {
  636. let param: TurnTableRouteParams = {
  637. isRepeat: this.isRepeat,
  638. spinDurationTime: this.spinDurationTime,
  639. spinDuration: this.spinDuration
  640. }
  641. this.onBack(JSON.stringify(param))
  642. })
  643. }
  644. .width("100%")
  645. .justifyContent(FlexAlign.Center)
  646. .padding({top: 16})
  647. }
  648. .width('320')
  649. .height(240)
  650. .padding({ left: 22, top: 30, right: 22, bottom: 20 })
  651. .borderRadius(20)
  652. .backgroundColor(Color.White)
  653. }
  654. }
  655. // 大转盘 - 转盘命名
  656. @ComponentV2
  657. struct BigWheelNameBuilder{
  658. @Local cells: string[] = []
  659. @Event onBack: (ans?:string) => void
  660. @Param @Require param: BasicType<string[]>
  661. aboutToAppear(): void {
  662. this.cells = this.param.generics!
  663. }
  664. build() {
  665. Column() {
  666. Row() {
  667. Text('转盘命名').fontSize(20).fontWeight(500).fontColor('#FF1C1C1C').margin({left:110,right:64,top:24})
  668. Column() {
  669. Image($r('app.media.quxiaocl')).width(10)
  670. }.width(24)
  671. .height(24)
  672. .backgroundColor(Color.White)
  673. .justifyContent(FlexAlign.Center)
  674. .borderRadius('50%')
  675. .onClick(() => {
  676. this.onBack()
  677. })
  678. }.width('100%')
  679. Column({space:10}){
  680. ForEach(this.cells,(item:string,index:number)=>{
  681. Row({space:10}){
  682. Text(`转盘${index}`)
  683. TextInput({text: item})
  684. .width(194)
  685. .height(30)
  686. .padding(0)
  687. .border({width:{bottom:1,left:0,right:0,top:0},color:'rgba(0, 0, 0, 0.3)'})
  688. .borderRadius(0)
  689. .maxLength(5)
  690. .backgroundColor(Color.Transparent)
  691. .onChange((value:string)=>{
  692. this.cells[index] = value
  693. })
  694. }.width('100%')
  695. })
  696. }
  697. Row({space: 45}){
  698. Text('取消')
  699. .borderRadius(15)
  700. .fontColor(Color.Black)
  701. .backgroundColor('#F5F5F7')
  702. .padding({left: 30, right: 30, top: 12, bottom: 12})
  703. .onClick(() => {
  704. this.onBack()
  705. })
  706. Text('确定')
  707. .borderRadius(15)
  708. .fontColor(Color.White)
  709. .backgroundColor('#95C50A')
  710. .padding({left: 30, right: 30, top: 12, bottom: 12})
  711. .onClick(() => {
  712. this.onBack(JSON.stringify(this.cells))
  713. })
  714. }
  715. .width("100%")
  716. .justifyContent(FlexAlign.Center)
  717. .padding({top: 26})
  718. }
  719. .width(300)
  720. .height(280 + ((this.cells.length-3) * 25))
  721. .justifyContent(FlexAlign.Start)
  722. .borderRadius(20)
  723. .padding({left:16,right:16})
  724. .linearGradient({
  725. angle:135,
  726. colors:[
  727. ['rgba(255, 255, 255, 1)',1]
  728. ]
  729. })
  730. }
  731. }