1e41f4b71Sopenharmony_ci# Modal Transition
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciYou can bind a full-screen modal to a component through the **bindContentCover** attribute. Better yet, with the **ModalTransition** parameter, you can apply a transition effect for when the component is inserted or deleted.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  The APIs of this module are supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci>  Switching between landscape and portrait modes is not supported.
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci>  Route hopping is not supported.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## bindContentCover
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_cibindContentCover(isShow: Optional\<boolean\>, builder: CustomBuilder, options?: ContentCoverOptions)
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciBinds a modal to the component, which can be displayed when the component is touched. The content of the modal is customizable. The transition type can be set to none, slide-up and slide-down animation, and opacity gradient animation.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Parameters**
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci| Name | Type                                       | Mandatory| Description                                                        |
26e41f4b71Sopenharmony_ci| ------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
27e41f4b71Sopenharmony_ci| isShow  | Optional\<boolean\>                         | Yes  | Whether to display the modal.<br>Since API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).|
28e41f4b71Sopenharmony_ci| builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes  | Content of the modal.                                      |
29e41f4b71Sopenharmony_ci| options | [ContentCoverOptions](#contentcoveroptions) | No  | Optional attributes of the modal.                                |
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci## ContentCoverOptions
32e41f4b71Sopenharmony_ciInherited from [BindOptions](ts-universal-attributes-sheet-transition.md#bindoptions).
33e41f4b71Sopenharmony_ci| Name             | Type                                      | Mandatory  | Description           |
34e41f4b71Sopenharmony_ci| --------------- | ---------------------------------------- | ---- | ------------- |
35e41f4b71Sopenharmony_ci| modalTransition | [ModalTransition](ts-types.md#modaltransition10) | No   | Transition mode of the modal.<br>**Atomic service API**: This API can be used in atomic services since API version 11. |
36e41f4b71Sopenharmony_ci| onWillDismiss<sup>12+</sup> | Callback&lt;[DismissContentCoverAction](#dismisscontentcoveraction12)&gt; | No   | Callback invoked to prevent a user-initiated attempt to close the modal.<br>**NOTE**<br>After this callback is registered, touching the Back button does not immediately close the modal. The **reason** parameter in the callback indicates the type of action that prevents the modal from being closed. You can specify whether to actually close the modal for the action. No more **onWillDismiss** callback is allowed in an **onWillDismiss** callback.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
37e41f4b71Sopenharmony_ci| transition<sup>12+</sup> | [TransitionEffect](ts-transition-animation-component.md#transitioneffect10) | No   | Transition mode of the modal.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci## DismissContentCoverAction<sup>12+</sup>
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| Name             | Type                                      | Mandatory  | Description           |
44e41f4b71Sopenharmony_ci| --------------- | ---------------------------------------- | ---- | ------------- |
45e41f4b71Sopenharmony_ci| dismiss | function | Yes   | Callback invoked when the modal is closed. Called when you need to exit the page.|
46e41f4b71Sopenharmony_ci| reason | [DismissReason](ts-universal-attributes-popup.md#dismissreason12) | Yes   | Reason why the modal cannot be closed, that is, the type of action that prevents the modal from being closed. |
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci## Example
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci### Example 1
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciThis example applies a custom animation to two modals whose transition type is none.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci```ts
55e41f4b71Sopenharmony_ci// xxx.ets
56e41f4b71Sopenharmony_ci@Entry
57e41f4b71Sopenharmony_ci@Component
58e41f4b71Sopenharmony_cistruct ModalTransitionExample {
59e41f4b71Sopenharmony_ci  @State isShow:boolean = false
60e41f4b71Sopenharmony_ci  @State isShow2:boolean = false
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci  @Builder myBuilder2() {
63e41f4b71Sopenharmony_ci    Column() {
64e41f4b71Sopenharmony_ci      Button("close modal 2")
65e41f4b71Sopenharmony_ci        .margin(10)
66e41f4b71Sopenharmony_ci        .fontSize(20)
67e41f4b71Sopenharmony_ci        .onClick(()=>{
68e41f4b71Sopenharmony_ci          this.isShow2 = false;
69e41f4b71Sopenharmony_ci        })
70e41f4b71Sopenharmony_ci    }
71e41f4b71Sopenharmony_ci    .width('100%')
72e41f4b71Sopenharmony_ci    .height('100%')
73e41f4b71Sopenharmony_ci  }
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci  @Builder myBuilder() {
76e41f4b71Sopenharmony_ci    Column() {
77e41f4b71Sopenharmony_ci      Button("transition modal 2")
78e41f4b71Sopenharmony_ci        .margin(10)
79e41f4b71Sopenharmony_ci        .fontSize(20)
80e41f4b71Sopenharmony_ci        .onClick(()=>{
81e41f4b71Sopenharmony_ci          this.isShow2 = true;
82e41f4b71Sopenharmony_ci        }).bindContentCover(this.isShow2, this.myBuilder2(), {
83e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.NONE, 
84e41f4b71Sopenharmony_ci          backgroundColor: Color.Orange, 
85e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
86e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
87e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
88e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
89e41f4b71Sopenharmony_ci        })
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci      Button("close modal 1")
92e41f4b71Sopenharmony_ci        .margin(10)
93e41f4b71Sopenharmony_ci        .fontSize(20)
94e41f4b71Sopenharmony_ci        .onClick(()=>{
95e41f4b71Sopenharmony_ci          this.isShow = false;
96e41f4b71Sopenharmony_ci        })
97e41f4b71Sopenharmony_ci    }
98e41f4b71Sopenharmony_ci    .width('100%')
99e41f4b71Sopenharmony_ci    .height('100%')
100e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
101e41f4b71Sopenharmony_ci  }
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci  build() {
104e41f4b71Sopenharmony_ci    Column() {
105e41f4b71Sopenharmony_ci      Button("transition modal 1")
106e41f4b71Sopenharmony_ci        .onClick(() => {
107e41f4b71Sopenharmony_ci          this.isShow = true
108e41f4b71Sopenharmony_ci        })
109e41f4b71Sopenharmony_ci        .fontSize(20)
110e41f4b71Sopenharmony_ci        .margin(10)
111e41f4b71Sopenharmony_ci        .bindContentCover(this.isShow, this.myBuilder(), {
112e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.NONE, 
113e41f4b71Sopenharmony_ci          backgroundColor: Color.Pink, 
114e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
115e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
116e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
117e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
118e41f4b71Sopenharmony_ci        })
119e41f4b71Sopenharmony_ci    }
120e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
121e41f4b71Sopenharmony_ci    .backgroundColor("#ff49c8ab")
122e41f4b71Sopenharmony_ci    .width('100%')
123e41f4b71Sopenharmony_ci    .height('100%')
124e41f4b71Sopenharmony_ci  }
125e41f4b71Sopenharmony_ci}
126e41f4b71Sopenharmony_ci```
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci![en-us_full_screen_modal_none_1](figures/en-us_full_screen_modal_none_1.gif)
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci### Example 2
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ciThis example applies a custom animation to two modals whose transition type is none.
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```ts
135e41f4b71Sopenharmony_ci// xxx.ets
136e41f4b71Sopenharmony_ciimport { curves } from '@kit.ArkUI';
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci@Entry
139e41f4b71Sopenharmony_ci@Component
140e41f4b71Sopenharmony_cistruct ModalTransitionExample {
141e41f4b71Sopenharmony_ci  @State  @Watch("isShow1Change") isShow:boolean = false
142e41f4b71Sopenharmony_ci  @State  @Watch("isShow2Change") isShow2:boolean = false
143e41f4b71Sopenharmony_ci  @State isScale1:number = 1;
144e41f4b71Sopenharmony_ci  @State isScale2:number = 1;
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci  isShow1Change() {
147e41f4b71Sopenharmony_ci    this.isShow ? this.isScale1 = 0.95 : this.isScale1 = 1
148e41f4b71Sopenharmony_ci  }
149e41f4b71Sopenharmony_ci  isShow2Change() {
150e41f4b71Sopenharmony_ci    this.isShow2 ? this.isScale2 = 0.95 : this.isScale2 = 1
151e41f4b71Sopenharmony_ci  }
152e41f4b71Sopenharmony_ci  @Builder myBuilder2() {
153e41f4b71Sopenharmony_ci    Column() {
154e41f4b71Sopenharmony_ci      Button("close modal 2")
155e41f4b71Sopenharmony_ci        .margin(10)
156e41f4b71Sopenharmony_ci        .fontSize(20)
157e41f4b71Sopenharmony_ci        .onClick(()=>{
158e41f4b71Sopenharmony_ci          this.isShow2 = false;
159e41f4b71Sopenharmony_ci        })
160e41f4b71Sopenharmony_ci    }
161e41f4b71Sopenharmony_ci    .width('100%')
162e41f4b71Sopenharmony_ci    .height('100%')
163e41f4b71Sopenharmony_ci  }
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci  @Builder myBuilder() {
167e41f4b71Sopenharmony_ci    Column() {
168e41f4b71Sopenharmony_ci      Button("transition modal 2")
169e41f4b71Sopenharmony_ci        .margin(10)
170e41f4b71Sopenharmony_ci        .fontSize(20)
171e41f4b71Sopenharmony_ci        .onClick(()=>{
172e41f4b71Sopenharmony_ci          this.isShow2 = true;
173e41f4b71Sopenharmony_ci        }).bindContentCover(this.isShow2, this.myBuilder2(), {
174e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.NONE, 
175e41f4b71Sopenharmony_ci          backgroundColor: Color.Orange, 
176e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
177e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
178e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
179e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
180e41f4b71Sopenharmony_ci        })
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci      Button("close modal 1")
183e41f4b71Sopenharmony_ci        .margin(10)
184e41f4b71Sopenharmony_ci        .fontSize(20)
185e41f4b71Sopenharmony_ci        .onClick(()=>{
186e41f4b71Sopenharmony_ci          this.isShow = false;
187e41f4b71Sopenharmony_ci        })
188e41f4b71Sopenharmony_ci    }
189e41f4b71Sopenharmony_ci    .width('100%')
190e41f4b71Sopenharmony_ci    .height('100%')
191e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
192e41f4b71Sopenharmony_ci    .scale({x: this.isScale2, y: this.isScale2})
193e41f4b71Sopenharmony_ci    .animation({curve:curves.springMotion()})
194e41f4b71Sopenharmony_ci  }
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci  build() {
197e41f4b71Sopenharmony_ci    Column() {
198e41f4b71Sopenharmony_ci      Button("transition modal 1")
199e41f4b71Sopenharmony_ci        .onClick(() => {
200e41f4b71Sopenharmony_ci          this.isShow = true
201e41f4b71Sopenharmony_ci        })
202e41f4b71Sopenharmony_ci        .fontSize(20)
203e41f4b71Sopenharmony_ci        .margin(10)
204e41f4b71Sopenharmony_ci        .bindContentCover(this.isShow, this.myBuilder(), {
205e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.NONE, 
206e41f4b71Sopenharmony_ci          backgroundColor: Color.Pink, 
207e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
208e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
209e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
210e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
211e41f4b71Sopenharmony_ci        })
212e41f4b71Sopenharmony_ci    }
213e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
214e41f4b71Sopenharmony_ci    .backgroundColor("#ff49c8ab")
215e41f4b71Sopenharmony_ci    .width('100%')
216e41f4b71Sopenharmony_ci    .height('100%')
217e41f4b71Sopenharmony_ci    .scale({ x: this.isScale1, y: this.isScale1 })
218e41f4b71Sopenharmony_ci    .animation({ curve: curves.springMotion() })
219e41f4b71Sopenharmony_ci  }
220e41f4b71Sopenharmony_ci}
221e41f4b71Sopenharmony_ci```
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci![en-us_full_screen_modal_none_2](figures/en-us_full_screen_modal_none_2.gif)
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci### Example 3
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ciThis example shows two modals whose transition type is slide-up and slide-down animation.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci```ts
230e41f4b71Sopenharmony_ci// xxx.ets
231e41f4b71Sopenharmony_ci@Entry
232e41f4b71Sopenharmony_ci@Component
233e41f4b71Sopenharmony_cistruct ModalTransitionExample {
234e41f4b71Sopenharmony_ci  @State isShow:boolean = false
235e41f4b71Sopenharmony_ci  @State isShow2:boolean = false
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci  @Builder myBuilder2() {
238e41f4b71Sopenharmony_ci    Column() {
239e41f4b71Sopenharmony_ci      Button("close modal 2")
240e41f4b71Sopenharmony_ci        .margin(10)
241e41f4b71Sopenharmony_ci        .fontSize(20)
242e41f4b71Sopenharmony_ci        .onClick(()=>{
243e41f4b71Sopenharmony_ci          this.isShow2 = false;
244e41f4b71Sopenharmony_ci        })
245e41f4b71Sopenharmony_ci    }
246e41f4b71Sopenharmony_ci    .width('100%')
247e41f4b71Sopenharmony_ci    .height('100%')
248e41f4b71Sopenharmony_ci  }
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci  @Builder myBuilder() {
251e41f4b71Sopenharmony_ci    Column() {
252e41f4b71Sopenharmony_ci      Button("transition modal 2")
253e41f4b71Sopenharmony_ci        .margin(10)
254e41f4b71Sopenharmony_ci        .fontSize(20)
255e41f4b71Sopenharmony_ci        .onClick(()=>{
256e41f4b71Sopenharmony_ci          this.isShow2 = true;
257e41f4b71Sopenharmony_ci        }).bindContentCover(this.isShow2, this.myBuilder2(), {
258e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.DEFAULT, 
259e41f4b71Sopenharmony_ci          backgroundColor: Color.Gray, 
260e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
261e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
262e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
263e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
264e41f4b71Sopenharmony_ci        })
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci      Button("close modal 1")
267e41f4b71Sopenharmony_ci        .margin(10)
268e41f4b71Sopenharmony_ci        .fontSize(20)
269e41f4b71Sopenharmony_ci        .onClick(()=>{
270e41f4b71Sopenharmony_ci          this.isShow = false;
271e41f4b71Sopenharmony_ci        })
272e41f4b71Sopenharmony_ci    }
273e41f4b71Sopenharmony_ci    .width('100%')
274e41f4b71Sopenharmony_ci    .height('100%')
275e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
276e41f4b71Sopenharmony_ci  }
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci  build() {
279e41f4b71Sopenharmony_ci    Column() {
280e41f4b71Sopenharmony_ci      Button("transition modal 1")
281e41f4b71Sopenharmony_ci        .onClick(() => {
282e41f4b71Sopenharmony_ci          this.isShow = true
283e41f4b71Sopenharmony_ci        })
284e41f4b71Sopenharmony_ci        .fontSize(20)
285e41f4b71Sopenharmony_ci        .margin(10)
286e41f4b71Sopenharmony_ci        .bindContentCover(this.isShow, this.myBuilder(), {
287e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.DEFAULT, 
288e41f4b71Sopenharmony_ci          backgroundColor: Color.Pink, 
289e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
290e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
291e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
292e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
293e41f4b71Sopenharmony_ci        })
294e41f4b71Sopenharmony_ci    }
295e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
296e41f4b71Sopenharmony_ci    .backgroundColor(Color.White)
297e41f4b71Sopenharmony_ci    .width('100%')
298e41f4b71Sopenharmony_ci    .height('100%')
299e41f4b71Sopenharmony_ci  }
300e41f4b71Sopenharmony_ci}
301e41f4b71Sopenharmony_ci```
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci![en-us_full_screen_modal_default](figures/en-us_full_screen_modal_default.gif)
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci### Example 4
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ciThis example shows two modals whose transition type is opacity gradient animation.
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci```ts
310e41f4b71Sopenharmony_ci// xxx.ets
311e41f4b71Sopenharmony_ci@Entry
312e41f4b71Sopenharmony_ci@Component
313e41f4b71Sopenharmony_cistruct ModalTransitionExample {
314e41f4b71Sopenharmony_ci  @State isShow:boolean = false
315e41f4b71Sopenharmony_ci  @State isShow2:boolean = false
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci  @Builder myBuilder2() {
318e41f4b71Sopenharmony_ci    Column() {
319e41f4b71Sopenharmony_ci      Button("close modal 2")
320e41f4b71Sopenharmony_ci        .margin(10)
321e41f4b71Sopenharmony_ci        .fontSize(20)
322e41f4b71Sopenharmony_ci        .onClick(()=>{
323e41f4b71Sopenharmony_ci          this.isShow2 = false;
324e41f4b71Sopenharmony_ci        })
325e41f4b71Sopenharmony_ci    }
326e41f4b71Sopenharmony_ci    .width('100%')
327e41f4b71Sopenharmony_ci    .height('100%')
328e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
329e41f4b71Sopenharmony_ci  }
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci  @Builder myBuilder() {
333e41f4b71Sopenharmony_ci    Column() {
334e41f4b71Sopenharmony_ci      Button("transition modal 2")
335e41f4b71Sopenharmony_ci        .margin(10)
336e41f4b71Sopenharmony_ci        .fontSize(20)
337e41f4b71Sopenharmony_ci        .onClick(()=>{
338e41f4b71Sopenharmony_ci          this.isShow2 = true;
339e41f4b71Sopenharmony_ci        }).bindContentCover(this.isShow2, this.myBuilder2(), {
340e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.ALPHA, 
341e41f4b71Sopenharmony_ci          backgroundColor: Color.Gray, 
342e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
343e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
344e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
345e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
346e41f4b71Sopenharmony_ci        })
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ci      Button("close modal 1")
349e41f4b71Sopenharmony_ci        .margin(10)
350e41f4b71Sopenharmony_ci        .fontSize(20)
351e41f4b71Sopenharmony_ci        .onClick(()=>{
352e41f4b71Sopenharmony_ci          this.isShow = false;
353e41f4b71Sopenharmony_ci        })
354e41f4b71Sopenharmony_ci    }
355e41f4b71Sopenharmony_ci    .width('100%')
356e41f4b71Sopenharmony_ci    .height('100%')
357e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
358e41f4b71Sopenharmony_ci  }
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci  build() {
361e41f4b71Sopenharmony_ci    Column() {
362e41f4b71Sopenharmony_ci      Button("transition modal 1")
363e41f4b71Sopenharmony_ci        .onClick(() => {
364e41f4b71Sopenharmony_ci          this.isShow = true
365e41f4b71Sopenharmony_ci        })
366e41f4b71Sopenharmony_ci        .fontSize(20)
367e41f4b71Sopenharmony_ci        .margin(10)
368e41f4b71Sopenharmony_ci        .bindContentCover(this.isShow, this.myBuilder(), {
369e41f4b71Sopenharmony_ci          modalTransition: ModalTransition.ALPHA, 
370e41f4b71Sopenharmony_ci          backgroundColor: Color.Pink, 
371e41f4b71Sopenharmony_ci          onWillAppear: () => {console.log("BindContentCover onWillAppear.")}, 
372e41f4b71Sopenharmony_ci          onAppear: () => {console.log("BindContentCover onAppear.")}, 
373e41f4b71Sopenharmony_ci          onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")}, 
374e41f4b71Sopenharmony_ci          onDisappear: () => {console.log("BindContentCover onDisappear.")}
375e41f4b71Sopenharmony_ci        })
376e41f4b71Sopenharmony_ci    }
377e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
378e41f4b71Sopenharmony_ci    .backgroundColor(Color.White)
379e41f4b71Sopenharmony_ci    .width('100%')
380e41f4b71Sopenharmony_ci    .height('100%')
381e41f4b71Sopenharmony_ci  }
382e41f4b71Sopenharmony_ci}
383e41f4b71Sopenharmony_ci```
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci![en-us_full_screen_modal_alpha](figures/en-us_full_screen_modal_alpha.gif)
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci### Example 5
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ciThis example shows a modal with a custom transition.
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci```ts
392e41f4b71Sopenharmony_ci// xxx.ets
393e41f4b71Sopenharmony_ci@Entry
394e41f4b71Sopenharmony_ci@Component
395e41f4b71Sopenharmony_cistruct ModalTransitionExample {
396e41f4b71Sopenharmony_ci  @State isShow:boolean = false
397e41f4b71Sopenharmony_ci  @State isShow2:boolean = false
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci  @Builder myBuilder2() {
400e41f4b71Sopenharmony_ci    Column() {
401e41f4b71Sopenharmony_ci      Button("Close Modal 2")
402e41f4b71Sopenharmony_ci        .margin(10)
403e41f4b71Sopenharmony_ci        .fontSize(20)
404e41f4b71Sopenharmony_ci        .onClick(()=>{
405e41f4b71Sopenharmony_ci          this.isShow2 = false;
406e41f4b71Sopenharmony_ci        })
407e41f4b71Sopenharmony_ci    }
408e41f4b71Sopenharmony_ci    .width('100%')
409e41f4b71Sopenharmony_ci    .height('100%')
410e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
411e41f4b71Sopenharmony_ci  }
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci  @Builder myBuilder() {
414e41f4b71Sopenharmony_ci    Column() {
415e41f4b71Sopenharmony_ci      Button("Transition Modal 2")
416e41f4b71Sopenharmony_ci        .margin(10)
417e41f4b71Sopenharmony_ci        .fontSize(20)
418e41f4b71Sopenharmony_ci        .onClick(()=>{
419e41f4b71Sopenharmony_ci          this.isShow2 = true;
420e41f4b71Sopenharmony_ci        })
421e41f4b71Sopenharmony_ci        .bindContentCover(
422e41f4b71Sopenharmony_ci          this.isShow2,
423e41f4b71Sopenharmony_ci          this.myBuilder2(),
424e41f4b71Sopenharmony_ci          {
425e41f4b71Sopenharmony_ci            modalTransition: ModalTransition.DEFAULT,
426e41f4b71Sopenharmony_ci            backgroundColor: Color.Gray,
427e41f4b71Sopenharmony_ci            transition: TransitionEffect.SLIDE.animation({ duration: 5000, curve: Curve.LinearOutSlowIn }),
428e41f4b71Sopenharmony_ci            onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => {
429e41f4b71Sopenharmony_ci              if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) {
430e41f4b71Sopenharmony_ci                console.log("BindContentCover dismiss reason is back pressed")
431e41f4b71Sopenharmony_ci              }
432e41f4b71Sopenharmony_ci              dismissContentCoverAction.dismiss()
433e41f4b71Sopenharmony_ci            }),
434e41f4b71Sopenharmony_ci            onAppear: () => { console.info("BindContentCover onAppear.") },
435e41f4b71Sopenharmony_ci            onDisappear: () => { this.isShow2 = false; console.info("BindContentCover onDisappear.") }
436e41f4b71Sopenharmony_ci          })
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci      Button("Close Modal 1")
439e41f4b71Sopenharmony_ci        .margin(10)
440e41f4b71Sopenharmony_ci        .fontSize(20)
441e41f4b71Sopenharmony_ci        .onClick(()=>{
442e41f4b71Sopenharmony_ci          this.isShow = false;
443e41f4b71Sopenharmony_ci        })
444e41f4b71Sopenharmony_ci    }
445e41f4b71Sopenharmony_ci    .width('100%')
446e41f4b71Sopenharmony_ci    .height('100%')
447e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
448e41f4b71Sopenharmony_ci  }
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci  build() {
451e41f4b71Sopenharmony_ci    Column() {
452e41f4b71Sopenharmony_ci      Button("Transition Modal 1")
453e41f4b71Sopenharmony_ci        .onClick(() => {
454e41f4b71Sopenharmony_ci          this.isShow = true
455e41f4b71Sopenharmony_ci        })
456e41f4b71Sopenharmony_ci        .fontSize(20)
457e41f4b71Sopenharmony_ci        .margin(10)
458e41f4b71Sopenharmony_ci        .bindContentCover(
459e41f4b71Sopenharmony_ci          this.isShow,
460e41f4b71Sopenharmony_ci          this.myBuilder(),
461e41f4b71Sopenharmony_ci          {
462e41f4b71Sopenharmony_ci            modalTransition: ModalTransition.DEFAULT,
463e41f4b71Sopenharmony_ci            backgroundColor: Color.Pink,
464e41f4b71Sopenharmony_ci            transition: TransitionEffect.asymmetric(
465e41f4b71Sopenharmony_ci              TransitionEffect.OPACITY.animation({ duration: 1100 }).combine(
466e41f4b71Sopenharmony_ci                TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ delay: 1000, duration: 1000 }))
467e41f4b71Sopenharmony_ci              ,
468e41f4b71Sopenharmony_ci              TransitionEffect.OPACITY.animation({ duration: 1200 }).combine(
469e41f4b71Sopenharmony_ci                TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ duration: 1300 }))
470e41f4b71Sopenharmony_ci            ),
471e41f4b71Sopenharmony_ci            onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => {
472e41f4b71Sopenharmony_ci              if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) {
473e41f4b71Sopenharmony_ci                console.log("back pressed");
474e41f4b71Sopenharmony_ci              }
475e41f4b71Sopenharmony_ci              dismissContentCoverAction.dismiss()
476e41f4b71Sopenharmony_ci            }),
477e41f4b71Sopenharmony_ci            onAppear: () => { console.log("BindContentCover onAppear.") },
478e41f4b71Sopenharmony_ci            onDisappear: () => { this.isShow = false; console.log("BindContentCover onDisappear.") }
479e41f4b71Sopenharmony_ci          })
480e41f4b71Sopenharmony_ci    }
481e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
482e41f4b71Sopenharmony_ci    .backgroundColor(Color.White)
483e41f4b71Sopenharmony_ci    .width('100%')
484e41f4b71Sopenharmony_ci    .height('100%')
485e41f4b71Sopenharmony_ci  }
486e41f4b71Sopenharmony_ci}
487e41f4b71Sopenharmony_ci```
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci![en-us_full_screen_modal_alpha](figures/en-us_full_screen_modal_transition.gif)
490