simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
+18 -38
View File
@@ -2,35 +2,14 @@ import 'package:flutter/material.dart';
enum BubbleNip { leftTop, rightBottom, none }
class BubbleEdges {
const BubbleEdges.only({
this.top = 0,
this.bottom = 0,
this.left = 0,
this.right = 0,
});
const BubbleEdges.all(double value)
: top = value,
bottom = value,
left = value,
right = value;
final double top;
final double bottom;
final double left;
final double right;
EdgeInsets toEdgeInsets() => EdgeInsets.fromLTRB(left, top, right, bottom);
}
class BubbleStyle {
const BubbleStyle({
this.color,
this.borderWidth = 0,
this.borderColor,
this.elevation = 0,
this.margin = const BubbleEdges.only(),
this.padding = const BubbleEdges.all(8),
this.margin = EdgeInsets.zero,
this.padding = const EdgeInsets.all(8),
this.alignment = Alignment.centerLeft,
this.nip = BubbleNip.none,
this.borderRadius = 12,
@@ -40,23 +19,24 @@ class BubbleStyle {
final double borderWidth;
final Color? borderColor;
final double elevation;
final BubbleEdges margin;
final BubbleEdges padding;
final EdgeInsets margin;
final EdgeInsets padding;
final Alignment alignment;
final BubbleNip nip;
final double borderRadius;
BubbleStyle copyWith({double? borderWidth, Color? borderColor}) => BubbleStyle(
color: color,
borderWidth: borderWidth ?? this.borderWidth,
borderColor: borderColor ?? this.borderColor,
elevation: elevation,
margin: margin,
padding: padding,
alignment: alignment,
nip: nip,
borderRadius: borderRadius,
);
BubbleStyle copyWith({double? borderWidth, Color? borderColor}) =>
BubbleStyle(
color: color,
borderWidth: borderWidth ?? this.borderWidth,
borderColor: borderColor ?? this.borderColor,
elevation: elevation,
margin: margin,
padding: padding,
alignment: alignment,
nip: nip,
borderRadius: borderRadius,
);
}
/// The "nip" is faked by flattening one corner so the bubble anchors to
@@ -96,7 +76,7 @@ class Bubble extends StatelessWidget {
return Align(
alignment: style.alignment,
child: Container(
margin: style.margin.toEdgeInsets(),
margin: style.margin,
decoration: BoxDecoration(
color: style.color,
borderRadius: radius,
@@ -116,7 +96,7 @@ class Bubble extends StatelessWidget {
]
: null,
),
padding: style.padding.toEdgeInsets(),
padding: style.padding,
child: child,
),
);