-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:forui/forui.dart'; | ||
|
||
/// The content for a text button. | ||
class FTextButtonContent extends StatelessWidget { | ||
/// Represents a content for [FButton]. | ||
final class FButtonContent extends StatelessWidget { | ||
/// The label on the button. | ||
final String text; | ||
final String? text; | ||
|
||
/// Creates a [FTextButtonContent]. | ||
const FTextButtonContent( | ||
this.text, { | ||
super.key, | ||
}); | ||
/// The icon; | ||
final String? icon; | ||
|
||
/// The child. | ||
final Widget? child; | ||
|
||
/// The style. | ||
final FButtonContentStyle? style; | ||
|
||
/// Creates a [FButtonContent]. | ||
const FButtonContent({ | ||
this.text, | ||
this.icon, | ||
this.child, | ||
this.style, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) => Container( | ||
alignment: Alignment.center, | ||
child: Text(text), | ||
); | ||
Widget build(BuildContext context) { | ||
final style = this.style ?? FTheme.of(context).widgets.button.content; | ||
|
||
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [ | ||
// [SvgTheme] provides a default color that overrides material's ButtonStyle foregroundColor | ||
// This is a workaround, the color of the icon is set here instead of the ButtonStyle. | ||
if (icon != null) //...[icon(height: 20, color: style.color), const SizedBox(width: 10)], | ||
if (text != null) Flexible(child: Text(text!, style: style.text)), | ||
if (child != null) child! | ||
]); | ||
} | ||
} | ||
// | ||
// /// The content for a icon button. | ||
// class IconButtonContent extends StatelessWidget { | ||
// /// The label on the button. | ||
// final String text; | ||
// | ||
// /// The icon. | ||
// final SvgAsset icon; | ||
// | ||
// /// The icon color | ||
// final Color color; | ||
// | ||
// /// Creates a [TextButtonContent]. | ||
// const IconButtonContent({ | ||
// required this.text, | ||
// required this.icon, | ||
// this.color = Colors.white, | ||
// super.key, | ||
// }); | ||
// | ||
// @override | ||
// Widget build(BuildContext context) => Row( | ||
// mainAxisAlignment: MainAxisAlignment.center, | ||
// children: [ | ||
// // [SvgTheme] provides a default color that overrides material's ButtonStyle foregroundColor | ||
// // This is a workaround, the color of the icon is set here instead of the ButtonStyle. | ||
// icon(height: 20, color: color), | ||
// const SizedBox(width: 10), | ||
// Flexible( | ||
// child: Text( | ||
// text, | ||
// ), | ||
// ), | ||
// ], | ||
// ); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:forui/forui.dart'; | ||
|
||
/// [FButtonContent]'s style. | ||
class FButtonContentStyle { | ||
/// The padding. | ||
final EdgeInsets padding; | ||
|
||
/// The title. | ||
final TextStyle text; | ||
|
||
/// The icon color. | ||
final Color color; | ||
|
||
/// Creates a [FButtonContentStyle]. | ||
const FButtonContentStyle({required this.padding, required this.text, required this.color}); | ||
|
||
/// Creates a [FButtonContentStyle] that inherits its properties from [style] and [font]. | ||
FButtonContentStyle.inherit({required FStyleData style, required FFontData font}) | ||
: padding = const EdgeInsets.fromLTRB(16, 12, 16, 16), | ||
text = ScaledTextStyle( | ||
TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w600, | ||
color: style.foreground, | ||
), | ||
font, | ||
), | ||
color = Colors.white; | ||
} |
Oops, something went wrong.