Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDDialogButtonOptions新增属性字体大小 #381

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions tdesign-component/lib/src/components/button/td_button_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ import '../../../tdesign_flutter.dart';
class TDButtonStyle {
/// 背景颜色
Color? backgroundColor;

/// 边框颜色
Color? frameColor;

/// 文字颜色
Color? textColor;

/// 边框宽度
double? frameWidth;

/// 自定义圆角
BorderRadiusGeometry? radius;

TDButtonStyle(
{this.backgroundColor,
this.frameColor,
this.textColor,
this.frameWidth,
this.radius});
TDButtonStyle({this.backgroundColor, this.frameColor, this.textColor, this.frameWidth, this.radius});

/// 生成不同主题的填充按钮样式
TDButtonStyle.generateFillStyleByTheme(
BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
TDButtonStyle.generateFillStyleByTheme(BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
switch (theme) {
case TDButtonTheme.primary:
textColor = TDTheme.of(context).fontWhColor1;
Expand All @@ -47,17 +45,18 @@ class TDButtonStyle {
}

/// 生成不同主题的描边按钮样式
TDButtonStyle.generateOutlineStyleByTheme(
BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
TDButtonStyle.generateOutlineStyleByTheme(BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
switch (theme) {
case TDButtonTheme.primary:
textColor = _getBrandColor(context, status);
backgroundColor = status == TDButtonStatus.active ? TDTheme.of(context).grayColor3 : TDTheme.of(context).whiteColor1;
backgroundColor =
status == TDButtonStatus.active ? TDTheme.of(context).grayColor3 : TDTheme.of(context).whiteColor1;
frameColor = textColor;
break;
case TDButtonTheme.danger:
textColor = _getErrorColor(context, status);
backgroundColor = status == TDButtonStatus.active ? TDTheme.of(context).grayColor3 : TDTheme.of(context).whiteColor1;
backgroundColor =
status == TDButtonStatus.active ? TDTheme.of(context).grayColor3 : TDTheme.of(context).whiteColor1;
frameColor = textColor;
break;
case TDButtonTheme.light:
Expand All @@ -75,8 +74,7 @@ class TDButtonStyle {
}

/// 生成不同主题的文本按钮样式
TDButtonStyle.generateTextStyleByTheme(
BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
TDButtonStyle.generateTextStyleByTheme(BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
switch (theme) {
case TDButtonTheme.primary:
textColor = _getBrandColor(context, status);
Expand All @@ -99,26 +97,28 @@ class TDButtonStyle {
}

/// 生成不同主题的幽灵按钮样式
TDButtonStyle.generateGhostStyleByTheme(
BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
TDButtonStyle.generateGhostStyleByTheme(BuildContext context, TDButtonTheme? theme, TDButtonStatus status) {
switch (theme) {
case TDButtonTheme.primary:
textColor = status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 : _getBrandColor(context, status);
textColor =
status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 : _getBrandColor(context, status);
break;
case TDButtonTheme.danger:
textColor = status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 :_getErrorColor(context, status);
textColor =
status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 : _getErrorColor(context, status);
break;
case TDButtonTheme.light:
textColor = status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 :_getBrandColor(context, status);
textColor =
status == TDButtonStatus.disable ? TDTheme.of(context).fontWhColor4 : _getBrandColor(context, status);
break;
case TDButtonTheme.defaultTheme:
default:
switch(status){
switch (status) {
case TDButtonStatus.active:
textColor = TDTheme.of(context).fontWhColor2;
textColor = TDTheme.of(context).fontWhColor2;
break;
case TDButtonStatus.disable:
textColor = TDTheme.of(context).fontWhColor4;
textColor = TDTheme.of(context).fontWhColor4;
break;
default:
textColor = TDTheme.of(context).fontWhColor1;
Expand All @@ -130,7 +130,7 @@ class TDButtonStyle {
}

Color _getBrandColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
return TDTheme.of(context).brandNormalColor;
case TDButtonStatus.active:
Expand All @@ -141,7 +141,7 @@ class TDButtonStyle {
}

Color _getLightColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
case TDButtonStatus.disable:
return TDTheme.of(context).brandLightColor;
Expand All @@ -151,7 +151,7 @@ class TDButtonStyle {
}

Color _getErrorColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
return TDTheme.of(context).errorNormalColor;
case TDButtonStatus.active:
Expand All @@ -162,7 +162,7 @@ class TDButtonStyle {
}

Color _getDefaultBgColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
return TDTheme.of(context).grayColor3;
case TDButtonStatus.active:
Expand All @@ -173,7 +173,7 @@ class TDButtonStyle {
}

Color _getDefaultTextColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
case TDButtonStatus.active:
return TDTheme.of(context).fontGyColor1;
Expand All @@ -183,7 +183,7 @@ class TDButtonStyle {
}

Color _getOutlineDefaultBgColor(BuildContext context, TDButtonStatus status) {
switch(status){
switch (status) {
case TDButtonStatus.defaultState:
return TDTheme.of(context).whiteColor1;
case TDButtonStatus.active:
Expand All @@ -192,5 +192,4 @@ class TDButtonStyle {
return TDTheme.of(context).grayColor2;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class TDAlertDialog extends StatelessWidget {
Widget btn = TDDialogButton(
buttonText: value.title,
buttonTextColor: value.titleColor,
buttonTextSize: value.titleSize,
height: value.height,
buttonTextFontWeight: value.fontWeight ?? FontWeight.w600,
buttonStyle: value.style,
Expand Down
4 changes: 4 additions & 0 deletions tdesign-component/lib/src/components/dialog/td_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TDDialogButtonOptions {
required this.title,
required this.action,
this.titleColor,
this.titleSize,
this.style,
this.type,
this.theme,
Expand All @@ -41,6 +42,9 @@ class TDDialogButtonOptions {
/// 标题颜色
Color? titleColor;

/// 字体大小
final double? titleSize;

/// 字体粗细
final FontWeight? fontWeight;

Expand Down
18 changes: 13 additions & 5 deletions tdesign-component/lib/src/components/dialog/td_dialog_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class HorizontalNormalButtons extends StatelessWidget {
Expanded(
child: TDDialogButton(
buttonText: leftBtn.title,
buttonTextColor: leftBtn.titleColor ?? TDTheme.of(context).brandNormalColor,
buttonTextColor: leftBtn.titleColor,
buttonTextSize: leftBtn.titleSize,
buttonStyle: leftBtn.style,
buttonType: leftBtn.type,
buttonTheme: leftBtn.theme,
Expand All @@ -253,7 +254,8 @@ class HorizontalNormalButtons extends StatelessWidget {
Expanded(
child: TDDialogButton(
buttonText: rightBtn.title,
buttonTextColor: rightBtn.titleColor ?? TDTheme.of(context).whiteColor1,
buttonTextColor: rightBtn.titleColor,
buttonTextSize: rightBtn.titleSize,
buttonStyle: rightBtn.style,
buttonType: rightBtn.type,
buttonTheme: rightBtn.theme,
Expand Down Expand Up @@ -300,7 +302,8 @@ class HorizontalTextButtons extends StatelessWidget {
Expanded(
child: TDDialogButton(
buttonText: leftBtn.title,
buttonTextColor: leftBtn.titleColor ?? TDTheme.of(context).fontGyColor1,
buttonTextColor: leftBtn.titleColor,
buttonTextSize: leftBtn.titleSize,
buttonStyle: leftBtn.style,
buttonType: leftBtn.type ?? TDButtonType.text,
buttonTheme: leftBtn.theme,
Expand All @@ -322,7 +325,8 @@ class HorizontalTextButtons extends StatelessWidget {
Expanded(
child: TDDialogButton(
buttonText: rightBtn.title,
buttonTextColor: rightBtn.titleColor ?? TDTheme.of(context).brandNormalColor,
buttonTextColor: rightBtn.titleColor,
buttonTextSize: rightBtn.titleSize,
buttonStyle: leftBtn.style,
buttonType: leftBtn.type ?? TDButtonType.text,
buttonTheme: leftBtn.theme ?? TDButtonTheme.primary,
Expand Down Expand Up @@ -350,6 +354,7 @@ class TDDialogButton extends StatelessWidget {
Key? key,
this.buttonText,
this.buttonTextColor,
this.buttonTextSize,
this.buttonTextFontWeight = FontWeight.w600,
this.buttonStyle,
this.buttonType,
Expand All @@ -366,6 +371,9 @@ class TDDialogButton extends StatelessWidget {
/// 按钮文字颜色
final Color? buttonTextColor;

/// 按钮文字大小
final double? buttonTextSize;

/// 按钮文字粗细
final FontWeight? buttonTextFontWeight;

Expand Down Expand Up @@ -398,7 +406,7 @@ class TDDialogButton extends StatelessWidget {
type: buttonType ?? TDButtonType.fill,
theme: buttonTheme,
text: buttonText,
textStyle: TextStyle(fontWeight: buttonTextFontWeight, color: buttonTextColor),
textStyle: TextStyle(fontWeight: buttonTextFontWeight,color:buttonTextColor,fontSize: buttonTextSize),
width: width,
height: height,
isBlock: isBlock,
Expand Down
7 changes: 5 additions & 2 deletions tdesign-component/lib/src/components/stepper/td_stepper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,11 @@ class _TDStepperState extends State<TDStepper> {
textAlign: TextAlign.center,
textAlignVertical: TextAlignVertical.center,
keyboardType: TextInputType.number,
decoration:
const InputDecoration(border: InputBorder.none),
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
TextInputFormatter.withFunction((oldValue, newValue) {
Expand Down
Loading