diff --git a/lib/localization/material_localization/lb_intl.dart b/lib/localization/material_localization/lb_intl.dart index 5f75d5ce..c517a088 100644 --- a/lib/localization/material_localization/lb_intl.dart +++ b/lib/localization/material_localization/lb_intl.dart @@ -210,6 +210,9 @@ class LbMaterialLocalizations extends GlobalMaterialLocalizations { @override String get backButtonTooltip => 'Zerèck'; + @override + String get clearButtonTooltip => 'Text läschen'; + @override String get bottomSheetLabel => 'Usiicht am ënneren Rand'; @@ -612,6 +615,9 @@ class LbMaterialLocalizations extends GlobalMaterialLocalizations { @override String get selectYearSemanticsLabel => 'Joer auswielen'; + @override + String get selectedDateLabel => 'Gewielt'; + @override String? get selectedRowCountTitleFew => null; diff --git a/lib/ui/utilities/app_theme.dart b/lib/ui/utilities/app_theme.dart index cc211ce9..9fea7f60 100644 --- a/lib/ui/utilities/app_theme.dart +++ b/lib/ui/utilities/app_theme.dart @@ -101,7 +101,7 @@ class AppTheme { space: 1, indent: 16, endIndent: 16, - color: colorScheme.surfaceVariant, + color: colorScheme.surfaceContainerHighest, ), pageTransitionsTheme: const PageTransitionsTheme( builders: { @@ -165,9 +165,9 @@ class AppTheme { titleTextStyle: theme.appBarTheme.titleTextStyle, ), switchTheme: theme.switchTheme.copyWith( - thumbIcon: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.selected)) { + thumbIcon: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.selected)) { return const Icon(Icons.check); } return null; diff --git a/lib/ui/widgets/better_app_bar.dart b/lib/ui/widgets/better_app_bar.dart index e4f1e678..c9c0a91e 100644 --- a/lib/ui/widgets/better_app_bar.dart +++ b/lib/ui/widgets/better_app_bar.dart @@ -476,8 +476,8 @@ class BetterAppBar extends StatefulWidget implements PreferredSizeWidget { /// overall theme's brightness is [Brightness.light], and [ColorScheme.surface] /// if the overall theme's brightness is [Brightness.dark]. /// - /// If this color is a [MaterialStateColor] it will be resolved against - /// [MaterialState.scrolledUnder] when the content of the app's + /// If this color is a [WidgetStateColor] it will be resolved against + /// [WidgetState.scrolledUnder] when the content of the app's /// primary scrollable overlaps the app bar. /// {@endtemplate} /// @@ -774,10 +774,10 @@ class _BetterAppBarState extends State { } } - Color _resolveColor(Set states, Color? widgetColor, Color? themeColor, Color defaultColor) { - return MaterialStateProperty.resolveAs(widgetColor, states) ?? - MaterialStateProperty.resolveAs(themeColor, states) ?? - MaterialStateProperty.resolveAs(defaultColor, states); + Color _resolveColor(Set states, Color? widgetColor, Color? themeColor, Color defaultColor) { + return WidgetStateProperty.resolveAs(widgetColor, states) ?? + WidgetStateProperty.resolveAs(themeColor, states) ?? + WidgetStateProperty.resolveAs(defaultColor, states); } SystemUiOverlayStyle _systemOverlayStyleForBrightness(Brightness brightness, [Color? backgroundColor]) { @@ -803,8 +803,8 @@ class _BetterAppBarState extends State { final ModalRoute? parentRoute = ModalRoute.of(context); final FlexibleSpaceBarSettings? settings = context.dependOnInheritedWidgetOfExactType(); - final Set states = { - if (settings?.isScrolledUnder ?? _scrolledUnder) MaterialState.scrolledUnder, + final Set states = { + if (settings?.isScrolledUnder ?? _scrolledUnder) WidgetState.scrolledUnder, }; final bool hasDrawer = scaffold?.hasDrawer ?? false; @@ -820,11 +820,20 @@ class _BetterAppBarState extends State { defaults.backgroundColor!, ); + final Color scrolledUnderBackground = _resolveColor( + states, + widget.backgroundColor, + appBarTheme.backgroundColor, + Theme.of(context).colorScheme.surfaceContainer, + ); + + final Color effectiveBackgroundColor = states.contains(WidgetState.scrolledUnder) ? scrolledUnderBackground : backgroundColor; + final Color foregroundColor = widget.foregroundColor ?? appBarTheme.foregroundColor ?? defaults.foregroundColor!; final double elevation = widget.elevation ?? appBarTheme.elevation ?? defaults.elevation!; - final double effectiveElevation = states.contains(MaterialState.scrolledUnder) + final double effectiveElevation = states.contains(WidgetState.scrolledUnder) ? widget.scrolledUnderElevation ?? appBarTheme.scrolledUnderElevation ?? defaults.scrolledUnderElevation ?? elevation : elevation; @@ -1074,7 +1083,7 @@ class _BetterAppBarState extends State { appBarTheme.systemOverlayStyle ?? defaults.systemOverlayStyle ?? _systemOverlayStyleForBrightness( - ThemeData.estimateBrightnessForColor(backgroundColor), + ThemeData.estimateBrightnessForColor(effectiveBackgroundColor), // Make the status bar transparent for M3 so the elevation overlay // color is picked up by the statusbar. theme.useMaterial3 ? const Color(0x00000000) : null, @@ -1085,11 +1094,17 @@ class _BetterAppBarState extends State { child: AnnotatedRegion( value: overlayStyle, child: Material( - color: backgroundColor, + color: theme.useMaterial3 ? effectiveBackgroundColor : backgroundColor, elevation: effectiveElevation, type: widget.forceMaterialTransparency ? MaterialType.transparency : MaterialType.canvas, shadowColor: widget.shadowColor ?? appBarTheme.shadowColor ?? defaults.shadowColor, - surfaceTintColor: widget.surfaceTintColor ?? appBarTheme.surfaceTintColor ?? defaults.surfaceTintColor, + surfaceTintColor: widget.surfaceTintColor ?? + appBarTheme.surfaceTintColor + // M3 `defaults.surfaceTint` is Colors.transparent now. It is not used + // here because otherwise, it will cause breaking change for + // `scrolledUnderElevation`. + ?? + (theme.useMaterial3 ? theme.colorScheme.surfaceTint : null), shape: widget.shape ?? appBarTheme.shape ?? defaults.shape, child: Semantics( explicitChildNodes: true, @@ -1140,6 +1155,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { required this.forceMaterialTransparency, required this.clipBehavior, required this.variant, + required this.accessibleNavigation, }) : assert(primary || topPadding == 0.0), _bottomHeight = bottom?.preferredSize.height ?? 0.0; @@ -1177,6 +1193,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { final bool forceMaterialTransparency; final Clip? clipBehavior; final _SliverAppVariant variant; + final bool accessibleNavigation; @override double get minExtent => collapsedHeight; @@ -1204,8 +1221,9 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { final bool isScrolledUnder = overlapsContent || forceElevated || (pinned && shrinkOffset > maxExtent - minExtent); final bool isPinnedWithOpacityFade = pinned && floating && bottom != null && extraToolbarHeight == 0.0; - final double toolbarOpacity = - !pinned || isPinnedWithOpacityFade ? clampDouble(visibleToolbarHeight / (toolbarHeight ?? kToolbarHeight), 0.0, 1.0) : 1.0; + final double toolbarOpacity = !accessibleNavigation && (!pinned || isPinnedWithOpacityFade) + ? clampDouble(visibleToolbarHeight / (toolbarHeight ?? kToolbarHeight), 0.0, 1.0) + : 1.0; final Widget? effectiveTitle = switch (variant) { _SliverAppVariant.small => title, _SliverAppVariant.medium || _SliverAppVariant.large => AnimatedOpacity( @@ -1294,7 +1312,8 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { toolbarTextStyle != oldDelegate.toolbarTextStyle || titleTextStyle != oldDelegate.titleTextStyle || systemOverlayStyle != oldDelegate.systemOverlayStyle || - forceMaterialTransparency != oldDelegate.forceMaterialTransparency; + forceMaterialTransparency != oldDelegate.forceMaterialTransparency || + accessibleNavigation != oldDelegate.accessibleNavigation; } @override @@ -1973,6 +1992,7 @@ class _BetterSliverAppBarState extends State with TickerProv forceMaterialTransparency: widget.forceMaterialTransparency, clipBehavior: widget.clipBehavior, variant: widget._variant, + accessibleNavigation: MediaQuery.of(context).accessibleNavigation, ), ), ); @@ -2183,42 +2203,48 @@ class _RenderExpandedTitleBox extends RenderShiftedBox { return child == null ? 0.0 : child.getMinIntrinsicWidth(double.infinity) + padding.horizontal; } - Size _computeSize(BoxConstraints constraints, ChildLayouter layoutChild) { + @override + Size computeDryLayout(BoxConstraints constraints) => child == null ? Size.zero : constraints.biggest; + + Offset _childOffsetFromSize(Size childSize, Size size) { + assert(child != null); + assert(padding.isNonNegative); + assert(titleAlignment.y == 1.0); + // yAdjustment is the minimum additional y offset to shift the child in + // the visible vertical space when BetterAppBar is fully expanded. The goal is to + // prevent the expanded title from being clipped when the expanded title + // widget + the bottom padding is too tall to fit in the flexible space (the + // top padding is basically ignored since the expanded title is + // bottom-aligned). + final double yAdjustment = clampDouble(childSize.height + padding.bottom - maxExtent, 0, padding.bottom); + final double offsetX = (titleAlignment.x + 1) / 2 * (size.width - padding.horizontal - childSize.width) + padding.left; + final double offsetY = size.height - childSize.height - padding.bottom + yAdjustment; + return Offset(offsetX, offsetY); + } + + @override + double? computeDryBaseline(covariant BoxConstraints constraints, TextBaseline baseline) { final RenderBox? child = this.child; if (child == null) { - return Size.zero; + return null; } - layoutChild(child, constraints.widthConstraints().deflate(padding)); - return constraints.biggest; + final BoxConstraints childConstraints = constraints.widthConstraints().deflate(padding); + final BaselineOffset result = BaselineOffset(child.getDryBaseline(childConstraints, baseline)) + + _childOffsetFromSize(child.getDryLayout(childConstraints), getDryLayout(constraints)).dy; + return result.offset; } - @override - Size computeDryLayout(BoxConstraints constraints) => _computeSize(constraints, ChildLayoutHelper.dryLayoutChild); - @override void performLayout() { final RenderBox? child = this.child; if (child == null) { - this.size = constraints.smallest; + size = constraints.smallest; return; } - final Size size = this.size = _computeSize(constraints, ChildLayoutHelper.layoutChild); - final Size childSize = child.size; - - assert(padding.isNonNegative); - assert(titleAlignment.y == 1.0); - // yAdjustement is the minimum additional y offset to shift the child in - // the visible vertical space when AppBar is fully expanded. The goal is to - // prevent the expanded title from being clipped when the expanded title - // widget + the bottom padding is too tall to fit in the flexible space (the - // top padding is basically ignored since the expanded title is - // bottom-aligned). - final double yAdjustement = clampDouble(childSize.height + padding.bottom - maxExtent, 0, padding.bottom); - final double offsetY = size.height - childSize.height - padding.bottom + yAdjustement; - final double offsetX = (titleAlignment.x + 1) / 2 * (size.width - padding.horizontal - childSize.width) + padding.left; - + size = constraints.biggest; + child.layout(constraints.widthConstraints().deflate(padding), parentUsesSize: true); final BoxParentData childParentData = child.parentData! as BoxParentData; - childParentData.offset = Offset(offsetX, offsetY); + childParentData.offset = _childOffsetFromSize(child.size, size); } } @@ -2289,7 +2315,7 @@ class _AppBarDefaultsM3 extends AppBarTheme { Color? get shadowColor => Colors.transparent; @override - Color? get surfaceTintColor => _colors.surfaceTint; + Color? get surfaceTintColor => Colors.transparent; @override IconThemeData? get iconTheme => IconThemeData( diff --git a/lib/ui/widgets/charts.dart b/lib/ui/widgets/charts.dart index 3ca0faa3..61b235e9 100644 --- a/lib/ui/widgets/charts.dart +++ b/lib/ui/widgets/charts.dart @@ -100,13 +100,13 @@ class _StandardLineChartState extends State { verticalInterval: widget.xGridInterval.toDouble(), getDrawingHorizontalLine: (value) { return FlLine( - color: Theme.of(context).colorScheme.onBackground.withOpacity(0.1), + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1), strokeWidth: 1, ); }, getDrawingVerticalLine: (value) { return FlLine( - color: Theme.of(context).colorScheme.onBackground.withOpacity(0.1), + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1), strokeWidth: 1, ); }, @@ -133,7 +133,7 @@ class _StandardLineChartState extends State { ), borderData: FlBorderData( show: true, - border: Border.all(color: Theme.of(context).colorScheme.surfaceVariant), + border: Border.all(color: Theme.of(context).colorScheme.surfaceContainerHighest), ), minX: minX, maxX: maxX,