• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import {
2  memo,
3  __memo_context_type,
4  __memo_id_type,
5  State,
6  StateDecoratedVariable,
7  MutableState,
8  stateOf,
9  observableProxy
10} from '@ohos.arkui.stateManagement' // should be insert by ui-plugins
11
12import {
13  Text,
14  TextAttribute,
15  Column,
16  Component,
17  Button,
18  ButtonAttribute,
19  ClickEvent,
20  UserView,
21  ButtonType,
22  ButtonStyleMode,
23  ButtonOptions,
24  ButtonRole,
25  Color,
26  Toggle,
27  ToggleAttribute,
28  ToggleType,
29  Checkbox,
30  CheckboxAttribute,
31  CheckBoxShape,
32  OnCheckboxChangeCallback,
33  OnCheckboxGroupChangeCallback,
34  CheckboxGroup,
35  CheckboxGroupAttribute,
36  CheckboxGroupResult,
37  MarkStyle,
38  NavDestination,
39  NavPathStack,
40  NavDestinationContext,
41  Callback
42} from '@ohos.arkui.component' // TextAttribute should be insert by ui-plugins
43
44import hilog from '@ohos.hilog'
45
46@Component
47export struct CheckboxTest {
48  @State stateVar: string = 'state var';
49  message: string = 'var';
50
51  changeValue() {
52    this.stateVar += '~'
53  }
54  build() {
55    NavDestination() {
56      Column(undefined) {
57        Text('Hello World').fontSize(20)
58        CheckboxGroup({ group: 'checkboxGroup' })
59          .checkboxShape(CheckBoxShape.ROUNDED_SQUARE)
60          .selectedColor('#007DFF')
61          .unselectedColor('#007DFF')
62          .mark({
63            strokeColor: Color.Black,
64            size: 50,
65            strokeWidth: 5
66          } as MarkStyle)
67          .onChange((value: CheckboxGroupResult) => {
68            hilog.info(0x0000, 'testTag', 'checkbox group content' + JSON.stringify(value));
69          } as OnCheckboxGroupChangeCallback)
70
71        Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
72          .select(true)
73          .selectedColor(0xed6f21)
74          .unselectedColor(Color.Pink)
75          .shape(CheckBoxShape.CIRCLE)
76          .onChange((value: boolean) => {
77            hilog.info(0x0000, 'testTag', 'yc--------------' + value);
78          } as OnCheckboxChangeCallback)
79
80        Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
81          .select(true)
82          .selectedColor(0xed6f21)
83          .shape(CheckBoxShape.CIRCLE)
84          .mark({
85            strokeColor: Color.Black,
86            size: 50,
87            strokeWidth: 5
88          } as MarkStyle)
89          .onChange((value: boolean) => {
90            hilog.info(0x0000, 'testTag', 'yc--------------' + value);
91          } as OnCheckboxChangeCallback)
92        Text(this.stateVar).fontSize(20)
93        Child({ stateVar: this.stateVar } as __Options_Child)
94      }
95    }
96    .title('checkbox基础功能测试')
97  }
98}
99
100@Component
101struct Child {
102  @State stateVar: string = 'Child';
103
104  build() {
105    Text(this.stateVar).fontSize(50)
106  }
107}