Skip to content

Commit e595e42

Browse files
Merge pull request #727 from Tencent/feature/td_popover_radius
add:TDPopover添加圆角属性自定义
2 parents a1f018a + 79616fc commit e595e42

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

tdesign-component/example/lib/page/td_popover_page.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ class _TDPopoverPage extends State<TDPopoverPage> {
194194
ExampleItem(
195195
desc: '显示多行内容',
196196
builder: _buildMultiLinePopover,
197+
),
198+
ExampleItem(
199+
desc: '自定义圆角',
200+
builder: _buildCustomRadiusPopover,
197201
)
198202
],
199203
);
@@ -778,4 +782,31 @@ class _TDPopoverPage extends State<TDPopoverPage> {
778782
),
779783
);
780784
}
785+
786+
@Demo(group: 'popover')
787+
Widget _buildCustomRadiusPopover(BuildContext context) {
788+
return Container(
789+
padding: const EdgeInsets.only(top: 0),
790+
margin: const EdgeInsets.all(8),
791+
child: LayoutBuilder(
792+
builder: (_, constraints) {
793+
return TDButton(
794+
size: TDButtonSize.medium,
795+
text: '自定义圆角',
796+
type: TDButtonType.outline,
797+
theme: TDButtonTheme.primary,
798+
799+
onTap: () {
800+
TDPopover.showPopover(
801+
context: _,
802+
width: 200,
803+
radius: BorderRadius.circular(16),
804+
content: '弹出气泡内容弹出气泡内容弹出气泡内容弹出气泡内容',
805+
);
806+
},
807+
);
808+
},
809+
),
810+
);
811+
}
781812
}

tdesign-component/lib/src/components/popover/td_popover.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TDPopover {
2020
Color? overlayColor = Colors.transparent,
2121
OnTap? onTap,
2222
OnLongTap? onLongTap,
23+
BorderRadius? radius,
2324
}) {
2425
return showDialog(
2526
barrierDismissible: closeOnClickOutside,
@@ -40,6 +41,7 @@ class TDPopover {
4041
height: height,
4142
onTap: onTap,
4243
onLongTap: onLongTap,
44+
radius: radius,
4345
),
4446
);
4547
}

tdesign-component/lib/src/components/popover/td_popover_widget.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class TDPopoverWidget extends StatefulWidget {
7878
this.height,
7979
this.onTap,
8080
this.onLongTap,
81+
this.radius
8182
});
8283

8384
/// 上下文
@@ -119,6 +120,9 @@ class TDPopoverWidget extends StatefulWidget {
119120
/// 长按事件
120121
final OnLongTap? onLongTap;
121122

123+
/// 圆角
124+
final BorderRadius? radius;
125+
122126
@override
123127
State<TDPopoverWidget> createState() => _TDPopoverWidgetState();
124128
}
@@ -350,7 +354,7 @@ class _TDPopoverWidgetState extends State<TDPopoverWidget> {
350354
height: widget.height,
351355
padding: widget.padding ?? const EdgeInsets.all(12),
352356
decoration: BoxDecoration(
353-
borderRadius: BorderRadius.circular(6),
357+
borderRadius: widget.radius ?? BorderRadius.circular(6),
354358
color: _backgroundColor,
355359
boxShadow: const [
356360
BoxShadow(color: Color(0x0d000000), offset: Offset(0, 6), blurRadius: 30, spreadRadius: 5),

0 commit comments

Comments
 (0)