1+ import { IBestCell, IBestCellGroup, IBestPopup, IBestToast } from "@ibestservices/ibest-ui"
2+ import { router } from '@kit.ArkUI'
3+ import { ComponentRouterParams } from '../assets/global.type'
4+ import TitleBar from '../components/TitleBar'
5+ import ComponentShowContainer from '../components/ComponentShowContainer'
6+ import { BACKGROUND_COLOR, CONTAINER_SIZE, FONT_SIZE, SPACE } from '../assets/styles/BaseStyle'
7+
8+ @Extend(Column) function positionColStyle(bd: boolean = false){
9+ .layoutWeight(1)
10+ .height("150lpx")
11+ .justifyContent(FlexAlign.Center)
12+ .border({width:{left: bd ? 1 : 0}, color: "#ebedf0"})
13+ }
14+ @Extend(Image) function positionImageStyle(){
15+ .width("50lpx")
16+ .aspectRatio(1)
17+ .fillColor("#333")
18+ }
19+
20+ @Entry
21+ @Component
22+ struct PopupPage {
23+ @State title: string = (router.getParams() as ComponentRouterParams).title || ''
24+ @State baseVisible: boolean = false
25+ @State upVisible: boolean = false
26+ @State downVisible: boolean = false
27+ @State leftVisible: boolean = false
28+ @State rightVisible: boolean = false
29+ @State showHeaderVisible: boolean = false
30+ @State cusCloseIconVisible: boolean = false
31+ @State centerCornerVisible: boolean = false
32+ @State bottomCornerVisible: boolean = false
33+ @State eventVisible: boolean = false
34+ @State safeAreaVisible: boolean = false
35+
36+ @Builder baseBuilder() {
37+ Column(){
38+ Text("内容")
39+ }
40+ }
41+ @Builder safeBuilder() {
42+ Column(){
43+ Text("内容")
44+ Text("内容")
45+ }
46+ .width("100%")
47+ .height("100%")
48+ .justifyContent(FlexAlign.SpaceBetween)
49+ .alignItems(HorizontalAlign.Center)
50+ }
51+
52+ build() {
53+ Column(){
54+ TitleBar({
55+ title: this.title
56+ }).backgroundColor('#FFF')
57+ List() {
58+ ListItem() {
59+ ComponentShowContainer({ title: '基础用法', titlePaddingLeft: SPACE.SMALL }) {
60+ IBestCellGroup({ inset: true }) {
61+ Column() {
62+ IBestCell({
63+ title: '展示弹出层',
64+ isLink: true,
65+ hasBorder: false,
66+ onClickCell: () => {
67+ this.baseVisible = true
68+ }
69+ })
70+ }
71+ }
72+ }
73+ }
74+ ListItem() {
75+ ComponentShowContainer({ title: '弹出位置', titlePaddingLeft: SPACE.SMALL }) {
76+ IBestCellGroup({ inset: true }) {
77+ Row(){
78+ Column(){
79+ Image($r("app.media.arrow_up"))
80+ .positionImageStyle()
81+ Text("顶部弹出")
82+ .margin({top: "16lpx"})
83+ .fontSize(FONT_SIZE.MINI)
84+ }
85+ .positionColStyle()
86+ .onClick(() => {
87+ this.upVisible = true
88+ })
89+ Column(){
90+ Image($r("app.media.arrow_down"))
91+ .positionImageStyle()
92+ Text("底部弹出")
93+ .margin({top: "16lpx"})
94+ .fontSize(FONT_SIZE.MINI)
95+ }
96+ .positionColStyle(true)
97+ .onClick(() => {
98+ this.downVisible = true
99+ })
100+ Column(){
101+ Image($r("app.media.arrow_left"))
102+ .positionImageStyle()
103+ Text("左侧弹出")
104+ .margin({top: "16lpx"})
105+ .fontSize(FONT_SIZE.MINI)
106+ }
107+ .positionColStyle(true)
108+ .onClick(() => {
109+ this.leftVisible = true
110+ })
111+ Column(){
112+ Image($r("app.media.arrow_right"))
113+ .positionImageStyle()
114+ Text("右侧弹出")
115+ .margin({top: "16lpx"})
116+ .fontSize(FONT_SIZE.MINI)
117+ }
118+ .positionColStyle(true)
119+ .onClick(() => {
120+ this.rightVisible = true
121+ })
122+ }
123+ .width(CONTAINER_SIZE.FULL)
124+ .backgroundColor("#fff")
125+ }
126+ }
127+ }
128+ ListItem() {
129+ ComponentShowContainer({ title: '显示标题', titlePaddingLeft: SPACE.SMALL }) {
130+ IBestCellGroup({ inset: true }) {
131+ Column() {
132+ IBestCell({
133+ title: '显示标题',
134+ isLink: true,
135+ onClickCell: () => {
136+ this.showHeaderVisible = true
137+ }
138+ })
139+ IBestCell({
140+ title: '自定义关闭图标',
141+ isLink: true,
142+ hasBorder: false,
143+ onClickCell: () => {
144+ this.cusCloseIconVisible = true
145+ }
146+ })
147+ }
148+ }
149+ }
150+ }
151+ ListItem() {
152+ ComponentShowContainer({ title: '圆角弹窗', titlePaddingLeft: SPACE.SMALL }) {
153+ IBestCellGroup({ inset: true }) {
154+ Column() {
155+ IBestCell({
156+ title: '圆角弹窗(居中)',
157+ isLink: true,
158+ onClickCell: () => {
159+ this.centerCornerVisible = true
160+ }
161+ })
162+ IBestCell({
163+ title: '圆角弹窗(底部)',
164+ isLink: true,
165+ hasBorder: false,
166+ onClickCell: () => {
167+ this.bottomCornerVisible = true
168+ }
169+ })
170+ }
171+ }
172+ }
173+ }
174+ ListItem() {
175+ ComponentShowContainer({ title: '事件监听', titlePaddingLeft: SPACE.SMALL }) {
176+ IBestCellGroup({ inset: true }) {
177+ Column() {
178+ IBestCell({
179+ title: '监听显示事件',
180+ isLink: true,
181+ hasBorder: false,
182+ onClickCell: () => {
183+ this.eventVisible = true
184+ }
185+ })
186+ }
187+ }
188+ }
189+ }
190+ ListItem() {
191+ ComponentShowContainer({ title: '安全区域适配', titlePaddingLeft: SPACE.SMALL }) {
192+ IBestCellGroup({ inset: true }) {
193+ Column() {
194+ IBestCell({
195+ title: '安全区域适配',
196+ isLink: true,
197+ hasBorder: false,
198+ onClickCell: () => {
199+ this.safeAreaVisible = true
200+ }
201+ })
202+ }
203+ }
204+ }
205+ }
206+ }
207+ .layoutWeight(1)
208+ // 基础展示
209+ IBestPopup({
210+ visible: this.baseVisible
211+ })
212+ // 弹框位置
213+ IBestPopup({
214+ visible: this.upVisible,
215+ popupAlign: "top"
216+ })
217+ IBestPopup({
218+ visible: this.downVisible,
219+ popupAlign: "bottom"
220+ })
221+ IBestPopup({
222+ visible: this.leftVisible,
223+ popupAlign: "left"
224+ })
225+ IBestPopup({
226+ visible: this.rightVisible,
227+ popupAlign: "right"
228+ })
229+ // 关闭图标
230+ IBestPopup({
231+ visible: this.showHeaderVisible,
232+ popupAlign: "bottom",
233+ isShowHeader: true,
234+ title: "标题"
235+ })
236+ IBestPopup({
237+ visible: this.cusCloseIconVisible,
238+ popupAlign: "bottom",
239+ isShowHeader: true,
240+ title: "标题",
241+ closeIcon: "https://ibestui.ibestservices.com/favicon.ico"
242+ })
243+ // 圆角弹窗
244+ IBestPopup({
245+ visible: this.centerCornerVisible,
246+ cornerRadius: 10
247+ })
248+ IBestPopup({
249+ visible: this.bottomCornerVisible,
250+ popupAlign: "bottom",
251+ cornerRadius: 30
252+ })
253+ // 事件监听
254+ IBestPopup({
255+ visible: this.eventVisible,
256+ popupAlign: "bottom",
257+ onOpen: () => {
258+ IBestToast.show("open")
259+ },
260+ onClose: () => {
261+ IBestToast.show("close")
262+ }
263+ })
264+ // 安全区域适配
265+ IBestPopup({
266+ visible: this.safeAreaVisible,
267+ popupAlign: "left",
268+ contentBuilder: this.safeBuilder,
269+ safeAreaInsetTop: true,
270+ safeAreaInsetBottom: true
271+ })
272+ }
273+ .width(CONTAINER_SIZE.FULL)
274+ .height(CONTAINER_SIZE.FULL)
275+ .backgroundColor(BACKGROUND_COLOR.BASE)
276+ }
277+ }
0 commit comments