mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Add TextBoxConfig options and fix TextBoxComponent bugs (#534)
* Add TextBoxConfig options and fix TextBxoComponent bugs * Add changelog entry * Fix snackbar deprecation * All examples to have publish to none * One argument per line * No explicit types for local variables * Cache the width * Fix formatting
This commit is contained in:
committed by
renancaraujo
parent
5dc93e1987
commit
d09d2bd449
@ -20,16 +20,31 @@ TextConfig tiny = regular.withFontSize(12.0);
|
||||
|
||||
class MyTextBox extends TextBoxComponent {
|
||||
MyTextBox(String text)
|
||||
: super(text, config: tiny, boxConfig: TextBoxConfig(timePerChar: 0.05));
|
||||
: super(
|
||||
text,
|
||||
config: tiny,
|
||||
boxConfig: TextBoxConfig(
|
||||
timePerChar: 0.05,
|
||||
growingBox: true,
|
||||
margins: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
void drawBackground(Canvas c) {
|
||||
final Rect rect = Rect.fromLTWH(0, 0, width, height);
|
||||
c.drawRect(rect, Paint()..color = const Color(0xFFFF00FF));
|
||||
final margin = boxConfig.margins;
|
||||
final Rect innerRect = Rect.fromLTWH(
|
||||
margin.left,
|
||||
margin.top,
|
||||
width - margin.horizontal,
|
||||
height - margin.vertical,
|
||||
);
|
||||
c.drawRect(
|
||||
rect.deflate(boxConfig.margin),
|
||||
innerRect,
|
||||
Paint()
|
||||
..color = BasicPalette.black.color
|
||||
..color = BasicPalette.white.color
|
||||
..style = PaintingStyle.stroke);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user