feat: implement afdivider (#7803)

This commit is contained in:
Richard Shiue 2025-04-22 22:14:03 +08:00 committed by GitHub
parent 6bdaee3a00
commit f9f151e89e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 0 deletions

View file

@ -1,3 +1,4 @@
export 'button/button.dart';
export 'separator/divider.dart';
export 'modal/modal.dart';
export 'textfield/textfield.dart';

View file

@ -0,0 +1,53 @@
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:flutter/widgets.dart';
class AFDivider extends StatelessWidget {
const AFDivider({
super.key,
this.axis = Axis.horizontal,
this.color,
this.thickness = 1.0,
this.spacing = 0.0,
this.startIndent = 0.0,
this.endIndent = 0.0,
}) : assert(thickness > 0.0),
assert(spacing >= 0.0),
assert(startIndent >= 0.0),
assert(endIndent >= 0.0);
final Axis axis;
final double thickness;
final double spacing;
final double startIndent;
final double endIndent;
final Color? color;
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
final color = this.color ?? theme.borderColorScheme.greyTertiary;
return switch (axis) {
Axis.horizontal => Container(
height: thickness,
color: color,
margin: EdgeInsetsDirectional.only(
start: startIndent,
end: endIndent,
top: spacing,
bottom: spacing,
),
),
Axis.vertical => Container(
width: thickness,
color: color,
margin: EdgeInsets.only(
left: spacing,
right: spacing,
top: startIndent,
bottom: endIndent,
),
),
};
}
}