diff options
Diffstat (limited to 'lib/widgets/common/fx/borders.dart')
| -rw-r--r-- | lib/widgets/common/fx/borders.dart | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/widgets/common/fx/borders.dart b/lib/widgets/common/fx/borders.dart new file mode 100644 index 0000000..ac4cfdc --- /dev/null +++ b/lib/widgets/common/fx/borders.dart @@ -0,0 +1,24 @@ +import 'package:aves/widgets/common/extensions/theme.dart'; +import 'package:flutter/material.dart'; + +class AvesBorder { + static Color _borderColor(BuildContext context) => Theme.of(context).isDark ? Colors.white30 : Colors.black26; + + // 1 device pixel for straight lines is fine + static double straightBorderWidth(BuildContext context) => 1 / MediaQuery.devicePixelRatioOf(context); + + // 1 device pixel for curves is too thin + static double curvedBorderWidth(BuildContext context) => MediaQuery.devicePixelRatioOf(context) > 2 ? 0.5 : 1.0; + + static BorderSide straightSide(BuildContext context, {double? width}) => BorderSide( + color: _borderColor(context), + width: width ?? straightBorderWidth(context), + ); + + static BorderSide curvedSide(BuildContext context, {double? width}) => BorderSide( + color: _borderColor(context), + width: width ?? curvedBorderWidth(context), + ); + + static Border border(BuildContext context, {double? width}) => Border.fromBorderSide(curvedSide(context, width: width)); +} |
