Skip to content

Commit

Permalink
YaruTitleBarTheme: fix border side lerp (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnurmi committed Mar 30, 2023
1 parent ff2cc86 commit e8f99e5
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions lib/src/widgets/yaru_title_bar_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,33 @@ class YaruTitleBarThemeData extends ThemeExtension<YaruTitleBarThemeData>
),
titleTextStyle: TextStyle.lerp(titleTextStyle, o?.titleTextStyle, t),
shape: ShapeBorder.lerp(shape, o?.shape, t),
border: BorderSide.lerp(
border ?? BorderSide.none,
o?.border ?? BorderSide.none,
t,
),
border: _lerpBorderSide(border, o?.border, t),
style: t < 0.5 ? style : o?.style,
);
}

// Special case because BorderSide.lerp() doesn't support null arguments.
static BorderSide? _lerpBorderSide(BorderSide? a, BorderSide? b, double t) {
if (a == null && b == null) {
return null;
}
if (a == null) {
return BorderSide.lerp(
BorderSide(width: 0, color: b!.color.withAlpha(0)),
b,
t,
);
}
if (b == null) {
return BorderSide.lerp(
BorderSide(width: 0, color: a.color.withAlpha(0)),
a,
t,
);
}
return BorderSide.lerp(a, b, t);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
Expand Down

0 comments on commit e8f99e5

Please sign in to comment.