deprecation: opacity

This commit is contained in:
Thibault Deckers 2024-10-26 00:10:40 +02:00
parent e039798463
commit 884baae602
35 changed files with 59 additions and 59 deletions

@ -1 +1 @@
Subproject commit 603104015dd692ea3403755b55d07813d5cf8965
Subproject commit b1c77b7ed32346fe829c0ca97bd85d19290d54ae

View file

@ -41,11 +41,11 @@ class Themes {
static Color _schemeThirdLayer(ColorScheme colors) => _isDarkTheme(colors) ? colors.surfaceContainerHighest : colors.surfaceContainerHigh;
static Color _unselectedWidgetColor(ColorScheme colors) => colors.onSurface.withOpacity(0.6);
static Color _unselectedWidgetColor(ColorScheme colors) => colors.onSurface.withAlpha((255.0 * .6).round());
static Color backgroundTextColor(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Color.alphaBlend(colors.surfaceTint, colors.onSurface).withOpacity(.5);
return Color.alphaBlend(colors.surfaceTint, colors.onSurface).withAlpha((255.0 * .5).round());
}
static final _typography = Typography.material2021(platform: TargetPlatform.android);
@ -98,7 +98,7 @@ class Themes {
// adapted from M3 defaults
final TextStyle style = textTheme.labelLarge!;
if (states.contains(WidgetState.disabled)) {
return style.apply(color: colors.onSurface.withOpacity(0.38));
return style.apply(color: colors.onSurface.withAlpha((255.0 * .38).round()));
}
return style.apply(color: colors.onSurface);
}),
@ -118,12 +118,12 @@ class Themes {
fillColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.disabled)) {
return colors.onSurface.withOpacity(0.38);
return colors.onSurface.withAlpha((255.0 * .38).round());
}
return colors.primary;
}
if (states.contains(WidgetState.disabled)) {
return colors.onSurface.withOpacity(0.38);
return colors.onSurface.withAlpha((255.0 * .38).round());
}
if (states.contains(WidgetState.pressed)) {
return colors.onSurface;
@ -139,7 +139,7 @@ class Themes {
);
static SliderThemeData _sliderTheme(ColorScheme colors) => SliderThemeData(
inactiveTrackColor: colors.primary.withOpacity(0.24),
inactiveTrackColor: colors.primary.withAlpha((255.0 * .24).round()),
);
static SnackBarThemeData _snackBarTheme(ColorScheme colors) => SnackBarThemeData(

View file

@ -103,7 +103,7 @@ class _ContentState extends State<_Content> {
return ListTile(
title: DefaultTextStyle(
style: theme.textTheme.bodyLarge!.copyWith(
color: isSelected ? colors.primary : colors.onSurface.withOpacity(0.64),
color: isSelected ? colors.primary : colors.onSurface.withAlpha((255.0 * .64).round()),
),
child: _getTitle(_Section.values[index]),
),

View file

@ -62,19 +62,19 @@ class _RandomTextSpanHighlighterState extends State<_RandomTextSpanHighlighter>
final color = widget.color;
_baseStyle = TextStyle(
color: color.withOpacity(.7),
color: color.withAlpha((255.0 * .7).round()),
shadows: [
Shadow(
color: color.withOpacity(0),
color: color.withAlpha(0),
blurRadius: 0,
)
],
);
final highlightStyle = TextStyle(
color: color.withOpacity(1),
color: color.withAlpha(255),
shadows: [
Shadow(
color: color.withOpacity(1),
color: color.withAlpha(255),
blurRadius: 3,
)
],

View file

@ -421,7 +421,7 @@ class _CollectionScaler extends StatelessWidget {
),
mosaicItemBuilder: (index, targetExtent) => DecoratedBox(
decoration: BoxDecoration(
color: ThumbnailImage.computeLoadingBackgroundColor(index * 10, brightness).withOpacity(.9),
color: ThumbnailImage.computeLoadingBackgroundColor(index * 10, brightness).withAlpha((255.0 * .9).round()),
border: Border.all(
color: borderColor,
width: borderWidth,

View file

@ -257,7 +257,7 @@ class _ReportOverlayState<T> extends State<ReportOverlay<T>> with SingleTickerPr
percent: percent,
lineWidth: strokeWidth,
radius: diameter / 2,
backgroundColor: colorScheme.onSurface.withOpacity(.2),
backgroundColor: colorScheme.onSurface.withAlpha((255.0 * .2).round()),
progressColor: progressColor,
animation: animate,
center: total != null
@ -314,7 +314,7 @@ class ReportProgressIndicator extends StatelessWidget {
height: diameter,
padding: const EdgeInsets.all(strokeWidth / 2),
child: CircularProgressIndicator(
color: progressColor.withOpacity(opacity),
color: progressColor.withAlpha((255.0 * opacity).round()),
strokeWidth: strokeWidth,
),
);
@ -422,7 +422,7 @@ class _FeedbackMessageState extends State<_FeedbackMessage> with SingleTickerPro
style: contentTextStyle.copyWith(
shadows: [
Shadow(
color: timerChangeShadowColor.withOpacity(0),
color: timerChangeShadowColor.withAlpha(0),
blurRadius: 0,
)
],

View file

@ -16,7 +16,7 @@ class SliverAppBarTitleWrapper extends StatelessWidget {
final toolbarOpacity = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>()!.toolbarOpacity;
final baseColor = (DefaultTextStyle.of(context).style.color ?? Theme.of(context).textTheme.titleLarge!.color!);
return DefaultTextStyle.merge(
style: TextStyle(color: baseColor.withOpacity(toolbarOpacity)),
style: TextStyle(color: baseColor.withAlpha((255.0 * toolbarOpacity).round())),
child: child,
);
}

View file

@ -81,7 +81,7 @@ class _WheelSelectorState<T> extends State<WheelSelector<T>> {
height: itemSize.height,
duration: transitionDuration,
decoration: BoxDecoration(
color: foreground.withOpacity(focused ? .2 : 0),
color: foreground.withAlpha((255.0 * (focused ? .2 : 0)).round()),
borderRadius: const BorderRadius.all(Radius.circular(8)),
),
);

View file

@ -31,7 +31,7 @@ class GridItemSelectionOverlay<T> extends StatelessWidget {
alignment: AlignmentDirectional.topEnd,
padding: padding,
decoration: BoxDecoration(
color: isSelected ? Theme.of(context).colorScheme.primary.withOpacity(.6) : Colors.transparent,
color: isSelected ? Theme.of(context).colorScheme.primary.withAlpha((255.0 * .6).round()) : Colors.transparent,
borderRadius: borderRadius,
),
duration: duration,

View file

@ -77,7 +77,7 @@ class FixedExtentGridPainter extends CustomPainter {
..shader = strokeShader;
final fillPaint = Paint()
..style = PaintingStyle.fill
..color = color.withOpacity(.25);
..color = color.withAlpha((255.0 * .25).round());
final chipWidth = chipSize.width;
final chipHeight = chipSize.height;

View file

@ -51,7 +51,7 @@ class MosaicScaleOverlay extends StatelessWidget {
child: Stack(
alignment: Alignment.center,
children: [
_buildBar(extentMax, colorScheme.onSurface.withOpacity(.2)),
_buildBar(extentMax, colorScheme.onSurface.withAlpha((255.0 * .2).round())),
_buildBar(scaledSize.width, colorScheme.primary),
],
),

View file

@ -270,7 +270,7 @@ class _AvesFloatingBarState extends State<AvesFloatingBar> with RouteAware {
borderRadius: AvesFloatingBar.borderRadius,
child: widget.builder(
context,
blurred ? backgroundColor.withOpacity(.85) : backgroundColor,
blurred ? backgroundColor.withAlpha((255.0 * .85).round()) : backgroundColor,
widget.child,
),
),

View file

@ -23,7 +23,7 @@ class AvesCaption extends StatelessWidget {
style: subtitleStyle.copyWith(
shadows: [
Shadow(
color: subtitleChangeShadowColor.withOpacity(0),
color: subtitleChangeShadowColor.withAlpha(0),
blurRadius: 0,
)
],

View file

@ -164,7 +164,7 @@ class CaptionedButtonText extends StatelessWidget {
Widget build(BuildContext context) {
var style = DefaultTextStyle.of(context).style;
if (!enabled) {
style = style.copyWith(color: style.color!.withOpacity(.2));
style = style.copyWith(color: style.color!.withAlpha((255.0 * .2).round()));
}
return Text(

View file

@ -175,7 +175,7 @@ class OverlayTextButton extends StatelessWidget {
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all<Color>(Themes.overlayBackgroundColor(brightness: theme.brightness, blurred: blurred)),
foregroundColor: WidgetStateProperty.all<Color>(theme.colorScheme.onSurface),
overlayColor: theme.isDark ? WidgetStateProperty.all<Color>(Colors.white.withOpacity(0.12)) : null,
overlayColor: theme.isDark ? WidgetStateProperty.all<Color>(Colors.white.withAlpha((255.0 * .12).round())) : null,
minimumSize: _minSize,
side: WidgetStateProperty.all<BorderSide>(AvesBorder.curvedSide(context)),
shape: WidgetStateProperty.all<OutlinedBorder>(const RoundedRectangleBorder(

View file

@ -25,7 +25,7 @@ class EmptyContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.primary.withOpacity(.5);
final color = Theme.of(context).colorScheme.primary.withAlpha((255.0 * .5).round());
final durations = context.watch<DurationsData>();
return Padding(
padding: safeBottom

View file

@ -26,7 +26,7 @@ class CompassPainter extends CustomPainter {
final fillPaint = Paint()
..style = PaintingStyle.fill
..color = color.withOpacity(.6);
..color = color.withAlpha((255.0 * .6).round());
final strokePaint = Paint()
..style = PaintingStyle.stroke
..color = color

View file

@ -188,7 +188,7 @@ class _ConvertEntryDialogState extends State<ConvertEntryDialog> {
// used by the drop down to match input decoration
final textFieldDecorationBorder = Border(
bottom: BorderSide(
color: colorScheme.onSurface.withOpacity(0.38),
color: colorScheme.onSurface.withAlpha((255.0 * .38).round()),
width: 1.0,
),
);
@ -309,7 +309,7 @@ class _ConvertEntryDialogState extends State<ConvertEntryDialog> {
style: trailingStyle.copyWith(
shadows: [
Shadow(
color: trailingChangeShadowColor.withOpacity(0),
color: trailingChangeShadowColor.withAlpha(0),
blurRadius: 0,
)
],

View file

@ -19,8 +19,8 @@ class CropperPainter extends CustomPainter {
static const double gridWidth = 1;
static const cornerColor = Colors.white;
static final borderColor = Colors.white.withOpacity(.5);
static final gridColor = Colors.white.withOpacity(.5);
static final borderColor = Colors.white.withAlpha((255.0 * .5).round());
static final gridColor = Colors.white.withAlpha((255.0 * .5).round());
@override
void paint(Canvas canvas, Size size) {
@ -32,7 +32,7 @@ class CropperPainter extends CustomPainter {
final gridPaint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = gridWidth
..color = gridColor.withOpacity(gridColor.opacity * gridOpacity);
..color = gridColor.withAlpha((255.0 * gridColor.opacity * gridOpacity).round());
final xLeft = rect.left;
final yTop = rect.top;
@ -118,7 +118,7 @@ class ScrimPainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final scrimPaint = Paint()
..style = PaintingStyle.fill
..color = scrimColor.withOpacity(opacity);
..color = scrimColor.withAlpha((255.0 * opacity).round());
final outside = Path()
..addRect(Rect.fromLTWH(0, 0, size.width, size.height).inflate(.5))

View file

@ -592,7 +592,7 @@ class _FilterScaler<T extends CollectionFilter> extends StatelessWidget {
),
mosaicItemBuilder: (index, targetExtent) => DecoratedBox(
decoration: BoxDecoration(
color: ThumbnailImage.computeLoadingBackgroundColor(index * 10, brightness).withOpacity(.9),
color: ThumbnailImage.computeLoadingBackgroundColor(index * 10, brightness).withAlpha((255.0 * .9).round()),
border: Border.all(
color: context.read<AvesColorsData>().neutral,
width: AvesFilterChip.outlineWidth,

View file

@ -175,8 +175,8 @@ class _AppDrawerState extends State<AppDrawer> with WidgetsBindingObserver {
data: OutlinedButtonThemeData(
style: ButtonStyle(
foregroundColor: WidgetStateProperty.all<Color>(onPrimary),
overlayColor: WidgetStateProperty.all<Color>(onPrimary.withOpacity(.12)),
side: WidgetStateProperty.all<BorderSide>(BorderSide(width: 1, color: onPrimary.withOpacity(.24))),
overlayColor: WidgetStateProperty.all<Color>(onPrimary.withAlpha((255.0 * .12).round())),
side: WidgetStateProperty.all<BorderSide>(BorderSide(width: 1, color: onPrimary.withAlpha((255.0 * .24).round()))),
),
),
child: Column(

View file

@ -36,7 +36,7 @@ class CollectionNavTile extends StatelessWidget {
trailing: trailing != null
? Builder(
builder: (context) {
final trailingColor = IconTheme.of(context).color!.withOpacity(.6);
final trailingColor = IconTheme.of(context).color!.withAlpha((255.0 * .6).round());
return IconTheme.merge(
data: IconThemeData(color: trailingColor),
child: DefaultTextStyle.merge(

View file

@ -43,7 +43,7 @@ class PageNavTile extends StatelessWidget {
? Builder(
builder: (context) => DefaultTextStyle.merge(
style: TextStyle(
color: IconTheme.of(context).color!.withOpacity(.6),
color: IconTheme.of(context).color!.withAlpha((255.0 * .6).round()),
),
child: trailing!,
),

View file

@ -15,10 +15,10 @@ class ActionPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final color = highlight ? theme.colorScheme.primary : Color.alphaBlend(theme.colorScheme.surfaceTint.withOpacity(.2), Themes.secondLayerColor(context));
final color = highlight ? theme.colorScheme.primary : Color.alphaBlend(theme.colorScheme.surfaceTint.withAlpha((255.0 * .2).round()), Themes.secondLayerColor(context));
return AnimatedContainer(
foregroundDecoration: BoxDecoration(
color: color.withOpacity(.2),
color: color.withAlpha((255.0 * .2).round()),
border: Border.fromBorderSide(BorderSide(
color: color,
width: highlight ? 2 : 1,

View file

@ -287,7 +287,7 @@ class _QuickActionEditorBodyState<T extends Object> extends State<QuickActionEdi
effect: WormEffect(
dotWidth: 8,
dotHeight: 8,
dotColor: colorScheme.onSurface.withOpacity(.2),
dotColor: colorScheme.onSurface.withAlpha((255.0 * .2).round()),
activeDotColor: colorScheme.primary,
),
),

View file

@ -141,7 +141,7 @@ class _FilePickerPageState extends State<FilePickerPage> {
height: kMinInteractiveDimension,
child: DefaultTextStyle(
style: crumbStyle.copyWith(
color: crumbStyle.color!.withOpacity(.4),
color: crumbStyle.color!.withAlpha((255.0 * .4).round()),
fontWeight: FontWeight.w500,
),
child: CrumbLine(

View file

@ -121,7 +121,7 @@ class ThumbnailOverlayPage extends StatelessWidget {
icon,
key: ValueKey(key),
size: _getIconSize(context),
color: _getIconColor(context).withOpacity(disabled ? SettingsSwitchListTile.disabledOpacity : 1.0),
color: _getIconColor(context).withAlpha((255.0 * (disabled ? SettingsSwitchListTile.disabledOpacity : 1.0)).round()),
),
),
);

View file

@ -22,7 +22,7 @@ class SubtitleSample extends StatelessWidget {
builder: (context, settings, child) {
final textAlign = settings.subtitleTextAlignment;
final textPosition = settings.subtitleTextPosition;
final outlineColor = Colors.black.withOpacity(settings.subtitleTextColor.opacity);
final outlineColor = Colors.black.withAlpha((255.0 * settings.subtitleTextColor.opacity).round());
final shadows = [
Shadow(
color: outlineColor,

View file

@ -62,23 +62,23 @@ class SubtitleThemePage extends StatelessWidget {
),
ColorListTile(
title: context.l10n.settingsSubtitleThemeTextColor,
value: settings.subtitleTextColor.withOpacity(1),
onChanged: (v) => settings.subtitleTextColor = v.withOpacity(settings.subtitleTextColor.opacity),
value: settings.subtitleTextColor.withAlpha(255),
onChanged: (v) => settings.subtitleTextColor = v.withAlpha((255.0 * settings.subtitleTextColor.opacity).round()),
),
SliderListTile(
title: context.l10n.settingsSubtitleThemeTextOpacity,
value: settings.subtitleTextColor.opacity,
onChanged: (v) => settings.subtitleTextColor = settings.subtitleTextColor.withOpacity(v),
onChanged: (v) => settings.subtitleTextColor = settings.subtitleTextColor.withAlpha((255.0 * v).round()),
),
ColorListTile(
title: context.l10n.settingsSubtitleThemeBackgroundColor,
value: settings.subtitleBackgroundColor.withOpacity(1),
onChanged: (v) => settings.subtitleBackgroundColor = v.withOpacity(settings.subtitleBackgroundColor.opacity),
value: settings.subtitleBackgroundColor.withAlpha(255),
onChanged: (v) => settings.subtitleBackgroundColor = v.withAlpha((255.0 * settings.subtitleBackgroundColor.opacity).round()),
),
SliderListTile(
title: context.l10n.settingsSubtitleThemeBackgroundOpacity,
value: settings.subtitleBackgroundColor.opacity,
onChanged: (v) => settings.subtitleBackgroundColor = settings.subtitleBackgroundColor.withOpacity(v),
onChanged: (v) => settings.subtitleBackgroundColor = settings.subtitleBackgroundColor.withAlpha((255.0 * v).round()),
),
SettingsSwitchListTile(
selector: (context, s) => s.subtitleShowOutline,

View file

@ -198,7 +198,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
final colorScheme = Theme.of(context).colorScheme;
final accentColor = colorScheme.primary;
final axisColor = charts.ColorUtil.fromDartColor(drawPoints ? colorScheme.onSurface : Colors.transparent);
final measureLineColor = charts.ColorUtil.fromDartColor(drawPoints ? colorScheme.onSurface.withOpacity(.1) : Colors.transparent);
final measureLineColor = charts.ColorUtil.fromDartColor(drawPoints ? colorScheme.onSurface.withAlpha((255.0 * .1).round()) : Colors.transparent);
final histogramLineColor = charts.ColorUtil.fromDartColor(drawLine ? accentColor : Colors.white);
final histogramPointStrikeColor = charts.ColorUtil.fromDartColor(drawPoints ? colorScheme.onSurface : Colors.transparent);
final histogramPointFillColor = charts.ColorUtil.fromDartColor(Themes.firstLayerColor(context));
@ -292,7 +292,7 @@ class _HistogramState extends State<Histogram> with AutomaticKeepAliveClientMixi
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
accentColor.withOpacity(0),
accentColor.withAlpha(0),
accentColor,
],
).createShader,

View file

@ -178,7 +178,7 @@ class _ViewerVerticalPageViewState extends State<ViewerVerticalPageView> {
builder: (context, overlayOpacity, child) {
final background = Theme.of(context).isDark ? Colors.black : Color.lerp(Colors.black, Colors.white, overlayOpacity)!;
return Container(
color: background.withOpacity(backgroundOpacity),
color: background.withAlpha((255.0 * backgroundOpacity).round()),
child: child,
);
},

View file

@ -138,7 +138,7 @@ class _HistogramPainter extends CustomPainter {
Path()..addPolygon(polyline, true),
Paint()
..style = PaintingStyle.fill
..color = color.withOpacity(.5));
..color = color.withAlpha((255.0 * .5).round()));
}
Color _getChannelColor(HistogramChannel channel) {

View file

@ -119,7 +119,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
if (!progress.isFinite) progress = 0.0;
return LinearProgressIndicator(
value: progress,
backgroundColor: theme.colorScheme.onSurface.withOpacity(.2),
backgroundColor: theme.colorScheme.onSurface.withAlpha((255.0 * .2).round()),
);
}),
),

View file

@ -44,7 +44,7 @@ class VideoSubtitles extends StatelessWidget {
final baseTextAlign = settings.subtitleTextAlignment;
final baseTextAlignY = settings.subtitleTextPosition.toTextAlignVertical();
final baseOutlineWidth = settings.subtitleShowOutline ? 1 : 0;
final baseOutlineColor = Colors.black.withOpacity(settings.subtitleTextColor.opacity);
final baseOutlineColor = Colors.black.withAlpha((255.0 * settings.subtitleTextColor.opacity).round());
final baseShadows = [
Shadow(
color: baseOutlineColor,

View file

@ -43,9 +43,9 @@ class SwipeActionFeedback extends StatelessWidget {
static const Radius radius = Radius.circular(width / 2);
static const double borderWidth = 2;
static const Color borderColor = Colors.white;
static final Color fillColor = Colors.white.withOpacity(.8);
static final Color backgroundColor = Colors.black.withOpacity(.2);
static final Color innerBorderColor = Colors.black.withOpacity(.5);
static final Color fillColor = Colors.white.withAlpha((255.0 * .8).round());
static final Color backgroundColor = Colors.black.withAlpha((255.0 * .2).round());
static final Color innerBorderColor = Colors.black.withAlpha((255.0 * .5).round());
static const Color iconColor = Colors.white;
static const Color shadowColor = Colors.black;